Skip to content

Commit 158f9e5

Browse files
committed
cmake: Do not modify build types when integrating by downstream project
The `CMAKE_BUILD_TYPE` and `CMAKE_CONFIGURATION_TYPES` variables must be managed by the downstream project. Suggesting to review with `git diff -w`.
1 parent 35c0fdc commit 158f9e5

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

CMakeLists.txt

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -213,23 +213,25 @@ mark_as_advanced(
213213
CMAKE_SHARED_LINKER_FLAGS_COVERAGE
214214
)
215215

216-
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
217-
set(default_build_type "RelWithDebInfo")
218-
if(is_multi_config)
219-
set(CMAKE_CONFIGURATION_TYPES "${default_build_type}" "Release" "Debug" "MinSizeRel" "Coverage" CACHE STRING
220-
"Supported configuration types."
221-
FORCE
222-
)
223-
else()
224-
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
225-
STRINGS "${default_build_type}" "Release" "Debug" "MinSizeRel" "Coverage"
226-
)
227-
if(NOT CMAKE_BUILD_TYPE)
228-
message(STATUS "Setting build type to \"${default_build_type}\" as none was specified")
229-
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING
230-
"Choose the type of build."
216+
if(PROJECT_IS_TOP_LEVEL)
217+
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
218+
set(default_build_type "RelWithDebInfo")
219+
if(is_multi_config)
220+
set(CMAKE_CONFIGURATION_TYPES "${default_build_type}" "Release" "Debug" "MinSizeRel" "Coverage" CACHE STRING
221+
"Supported configuration types."
231222
FORCE
232223
)
224+
else()
225+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
226+
STRINGS "${default_build_type}" "Release" "Debug" "MinSizeRel" "Coverage"
227+
)
228+
if(NOT CMAKE_BUILD_TYPE)
229+
message(STATUS "Setting build type to \"${default_build_type}\" as none was specified")
230+
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING
231+
"Choose the type of build."
232+
FORCE
233+
)
234+
endif()
233235
endif()
234236
endif()
235237

0 commit comments

Comments
 (0)