-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
72 lines (61 loc) · 1.71 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
68
69
70
71
72
cmake_minimum_required(VERSION 3.21)
project(advent_of_code LANGUAGES C)
find_library(CMOCKA cmocka)
find_package(OpenMP)
set(CMAKE_C_STANDARD 23)
option(ASAN "Enable address sanitizer" OFF)
option(DISABLE_2022_16_P2 "Enable 2022 day 16 part 2 (slow)" OFF)
add_compile_options(
-Wall
-Wextra
-Werror
-Wpedantic
-Wno-unused-function
-Wno-unused-parameter
-Wno-sign-compare
-Wno-gnu-folding-constant
$<$<C_COMPILER_ID:GNU>:-Waggressive-loop-optimizations>
-march=native
-mtune=native
-fopenmp
)
add_link_options(
-fopenmp
)
if(ASAN)
add_compile_options(
-fstack-protector-all
-fsanitize=address
-fno-omit-frame-pointer
$<$<C_COMPILER_ID:Clang>:-fsanitize-address-use-after-return=always>
$<$<C_COMPILER_ID:Clang>:-fsanitize=undefined>
-fsanitize-address-use-after-scope
)
add_link_options(
-fsanitize=address
$<$<C_COMPILER_ID:Clang>:-fsanitize=undefined>
)
endif(ASAN)
include(CheckIPOSupported)
check_ipo_supported()
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
include_directories("common")
include_directories("external/libdivide")
function(add_unit_test name source link)
if (CMOCKA)
add_executable(${name} ${source})
target_link_libraries(${name} cmocka common ${link})
add_custom_command(
TARGET ${name}
POST_BUILD
COMMAND ${name}
COMMENT "Tests for ${link} from ${source}"
)
add_custom_target(${name}.RUN_TESTS ${name} ALL)
else()
message(AUTHOR_WARNING "Skipping creating ${name} from ${source} as cmocka is not available")
endif()
endfunction(add_unit_test)
add_subdirectory(common/)
add_subdirectory(2021)
add_subdirectory(2022)