From 0296e2df37baef8f042317e41cbf3dda74dcd700 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Tue, 13 Jul 2021 11:05:52 +1000 Subject: [PATCH] CMake: Handle single- and multi-config differences more robustly Projects sometimes set both CMAKE_CONFIGURATION_TYPES and CMAKE_BUILD_TYPE regardless of what CMake generator they are using. They shouldn't, but it is common enough that we should protect against it. The GENERATOR_IS_MULTI_CONFIG global property is the only robust way to know which type of generator we are using, so switch to that for how we detect this. Change-Id: If5d6568da0d2adb3275bbaf9a7d3bd3e033dc636 Reviewed-by: Alexandru Croitor (cherry picked from commit b30ac93a3737628da118f2137d96c7773ea9e239) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/Qt6CoreMacros.cmake | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 370e703a4d9..9d3e2a646bf 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -970,16 +970,17 @@ function(qt6_extract_metatypes target) AUTOMOC_MOC_OPTIONS "--output-json" ) - if(NOT CMAKE_CONFIGURATION_TYPES) + get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(NOT is_multi_config) set(cmake_autogen_cache_file "${target_binary_dir}/CMakeFiles/${target}_autogen.dir/ParseCache.txt") - set(mutli_config_args + set(multi_config_args --cmake-autogen-include-dir-path "${target_binary_dir}/${target}_autogen/include" ) else() set(cmake_autogen_cache_file "${target_binary_dir}/CMakeFiles/${target}_autogen.dir/ParseCache_$.txt") - set(mutli_config_args + set(multi_config_args --cmake-autogen-include-dir-path "${target_binary_dir}/${target}_autogen/include_$" "--cmake-multi-config") endif() @@ -1029,7 +1030,7 @@ function(qt6_extract_metatypes target) --cmake-autogen-cache-file "${cmake_autogen_cache_file}" --cmake-autogen-info-file "${cmake_autogen_info_file}" --output-file-path "${type_list_file}" - ${mutli_config_args} + ${multi_config_args} COMMENT "Running AUTOMOC file extraction for target ${target}" COMMAND_EXPAND_LISTS ) @@ -1047,7 +1048,7 @@ function(qt6_extract_metatypes target) --cmake-autogen-cache-file "${cmake_autogen_cache_file}" --cmake-autogen-info-file "${cmake_autogen_info_file}" --output-file-path "${type_list_file}" - ${mutli_config_args} + ${multi_config_args} COMMENT "Running AUTOMOC file extraction for target ${target}" COMMAND_EXPAND_LISTS ) @@ -1073,7 +1074,7 @@ function(qt6_extract_metatypes target) message(FATAL_ERROR "Metatype generation requires either the use of AUTOMOC or a manual list of generated json files") endif() - if (CMAKE_BUILD_TYPE) + if (CMAKE_BUILD_TYPE AND NOT is_multi_config) string(TOLOWER ${target}_${CMAKE_BUILD_TYPE} target_lowercase) else() string(TOLOWER ${target} target_lowercase)