summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-12-06 15:12:17 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-01-27 11:47:57 +0000
commitc9bea1ad62addb7582ddf0e8d790719c96a0ea90 (patch)
treee2f9c807399606e839c76504be8617fee18dfc20 /src/corelib
parentcce8ada8141d786c1deda78fdba485b4c67f9687 (diff)
Add initial support for CMake "Ninja Multi-Config" generator
This allows doing debug_and_release builds with Ninja on all platforms. The "Ninja Multi-Config generator" is available starting with CMake 3.17. Desired configurations can be set via CMAKE_CONFIGURATION_TYPES. Possible values: "Release, Debug, RelWithDebInfo, MinRelSize". For example -DCMAKE_CONFIGURATION_TYPES="Release;Debug". The first configuration is the 'default' configuration which is built when calling ninja with no arguments. To build all targets of a certain configuration use "ninja all:Release" or "ninja all:Debug". To build all targets in all configurations use "ninja all:all". Note that the first configuration influences which configuration of tools will be used when building the libraries for all configurations. In simple terms, when configured with -DCMAKE_CONFIGURATION_TYPES="Release;Debug" the release version of moc is used by AUTOMOC. When configured with -DCMAKE_CONFIGURATION_TYPES="Debug;Release" the debug version of moc is used by AUTOMOC. Framework builds and Ninja Multi-Config don't currently work together due to multiple bugs in CMake, which ends up generating an invalid ninja file with duplicate rules. There are also issues with placement of the debug artifacts. This will be handled in a follow up patch after CMake is fixed. Task-number: QTBUG-76899 Change-Id: If224adc0b71b7d1d6606738101536146aa866cd7 Reviewed-by: Qt CMake Build Bot Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/Qt6CoreMacros.cmake21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index da0b4641ae..cf860cd9ad 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -543,8 +543,20 @@ function(qt6_generate_meta_types_json_file target)
get_target_property(target_binary_dir ${target} BINARY_DIR)
- set(cmake_autogen_cache_file
- "${target_binary_dir}/CMakeFiles/${target}_autogen.dir/ParseCache.txt")
+ if(CMAKE_BUILD_TYPE)
+ set(cmake_autogen_cache_file
+ "${target_binary_dir}/CMakeFiles/${target}_autogen.dir/ParseCache.txt")
+ set(mutli_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_$<CONFIG>.txt")
+ set(mutli_config_args
+ --cmake-autogen-include-dir-path "${target_binary_dir}/${target}_autogen/include_$<CONFIG>"
+ "--cmake-multi-config")
+ endif()
+
set(cmake_autogen_info_file
"${target_binary_dir}/CMakeFiles/${target}_autogen.dir/AutogenInfo.json")
set(type_list_file "${target_binary_dir}/meta_types/json_file_list.txt")
@@ -556,8 +568,9 @@ function(qt6_generate_meta_types_json_file target)
--cmake-autogen-cache-file "${cmake_autogen_cache_file}"
--cmake-autogen-info-file "${cmake_autogen_info_file}"
--output-file-path "${type_list_file}"
- --cmake-autogen-include-dir-path "${target_binary_dir}/${target}_autogen/include"
+ ${mutli_config_args}
COMMENT "Running Automoc file extraction"
+ COMMAND_EXPAND_LISTS
)
add_dependencies(${target}_automoc_json_extraction ${target}_autogen)
@@ -565,7 +578,7 @@ function(qt6_generate_meta_types_json_file target)
if (CMAKE_BUILD_TYPE)
string(TOLOWER ${target}_${CMAKE_BUILD_TYPE} target_lowercase)
else()
- message(FATAL_ERROR "add_custom_command's OUTPUT parameter does not support generator expressions, so we can't generate this file for multi-config generators")
+ string(TOLOWER ${target} target_lowercase)
endif()
set(metatypes_file "${target_binary_dir}/meta_types/qt6${target_lowercase}_metatypes.json")
add_custom_command(OUTPUT ${metatypes_file}