-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
68 lines (56 loc) · 2.1 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
cmake_minimum_required(VERSION 3.15)
# so MSVC will compile and link correctly
cmake_policy(SET CMP0091 NEW)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
include(CMakeDependentOption)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
project(AOC LANGUAGES C CXX)
include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_DATAROOTDIR}/cmake/aoc)
# build flags
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
endif()
if(NOT CMAKE_CONFIGURATION_TYPES)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
##
# @brief Symbolically links a list of files to build directory
# @param ARGN files to link. Must be relative paths!
function(SYMLINK_FILES)
# make absolute paths
foreach(s IN LISTS ARGN)
if(NOT IS_ABSOLUTE "${s}")
get_filename_component(sabs "${s}" ABSOLUTE)
file(CREATE_LINK "${sabs}" "${CMAKE_CURRENT_BINARY_DIR}/${s}" SYMBOLIC)
else()
message(ERROR "can't call SYMLINK_FILES with an absolute path")
endif()
endforeach()
endfunction()
function(AOC_EXECUTABLE name)
# join the 2 parent directories of executable
get_filename_component(DAY_DIR "${CMAKE_CURRENT_SOURCE_DIR}" DIRECTORY)
get_filename_component(YEAR_DIR "${DAY_DIR}" DIRECTORY)
get_filename_component(YEAR_DIR "${DAY_DIR}" NAME)
get_filename_component(DAY_DIR "${CMAKE_CURRENT_SOURCE_DIR}" NAME)
add_executable("${YEAR_DIR}_${DAY_DIR}_${name}" ${ARGN})
target_link_libraries("${YEAR_DIR}_${DAY_DIR}_${name}" aoc_common)
set_target_properties("${YEAR_DIR}_${DAY_DIR}_${name}" PROPERTIES OUTPUT_NAME "${name}")
endfunction()
# add user modules
include("aoc-modules")
add_subdirectory(common)
add_subdirectory(2015)
add_subdirectory(2016)
add_subdirectory(2017)
add_subdirectory(2018)
add_subdirectory(2019)
add_subdirectory(2020)
add_subdirectory(2021)
add_subdirectory(2022)
add_subdirectory(2023)
add_subdirectory(2024)