OS detection through Cmake
This commit is contained in:
parent
dc8e8a27fe
commit
2e89a903ec
@ -16,5 +16,13 @@ file(GLOB SRC2020 src/2020/*.c)
|
||||
file(COPY input DESTINATION ${CMAKE_BINARY_DIR})
|
||||
|
||||
add_executable(advent ${SRC} ${SRC2015} ${SRC2016} ${SRC2017} ${SRC2018} ${SRC2019} ${SRC2020})
|
||||
target_link_libraries(advent PRIVATE bsd flint)
|
||||
|
||||
if ((${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") OR (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD"))
|
||||
message(WARNING "${CMAKE_SYSTEM_NAME}: Not linking libbsd")
|
||||
target_link_libraries(advent PRIVATE flint)
|
||||
else()
|
||||
message(WARNING "${CMAKE_SYSTEM_NAME}: Linking libbsd")
|
||||
target_link_libraries(advent PRIVATE bsd flint)
|
||||
endif()
|
||||
|
||||
target_include_directories(advent PRIVATE include lib/libflint/include)
|
@ -6,7 +6,7 @@ Advent Of Code solutions using C99.
|
||||
|
||||
Be sure to clone the project with its submodules:
|
||||
|
||||
git clone --recurse-submodules -j8 https://git.fputs.com/fputs/advent
|
||||
git clone --recurse-submodules https://git.fputs.com/fputs/advent
|
||||
|
||||
This project relies on several BSD extensions to the stdlib. BSDs should be able to build the project out of the box. Linux users will need `libbsd` installed. The package is called `libbsd-dev` on Debian-based systems.
|
||||
|
||||
@ -17,6 +17,8 @@ Build the project using Cmake:
|
||||
cmake ..
|
||||
make
|
||||
|
||||
The supplied `build.sh` script uses `scan-build` to build a compilation database. This is not neccesary for users.
|
||||
|
||||
## Inputs
|
||||
|
||||
Inputs can be generated from `get_input.sh`. You will need to get your session cookie from the Advent of Code website. The easiest way to do this is to inspect any input page in your browser.
|
||||
|
8
build.sh
Executable file
8
build.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#! /usr/bin/env sh
|
||||
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
cp advent ..
|
||||
cd ..
|
@ -3,7 +3,9 @@
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <bsd/stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "input.h"
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <bsd/stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "advent2015.h"
|
||||
#include "advent2016.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user