-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
63 lines (50 loc) · 1.73 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
cmake_minimum_required(VERSION 3.16)
project(CtUnits CXX)
include(cmake/StandardProjectSettings.cmake)
add_library(project_options INTERFACE)
target_compile_features(project_options INTERFACE cxx_std_17)
if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
option(
ENABLE_BUILD_WITH_TIME_TRACE
"Enable -ftime-trace to generate time tracing .json files on clang"
OFF)
if(ENABLE_BUILD_WITH_TIME_TRACE)
add_compile_definitions(project_options INTERFACE -ftime-trace)
endif()
endif()
# Link this 'library' to use the warnings specified in CompilerWarnings.cmake
add_library(project_warnings INTERFACE)
# standard compiler warnings
include(cmake/CompilerWarnings.cmake)
set_project_warnings(project_warnings)
# allow for static analysis options
include(cmake/StaticAnalyzers.cmake)
# sanitizer options if supported by compiler
include(cmake/Sanitizers.cmake)
enable_sanitizers(project_options)
option(ENABLE_TESTING "Enable tests" ON)
if(ENABLE_TESTING)
enable_testing()
endif()
option(ENABLE_CODE_COVERAGE "Generate coverage data" OFF)
include(cmake/CodeCoverage.cmake)
enable_code_coverage(project_options)
function(add_regular_executable source_file)
get_filename_component(core_name ${source_file} NAME_WLE)
add_executable(${core_name} ${source_file})
target_link_libraries(${core_name}
PRIVATE
project_options
project_warnings)
endfunction()
find_package(Boost 1.66 REQUIRED)
if(NOT Boost_FOUND)
message(
FATAL_ERROR "Fatal error: Boost (version >= 1.66.0) required.\n")
endif()
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
option(ENABLE_BOOST_TESTS "Add boost tests" ON)
if(ENABLE_BOOST_TESTS)
add_subdirectory(tests)
endif()
add_subdirectory(examples)