From 33f5e985e480283bb0ca9dea5f82643e825ba87c Mon Sep 17 00:00:00 2001 From: Orkun Tokdemir Date: Wed, 13 Sep 2023 18:02:48 +0200 Subject: [PATCH] CMake: Update timestamp file for `Cross-Config` builds Since https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8564 is merged, the timestamp file for {target}_json_file.txt should be updated for `Cross-Config` builds. The actual error message before this commit when CMake 3.28 is used: ``` ninja: error: 'src/corelib/Core_autogen/timestamp', needed by 'src/corelib/meta_types/Core_json_file_list.txt', missing and no known rule to make it ``` Change-Id: Ib544b18b67d2d4722f3801b1f46a0e0e18e59d48 Reviewed-by: Amir Masoud Abdol Reviewed-by: Alexandru Croitor (cherry picked from commit 8041bfba47305352627d910930e52da496904c17) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 5c9e77298583d9955c139765783e403314799f42) --- src/corelib/Qt6CoreMacros.cmake | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 5bc313a276d..349bb4b4190 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -1061,9 +1061,23 @@ 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(use_better_automoc_graph FALSE) + if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.28.0" + AND CMAKE_CROSS_CONFIGS) + if(DEFINED QT_USE_BETTER_AUTOMOC_GRAPH) + set(use_better_automoc_graph ${QT_USE_BETTER_AUTOMOC_GRAPH}) + else() + set(use_better_automoc_graph TRUE) + endif() + endif() + + if(use_better_automoc_graph) + set(cmake_autogen_timestamp_file + "${target_autogen_build_dir}/timestamp_$") + else() + set(cmake_autogen_timestamp_file + "${target_autogen_build_dir}/timestamp") + endif() add_custom_command(OUTPUT ${type_list_file} DEPENDS ${QT_CMAKE_EXPORT_NAMESPACE}::cmake_automoc_parser