-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert_default_options.cmake
105 lines (94 loc) · 6.51 KB
/
convert_default_options.cmake
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
include(display_list)
# Sets up the default compiler options, based on a number of defined variables:
# FLAGS_CXX Compiler flags for all platforms, for langurage C++
# FLAGS_CXX_DEBUG Compiler flags for debug build, for langurage C++
# FLAGS_CXX_RELEASE Compiler flags for release build, for langurage C++
# FLAGS_CXX_MINSIZEREL Compiler flags for release min size build, for langurage C++
# FLAGS_CXX_RELWITHDEBINFO Compiler flags for release with debug info build, for langurage C++
# FLAGS_C Compiler flags for all platforms, for langurage C
# FLAGS_C_DEBUG Compiler flags for debug build, for langurage C
# FLAGS_C_RELEASE Compiler flags for release build, for langurage C
# FLAGS_C_MINSIZEREL Compiler flags for release min size build, for langurage C
# FLAGS_C_RELWITHDEBINFO Compiler flags for release with debug info build, for langurage C
# DEFINES Compiler definitions for all platforms, for langurage C and C++
# DEFINES_DEBUG Compiler definitions for debug build, for langurage C and C++
# DEFINES_RELEASE Compiler definitions for release build, for langurage C and C++
# DEFINES_MINSIZEREL Compiler definitions for release min size build, for langurage C and C++
# DEFINES_RELWITHDEBINFO Compiler definitions for release with debug info build, for langurage C and C++
# LINK_FLAGS Linker specific options
# LINK_LIBRARIES Linker libraries to be linked to all targets
#
# The following standard variables are set and placed in the cache (by appending the contents of the mentioned
# lists, and subsequently converting the lists to space separated string):
#
# COMPILER_DEFINITIONS DEFINES
# COMPILER_DEFINITIONS_DEBUG DEFINES DEFINES_DEBUG
# COMPILER_DEFINITIONS_RELEASE DEFINES DEFINES_RELEASE
# COMPILER_DEFINITIONS_MINSIZEREL DEFINES DEFINES_MINSIZEREL
# COMPILER_DEFINITIONS_RELWITHDEBINFO DEFINES DEFINES_RELWITHDEBINFO
# COMPILER_OPTIONS_CXX_FLAGS FLAGS_CXX
# COMPILER_OPTIONS_CXX_FLAGS_DEBUG FLAGS_CXX FLAGS_CXX_DEBUG
# COMPILER_OPTIONS_CXX_FLAGS_RELEASE FLAGS_CXX FLAGS_CXX_RELEASE
# COMPILER_OPTIONS_CXX_FLAGS_MINSIZEREL FLAGS_CXX FLAGS_CXX_MINSIZEREL
# COMPILER_OPTIONS_CXX_FLAGS_RELWITHDEBINFO FLAGS_CXX FLAGS_CXX_RELWITHDEBINFO
# COMPILER_OPTIONS_C_FLAGS FLAGS_C COMPILER_DEFINITIONS
# COMPILER_OPTIONS_C_FLAGS_DEBUG FLAGS_C FLAGS_C_DEBUG
# COMPILER_OPTIONS_C_FLAGS_RELEASE FLAGS_C FLAGS_C_RELEASE
# COMPILER_OPTIONS_C_FLAGS_MINSIZEREL FLAGS_C FLAGS_C_MINSIZEREL
# COMPILER_OPTIONS_C_FLAGS_RELWITHDEBINFO FLAGS_C FLAGS_C_RELWITHDEBINFO
# LINKER_OPTIONS LINK_FLAGS
# LINKER_LIBRARIES LINK_LIBRARIES
macro(convert_default_options)
set(COMPILER_DEFINITIONS_DEBUG ${DEFINES} ${DEFINES_DEBUG})
set(COMPILER_DEFINITIONS_RELEASE ${DEFINES} ${DEFINES_RELEASE})
set(COMPILER_DEFINITIONS_MINSIZEREL ${DEFINES} ${DEFINES_MINSIZEREL})
set(COMPILER_DEFINITIONS_RELWITHDEBINFO ${DEFINES} ${DEFINES_RELWITHDEBINFO})
set(COMPILER_OPTIONS_CXX_DEBUG ${FLAGS_CXX} ${FLAGS_CXX_DEBUG})
set(COMPILER_OPTIONS_CXX_RELEASE ${FLAGS_CXX} ${FLAGS_CXX_RELEASE})
set(COMPILER_OPTIONS_CXX_MINSIZEREL ${FLAGS_CXX} ${FLAGS_CXX_MINSIZEREL})
set(COMPILER_OPTIONS_CXX_RELWITHDEBINFO ${FLAGS_CXX} ${FLAGS_CXX_RELWITHDEBINFO})
set(COMPILER_OPTIONS_C_DEBUG ${FLAGS_C} ${FLAGS_C_DEBUG})
set(COMPILER_OPTIONS_C_RELEASE ${FLAGS_C} ${FLAGS_C_RELEASE})
set(COMPILER_OPTIONS_C_MINSIZEREL ${FLAGS_C} ${FLAGS_C_MINSIZEREL})
set(COMPILER_OPTIONS_C_RELWITHDEBINFO ${FLAGS_C} ${FLAGS_C_RELWITHDEBINFO})
set(LINKER_OPTIONS ${LINK_FLAGS})
set(LINKER_LIBRARIES ${LINK_LIBRARIES})
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(COMPILER_DEFINITIONS ${COMPILER_DEFINITIONS_DEBUG})
set(COMPILER_OPTIONS_CXX ${COMPILER_OPTIONS_CXX_DEBUG})
set(COMPILER_OPTIONS_C ${COMPILER_OPTIONS_C_DEBUG})
elseif(${CMAKE_BUILD_TYPE} STREQUAL "Release")
set(COMPILER_DEFINITIONS ${COMPILER_DEFINITIONS_RELEASE})
set(COMPILER_OPTIONS_CXX ${COMPILER_OPTIONS_CXX_RELEASE})
set(COMPILER_OPTIONS_C ${COMPILER_OPTIONS_CXX_RELEASE})
elseif(${CMAKE_BUILD_TYPE} STREQUAL "MinSizeRel")
set(COMPILER_DEFINITIONS ${COMPILER_DEFINITIONS_MINSIZEREL})
set(COMPILER_OPTIONS_CXX ${COMPILER_OPTIONS_CXX_MINSIZEREL})
set(COMPILER_OPTIONS_C ${COMPILER_OPTIONS_C_MINSIZEREL})
elseif(${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
set(COMPILER_DEFINITIONS ${COMPILER_DEFINITIONS_RELWITHDEBINFO})
set(COMPILER_OPTIONS_CXX ${COMPILER_OPTIONS_CXX_RELWITHDEBINFO})
set(COMPILER_OPTIONS_C ${COMPILER_OPTIONS_C_RELWITHDEBINFO})
else()
message(FATAL_ERROR "Invalid build type: " ${CMAKE_BUILD_TYPE})
endif()
if(CMAKE_VERBOSE_MAKEFILE)
display_list("COMPILER_DEFINITIONS_DEBUG : " ${COMPILER_DEFINITIONS_DEBUG})
display_list("COMPILER_DEFINITIONS_RELEASE : " ${COMPILER_DEFINITIONS_RELEASE})
display_list("COMPILER_DEFINITIONS_MINSIZEREL : " ${COMPILER_DEFINITIONS_MINSIZEREL})
display_list("COMPILER_DEFINITIONS_RELWITHDEBINFO : " ${COMPILER_DEFINITIONS_RELWITHDEBINFO})
display_list("COMPILER_OPTIONS_CXX_DEBUG : " ${COMPILER_OPTIONS_CXX_DEBUG})
display_list("COMPILER_OPTIONS_CXX_RELEASE : " ${COMPILER_OPTIONS_CXX_RELEASE})
display_list("COMPILER_OPTIONS_CXX_MINSIZEREL : " ${COMPILER_OPTIONS_CXX_MINSIZEREL})
display_list("COMPILER_OPTIONS_CXX_RELWITHDEBINFO : " ${COMPILER_OPTIONS_CXX_RELWITHDEBINFO})
display_list("COMPILER_OPTIONS_C_DEBUG : " ${COMPILER_OPTIONS_C_DEBUG})
display_list("COMPILER_OPTIONS_C_RELEASE : " ${COMPILER_OPTIONS_C_RELEASE})
display_list("COMPILER_OPTIONS_C_MINSIZEREL : " ${COMPILER_OPTIONS_C_MINSIZEREL})
display_list("COMPILER_OPTIONS_C_RELWITHDEBINFO : " ${COMPILER_OPTIONS_C_RELWITHDEBINFO})
display_list("Active COMPILER_DEFINITIONS : " ${COMPILER_DEFINITIONS})
display_list("Active COMPILER_OPTIONS_CXX : " ${COMPILER_OPTIONS_CXX})
display_list("Active COMPILER_OPTIONS_C : " ${COMPILER_OPTIONS_C})
display_list("Active LINKER_OPTIONS : " ${LINKER_OPTIONS})
display_list("Active LINKER_LIBRARIES : " ${LINKER_LIBRARIES})
endif()
endmacro()