From ba2ab5fa432a19fdb8d051e5fa4057d7156401f4 Mon Sep 17 00:00:00 2001 From: Orkun Tokdemir Date: Mon, 23 Oct 2023 18:52:56 +0200 Subject: [PATCH] CMake: Set AUTOGEN_BETTER_GRAPH_MULTI_CONFIG Since https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8919 is merged, `qtbase` should be updated accordingly. If `CMake` is equal or greater than `3.29`. `timestamp_$` is used instead of `timestamp`. This commit reimplements 8041bfba47305352627d910930e52da496904c17 which is reverted with 4b1d96ea1b16e3eef2222de78677a4d99a87940f Change-Id: I335e3855c1a11c404202ae7b74f0c356b8fe53bd Reviewed-by: Alexandru Croitor Reviewed-by: Leena Miettinen --- src/corelib/Qt6CoreMacros.cmake | 15 +++++++++--- .../src/cmake/cmake-standard-properties.qdoc | 24 +++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 src/corelib/doc/src/cmake/cmake-standard-properties.qdoc diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index ebd94dd82ae..4b96776760d 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -1238,9 +1238,18 @@ function(qt6_extract_metatypes target) add_dependencies(${target}_automoc_json_extraction ${target}_autogen) _qt_internal_assign_to_internal_targets_folder(${target}_automoc_json_extraction) else() - set(cmake_autogen_timestamp_file - "${target_autogen_build_dir}/timestamp" - ) + set(timestamp_file "${target_autogen_build_dir}/timestamp") + set(timestamp_file_with_config "${timestamp_file}_$") + if (is_multi_config AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.29" + AND NOT QT_INTERNAL_USE_OLD_AUTOGEN_GRAPH_MULTI_CONFIG_METATYPES) + string(JOIN "" timestamp_genex + "$>," + "${timestamp_file_with_config},${timestamp_file}>") + set(cmake_autogen_timestamp_file "${timestamp_genex}") + else() + set(cmake_autogen_timestamp_file ${timestamp_file}) + endif() add_custom_command(OUTPUT ${type_list_file} DEPENDS ${QT_CMAKE_EXPORT_NAMESPACE}::cmake_automoc_parser diff --git a/src/corelib/doc/src/cmake/cmake-standard-properties.qdoc b/src/corelib/doc/src/cmake/cmake-standard-properties.qdoc new file mode 100644 index 00000000000..a8ece6ba8f3 --- /dev/null +++ b/src/corelib/doc/src/cmake/cmake-standard-properties.qdoc @@ -0,0 +1,24 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only + +/*! +\page cmake-standard-property-autogen-better-graph-multi-config.html +\ingroup cmake-standard-properties + +\title AUTOGEN_BETTER_GRAPH_MULTI_CONFIG + +\brief Improves the dependency graph for multi-configuration generators when you +set it on a target. + +When this boolean property is enabled, \c{CMake} will generate more per-config targets. +Thus, the dependency graph will be more accurate for multi-configuration +generators and some recompilations will be avoided. + +Since Qt 6.8, this property is enabled by default. For older versions, +you need to enable it manually to use it. +However, \l{qt_extract_metatypes} and \l{qt_add_qml_module} were updated to +support \c{AUTOGEN_BETTER_GRAPH_MULTI_CONFIG} in Qt 6.8, so you will get build +errors, unless you patch the older Qt version to support it. + +See \l{https://cmake.org/cmake/help/latest/prop_tgt/AUTOGEN_BETTER_GRAPH_MULTI_CONFIG.html}{AUTOGEN_BETTER_GRAPH_MULTI_CONFIG} for more information. +*/