-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
56 lines (54 loc) · 1.65 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
cmake_minimum_required(VERSION 3.25)
project(include2import)
if(CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
message(FATAL_ERROR "In-source build is unsupported")
endif()
# Setup the 3rdParty folder
execute_process(
WORKING_DIRECTORY ../3rdParty
COMMAND ${CMAKE_COMMAND} -P Setup.cmake
)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-fno-omit-frame-pointer" OFP)
if(OFP)
add_compile_options(-fno-omit-frame-pointer)
add_link_options(-fno-omit-frame-pointer)
endif()
# Also needs to be a link flag for test to pass
set(CMAKE_REQUIRED_LINK_OPTIONS -fsanitize=address)
check_cxx_compiler_flag("-fsanitize=address" ASAN)
if(ASAN)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()
unset(CMAKE_REQUIRED_LINK_OPTIONS)
check_cxx_compiler_flag("-fsanitize=undefined" UBSAN)
if(UBSAN)
add_compile_options(-fsanitize=undefined)
add_link_options(-fsanitize=undefined)
endif()
check_cxx_compiler_flag("-fsanitize=leak" LSAN)
if(LSAN)
add_compile_options(-fsanitize=leak)
add_link_options(-fsanitize=leak)
endif()
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO)
if(IPO)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
endif()
endif()
set(BUILD_SHARED_LIBS OFF)
add_compile_options(-Wall)
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_subdirectory(src)
option(BUILD_TESTS "Build and run tests" OFF)
if(${BUILD_TESTS})
add_subdirectory(test)
endif()