diff --git a/.gitignore b/.gitignore index a429d65..438252d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ input/ advent compile_commands.json .cache +cmake-build-debug +cmake-build-release +build diff --git a/.idea/advent.iml b/.idea/advent.iml new file mode 100644 index 0000000..6d70257 --- /dev/null +++ b/.idea/advent.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..f1c67df --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..af3e273 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..9661ac7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..8cfc77d --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1630619869539 + + + + + + + + + + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c027341 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.10) + +project(advent C) + +file(GLOB SRC src/*.c) +file(GLOB SRC2015 src/2015/*.c) +file(GLOB SRC2016 src/2016/*.c) +file(GLOB SRC2017 src/2017/*.c) +file(GLOB SRC2018 src/2018/*.c) +file(GLOB SRC2019 src/2019/*.c) +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) +target_include_directories(advent PRIVATE include) \ No newline at end of file diff --git a/GNUmakefile b/GNUmakefile deleted file mode 100644 index 261d672..0000000 --- a/GNUmakefile +++ /dev/null @@ -1,16 +0,0 @@ -CFLAGS= -std=c99 -Wall -pedantic -Iinclude -g -LDFLAGS= -lbsd -OUT= -o advent -SRC= src/*.c \ - src/2015/*.c \ - src/2016/*.c \ - src/2017/*.c \ - src/2018/*.c \ - src/2019/*.c \ - src/2020/*.c - -all: - cc ${CFLAGS} ${OUT} ${LDFLAGS} ${SRC} - -clean: - rm advent diff --git a/Makefile b/Makefile deleted file mode 100644 index f769d76..0000000 --- a/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -CFLAGS= -std=c99 -Wall -pedantic -Iinclude -g -LDFLAGS= '' -OUT= -o advent -SRC= src/*.c \ - src/2015/*.c \ - src/2016/*.c \ - src/2017/*.c \ - src/2018/*.c \ - src/2019/*.c \ - src/2020/*.c - -all: - cc ${CFLAGS} ${OUT} ${LDFLAGS} ${SRC} - -clean: - rm advent diff --git a/README.md b/README.md index 0ed5a9e..6bbe8f8 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,14 @@ Advent Of Code solutions using C99. ## Building -This project relies on several BSD extensions to the stdlib. BSDs should be able to build the project out of the box. If on a BSD, `make` is enough to build the project. +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. -Linux users will need `libbsd` installed and use GNU Make with the supplied GNUmakefile, which should be automatically used with a simple `make`. +Build the project using Cmake: + + mkdir build + cd build + cmake .. + make ## Inputs