forked from hikoworks/hikogui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeOverride.txt
More file actions
106 lines (93 loc) · 4.02 KB
/
CMakeOverride.txt
File metadata and controls
106 lines (93 loc) · 4.02 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
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
# By default cmake does not make optimized binaries when building "RelWithDebInfo" using the MSVC compiler.
# It will only make optimized binaries when making a "Release" build, however those don't have debugging symbols.
# Referencing: https://gitlab.kitware.com/cmake/cmake/-/issues/20812
#
# This CMakeOverride.txt will change the default compiler options for the "RelWithDebInfo" to make a fully
# optimized executable like when building with "Release" but with included debugging symbols.
cmake_policy(SET CMP0011 NEW)
cmake_policy(SET CMP0054 NEW)
# log all *_INIT variables
#message("Start *_INIT variables:")
#get_cmake_property(_varNames VARIABLES)
#list (REMOVE_DUPLICATES _varNames)
#list (SORT _varNames)
#foreach (_varName ${_varNames})
# if (_varName MATCHES "_INIT$")
# message(STATUS "${_varName}=${${_varName}}")
# endif()
#endforeach()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
#
# RelWithDebugInfo
#
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-Zi -O2 -Ob2 -DNDEBUG -stdlib=libc++")
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-Zi -O2 -Ob2 -DNDEBUG -stdlib=libc++")
#set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "-INCREMENTAL:NO -debug")
#set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT "-INCREMENTAL:NO -debug")
#set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT "-INCREMENTAL:NO -debug")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
# using Intel C++
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# using Visual Studio C++
#
# Settings for ALL build types
#
# -GR: Add type information in executable needed for dynamic_cast<>() to work.
# -EHsc: Uses the standard C++ exception handling, i.e. catch(...) does not catch
# Window's structured exceptions such as segmentation-faults.
#
set(CMAKE_C_FLAGS_INIT "-DWIN32 -D_WINDOWS -nologo")
set(CMAKE_CXX_FLAGS_INIT "-DWIN32 -D_WINDOWS -GR -EHsc -nologo")
set(CMAKE_EXE_LINKER_FLAGS_INIT "-machine:x64 -nologo")
set(CMAKE_MODULE_LINKER_FLAGS_INIT "-machine:x64 -nologo")
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-machine:x64 -nologo")
set(CMAKE_STATIC_LINKER_FLAGS_INIT "-machine:x64 -nologo")
#
# Debug
#
# Zi: Produce a separate PDB file (debug symbols)
# Ob0: Disable inline expansions
# Od: Disable code movements for easier debugging (DEBUG)
#
# -debug:fastlink causes "Access Violation" on github-actions.
#
set(CMAKE_CXX_FLAGS_DEBUG_INIT "-Zi -Ob0 -Od")
set(CMAKE_C_FLAGS_DEBUG_INIT "-Zi -Ob0 -Od")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "-debug")
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG_INIT "-debug")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT "-debug")
#
# RelWithDebugInfo
#
# This build_type is important, because we need to step through the
# assembly of the optimized release build, while having debug information.
#
# Zi: Produce a separate PDB file (debug symbols)
# O2: Maximize Speed
# Ob3: Aggressive Inline Function Expansion
# NDEBUG: Assertion checks turned off at compile time
#
# -debug:fastlink causes "Access Violation" on github-actions.
#
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-Zi -O2 -Ob3 -DNDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-Zi -O2 -Ob3 -DNDEBUG")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "-debug")
set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT "-debug")
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT "-debug")
#
# Release
#
# O2: Maximize Speed
# Ob3: Aggressive Inline Function Expansion
# NDEBUG: Assertion checks turned off at compile time
#
# -debug:fastlink causes "Access Violation" on github-actions.
#
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-O2 -Ob3 -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE_INIT "-O2 -Ob3 -DNDEBUG")
#set(CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT "-INCREMENTAL:NO")
#set(CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT "-INCREMENTAL:NO")
#set(CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT "-INCREMENTAL:NO")
endif()