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`.
This commit is contained in:
Hennadii Stepanov
2024-06-18 15:44:15 +01:00
parent 35c0fdc86b
commit 158f9e5eae

View File

@@ -213,14 +213,15 @@ mark_as_advanced(
CMAKE_SHARED_LINKER_FLAGS_COVERAGE CMAKE_SHARED_LINKER_FLAGS_COVERAGE
) )
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(PROJECT_IS_TOP_LEVEL)
set(default_build_type "RelWithDebInfo") get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(is_multi_config) set(default_build_type "RelWithDebInfo")
if(is_multi_config)
set(CMAKE_CONFIGURATION_TYPES "${default_build_type}" "Release" "Debug" "MinSizeRel" "Coverage" CACHE STRING set(CMAKE_CONFIGURATION_TYPES "${default_build_type}" "Release" "Debug" "MinSizeRel" "Coverage" CACHE STRING
"Supported configuration types." "Supported configuration types."
FORCE FORCE
) )
else() else()
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
STRINGS "${default_build_type}" "Release" "Debug" "MinSizeRel" "Coverage" STRINGS "${default_build_type}" "Release" "Debug" "MinSizeRel" "Coverage"
) )
@@ -231,6 +232,7 @@ else()
FORCE FORCE
) )
endif() endif()
endif()
endif() endif()
include(TryAppendCFlags) include(TryAppendCFlags)