-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommonProjectOptions.cmake
More file actions
70 lines (63 loc) · 2.08 KB
/
CommonProjectOptions.cmake
File metadata and controls
70 lines (63 loc) · 2.08 KB
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
add_library(CommonProjectOptions INTERFACE)
# === BUILD TYPE ===
set_property(CACHE CMAKE_BUILD_TYPE
PROPERTY STRINGS "Debug"
"Release"
"RelWithDebInfo")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
log_war("No build type specified, setting to RelWithDebInfo")
set(CMAKE_BUILD_TYPE
RelWithDebInfo
CACHE STRING "Type of build" FORCE)
else()
log_info("Build type: ${CMAKE_BUILD_TYPE}")
endif()
set(BUILD_SHARED_LIBS OFF)
# === CCACHE ===
option(TACHYON_OPTIONS_ENABLE_CCACHE
"Enable ccache"
FALSE)
if(TACHYON_OPTIONS_ENABLE_CCACHE)
find_program(PATH_CCACHE ccache)
if(PATH_CCACHE)
log_option_enabled("ccache")
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE})
else()
log_option_disabled("ccache")
endif()
endif()
# === LTO ===
option(TACHYON_OPTIONS_ENABLE_LTO
"Enable link-time optimization"
TRUE)
if(TACHYON_OPTIONS_ENABLE_LTO)
include(CheckIPOSupported)
check_ipo_supported(RESULT result OUTPUT output)
if(result)
set_property(TARGET CommonProjectOptions PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
log_err("LTO is not supported: ${output}")
endif()
endif()
# === PCH ===
option(TACHYON_OPTIONS_ENABLE_PCH
"Enable precompiled header"
TRUE)
if(TACHYON_OPTIONS_ENABLE_PCH)
log_option_enabled("precompiled header")
target_precompile_headers(CommonProjectOptions INTERFACE <memory>
<string>
<vector>
<cassert>
<cstdint>)
else()
log_option_disabled("precompiled header")
endif()
# === Misc ===
option(TACHYON_OPTIONS_BUILD_TESTING "Enable Tachyon tests" FALSE)
if(TACHYON_OPTIONS_BUILD_TESTING)
log_option_enabled("building tests")
else()
log_option_disabled("building tests")
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)