-
Notifications
You must be signed in to change notification settings - Fork 21
/
CMakeLists.txt
119 lines (96 loc) · 4.31 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
cmake_minimum_required(VERSION 3.13)
project(HomeStore)
option(DEBUG_CMAKE "Debug CMake messages option" OFF)
# Set Global CMake Options
set_property(GLOBAL PROPERTY USE_FOLDERS ON) # turn on folder hierarchies
include (cmake/Flags.cmake)
set(CMAKE_CXX_STANDARD 20)
enable_testing()
include (cmake/test_mode.cmake)
if (DEFINED BUILD_COVERAGE)
if (${BUILD_COVERAGE})
include (cmake/CodeCoverage.cmake)
APPEND_COVERAGE_COMPILER_FLAGS()
SETUP_TARGET_FOR_COVERAGE_GCOVR_XML(NAME coverage EXECUTABLE ctest DEPENDENCIES )
endif ()
endif ()
set(ASAN_ENABLED_BUILD false)
if ($ENV{ASAN_OPTIONS} MATCHES "detect_leaks=1")
message(STATUS "Running with ASAN leak detection ON")
set(ASAN_ENABLED_BUILD true)
endif()
if (DEFINED MEMORY_SANITIZER_ON)
if (${MEMORY_SANITIZER_ON})
message(STATUS "Build with Memory Sanitizer ON")
include (cmake/mem_sanitizer.cmake)
else ()
message(STATUS "Build with Memory Sanitizer OFF")
endif()
else ()
message(STATUS "Build with Memory Sanitizer OFF")
endif ()
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
if (NOT ${ASAN_ENABLED_BUILD})
message(STATUS "********* WARNING: Running with ASAN leak detection OFF for debug build *********")
message(STATUS "If not desired, set the env variable as follows and rerun the build")
message(STATUS "'ASAN_OPTIONS=detect_leaks=1:abort_on_error=1:disable_coredump=0::unmap_shadow_on_exit=1'")
endif()
endif()
find_package(sisl REQUIRED)
list(GET sisl_INCLUDE_DIRS 0 SISL_TOP_INCLUDE)
include ("${SISL_TOP_INCLUDE}/../cmake/settings_gen.cmake")
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif ()
if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))
# add linux options
add_flags("-Dlinux")
# add compiler options
add_flags("-faligned-new -fconcepts" Languages "CXX")
# add warning options
add_flags("-Wall -Wextra -Werror")
add_flags("-Wno-empty-body -Wno-array-bounds -Wno-cast-function-type")
add_flags("-Wno-unused-parameter -Wno-unused-variable -Wno-maybe-uninitialized -Wno-unused-function")
# add C++ only warning options
add_flags("-Wno-deprecated-copy" Languages "CXX")
# Allow deprecated C++
add_flags("-fpermissive")
endif()
# add boost options
add_flags("-DBOOST_ALLOW_DEPRECATED_HEADERS")
# add version information
set(PACKAGE_REVISION "0.0.0+unknown")
if (DEFINED CONAN_PACKAGE_NAME)
set(PACKAGE_REVISION "${CONAN_PACKAGE_VERSION}")
endif ()
add_flags("-DPACKAGE_NAME=\\\"${PROJECT_NAME}\\\"")
add_flags("-DPACKAGE_VERSION=\\\"${PACKAGE_REVISION}\\\"")
if(UNIX)
# enable proper pread/pwrite and large file
add_flags("-D_POSIX_C_SOURCE=200809L -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
endif()
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
message(STATUS "Debug build")
add_flags("-DDEBUG_RCU -D_DEBUG")
else()
message(STATUS "Release build")
if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))
remove_flag("-O[0-4]")
add_flags("-O2")
endif()
endif()
add_flags("-g")
add_subdirectory(src)
# build info
string(TOUPPER "${CMAKE_BUILD_TYPE}" UC_CMAKE_BUILD_TYPE)
message(STATUS "Build configuration: ${CMAKE_BUILD_TYPE}")
message(STATUS "C compiler info: ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION} ${CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN}")
message(STATUS "C++ compiler info: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} ${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}")
message(STATUS "C flags: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${UC_CMAKE_BUILD_TYPE}}")
message(STATUS "C++ flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UC_CMAKE_BUILD_TYPE}}")
message(STATUS "Linker flags (executable): ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${UC_CMAKE_BUILD_TYPE}}")
message(STATUS "Linker flags (shared): ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_${UC_CMAKE_BUILD_TYPE}}")
message(STATUS "Linker flags (module): ${CMAKE_MODULE_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS_${UC_CMAKE_BUILD_TYPE}}")
message(STATUS "Linker flags (static): ${CMAKE_STATIC_LINKER_FLAGS} ${CMAKE_STATIC_LINKER_FLAGS_${UC_CMAKE_BUILD_TYPE}}")