-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
83 lines (71 loc) · 2.13 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
73
74
75
76
77
78
79
80
81
82
83
# cmake settings
cmake_minimum_required(VERSION 3.19.0)
project(pivot VERSION 0.1.0 LANGUAGES C CXX)
# global settings
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# imports
include(CTest)
include(FetchContent)
# options
option(SANITIZE "Enable sanitizers" OFF)
option(GRAPHVIZ_INCLUDE_PATH "Custom path to graphviz headers" OFF)
set(DIMS_UB 6 CACHE STRING "Upper bound on dimensions handled" FORCE)
# dependencies
# CLI11
FetchContent_Declare(
cli11_proj
QUIET
GIT_REPOSITORY https://github.com/CLIUtils/CLI11.git
GIT_TAG ccd6801
)
FetchContent_MakeAvailable(cli11_proj)
## boost
find_package(Boost 1.81.0 REQUIRED)
# core library
file(GLOB_RECURSE pivot_lib_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
list(REMOVE_ITEM pivot_lib_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp")
add_library(pivot ${pivot_lib_SRC})
target_include_directories(pivot PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/include")
target_include_directories(pivot PUBLIC ${Boost_INCLUDE_DIRS})
## graphviz
if (GRAPHVIZ_INCLUDE_PATH)
target_include_directories(pivot PUBLIC ${GRAPHVIZ_INCLUDE_PATH})
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(GVC REQUIRED IMPORTED_TARGET libgvc)
pkg_check_modules(CGRAPH REQUIRED IMPORTED_TARGET libcgraph)
target_include_directories(pivot PUBLIC ${GVC_INCLUDE_DIRS} ${CGRAPH_INCLUDE_DIRS})
endif()
target_compile_options(pivot
PUBLIC
-Wall -Wextra -Werror -Wpedantic
$<$<CONFIG:Debug>:-O0 -g>
)
target_compile_definitions(pivot
PUBLIC
$<$<CONFIG:Debug>:_GLIBCXX_DEBUG>
)
## sanitizer option
if(SANITIZE)
target_compile_options(pivot
PUBLIC
-fsanitize=address,leak,undefined -fno-omit-frame-pointer -fno-sanitize-recover=undefined
)
target_link_options(pivot
PUBLIC
-fsanitize=address,leak,undefined
)
endif()
## upper bound on dimension
target_compile_definitions(pivot
PUBLIC
DIMS_UB=${DIMS_UB}
)
# executable
add_executable(pivot_exec "src/main.cpp")
set_target_properties(pivot_exec PROPERTIES OUTPUT_NAME pivot)
target_link_libraries(pivot_exec PUBLIC pivot PRIVATE CLI11::CLI11)
# tests
add_subdirectory(tests)