@@ -33,16 +33,16 @@ macro(parse_target)
33
33
if (${cur_component} STREQUAL gcc)
34
34
if (DEFINED ENV{GNU_CC})
35
35
set (CMAKE_C_COMPILER $ENV{GNU_CC} )
36
- elseif ($ENV{CXX } MATCHES .*gcc.*)
37
- set (CMAKE_CXX_COMPILER $ENV{CC} )
36
+ elseif ($ENV{CC } MATCHES .*gcc.*)
37
+ set (CMAKE_C_COMPILER $ENV{CC} )
38
38
else ()
39
39
find_program (CMAKE_C_COMPILER gcc)
40
40
endif ()
41
41
42
42
if (DEFINED ENV{GNU_CXX})
43
- set (CMAKE_C_COMPILER $ENV{GNU_CXX} )
43
+ set (CMAKE_CXX_COMPILER $ENV{GNU_CXX} )
44
44
elseif ($ENV{CXX} MATCHES .*g\\+\\+.*)
45
- set (CMAKE_C_COMPILER $ENV{CC } )
45
+ set (CMAKE_CXX_COMPILER $ENV{CXX } )
46
46
else ()
47
47
find_program (CMAKE_CXX_COMPILER g++)
48
48
endif ()
@@ -51,16 +51,16 @@ macro(parse_target)
51
51
if (${cur_component} STREQUAL clang)
52
52
if (DEFINED ENV{CLANG_CC})
53
53
set (CMAKE_C_COMPILER $ENV{CLANG_CC} )
54
- elseif ($ENV{CXX } MATCHES .*clang.*)
55
- set (CMAKE_CXX_COMPILER $ENV{CC} )
54
+ elseif ($ENV{CC } MATCHES .*clang.*)
55
+ set (CMAKE_C_COMPILER $ENV{CC} )
56
56
else ()
57
57
find_program (CMAKE_C_COMPILER clang)
58
58
endif ()
59
59
60
60
if (DEFINED ENV{CLANG_CXX})
61
- set (CMAKE_C_COMPILER $ENV{CLANG_CXX} )
61
+ set (CMAKE_CXX_COMPILER $ENV{CLANG_CXX} )
62
62
elseif ($ENV{CXX} MATCHES .*clang.*)
63
- set (CMAKE_C_COMPILER $ENV{CC } )
63
+ set (CMAKE_CXX_COMPILER $ENV{CXX } )
64
64
else ()
65
65
find_program (CMAKE_CXX_COMPILER clang++)
66
66
endif ()
@@ -105,16 +105,40 @@ macro(parse_target)
105
105
endif ()
106
106
107
107
endwhile ()
108
+ # Promote these values to the CACHE, then unset the locals
109
+ # to prevent shadowing.
110
+ set (CMAKE_C_COMPILER ${CMAKE_C_COMPILER} CACHE FILEPATH
111
+ "Path to a program" FORCE)
112
+ unset (CMAKE_C_COMPILER)
113
+ set (CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE FILEPATH
114
+ "Path to a program" FORCE)
115
+ unset (CMAKE_CXX_COMPILER)
108
116
109
117
if (release)
110
118
set (CMAKE_BUILD_TYPE Release)
111
119
else ()
112
120
set (CMAKE_BUILD_TYPE Debug)
113
121
endif ()
114
122
123
+ # ensure that the unity flags are set and exclusive
124
+ if (NOT DEFINED unity OR unity)
125
+ # Default to unity builds
126
+ set (unity true )
127
+ set (nonunity false )
128
+ else ()
129
+ set (unity false )
130
+ set (nonunity true )
131
+ endif ()
132
+
115
133
if (NOT unity)
116
134
set (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} Classic)
117
135
endif ()
136
+ # Promote this value to the CACHE, then unset the local
137
+ # to prevent shadowing.
138
+ set (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE INTERNAL
139
+ "Choose the type of build, options are in CMAKE_CONFIGURATION_TYPES"
140
+ FORCE)
141
+ unset (CMAKE_BUILD_TYPE )
118
142
endif ()
119
143
120
144
endmacro ()
@@ -149,8 +173,11 @@ macro(setup_build_cache)
149
173
ReleaseClassic)
150
174
endif ()
151
175
176
+ # Promote this value to the CACHE, then unset the local
177
+ # to prevent shadowing.
152
178
set (CMAKE_CONFIGURATION_TYPES
153
179
${CMAKE_CONFIGURATION_TYPES} CACHE STRING "" FORCE)
180
+ unset (CMAKE_CONFIGURATION_TYPES )
154
181
endmacro ()
155
182
156
183
############################################################
0 commit comments