diff options
author | Leander Beernaert <leander.beernaert@qt.io> | 2020-03-04 15:58:59 +0100 |
---|---|---|
committer | Leander Beernaert <leander.beernaert@qt.io> | 2020-03-05 16:14:35 +0100 |
commit | 73301b252a3486098d1e8d0dd4e36462d9ab5885 (patch) | |
tree | ffdb7c68f99b860c7b84dc011cb60219d228940b /src/corelib | |
parent | fda03bfed09821f508ff8ec7ebbd411b0a42e4bc (diff) |
CMake: Depend on automoc timestamp for metatypes extraction
When using CMake 3.17 with any of the Ninja generators we can leverage
a dependency on the timestamp file produced by CMake's automoc to avoid
having a custom target run on every build.
Change-Id: Ia70d2730cc8296d0a43642655fe69b555cb393c0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/Qt6CoreMacros.cmake | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index c478c9e5f5..4940eaa44d 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -683,19 +683,46 @@ function(qt6_generate_meta_types_json_file target) set(cmake_autogen_info_file "${target_binary_dir}/CMakeFiles/${target}_autogen.dir/AutogenInfo.json") - add_custom_target(${target}_automoc_json_extraction - DEPENDS ${QT_CMAKE_EXPORT_NAMESPACE}::cmake_automoc_parser - BYPRODUCTS ${type_list_file} - COMMAND - ${QT_CMAKE_EXPORT_NAMESPACE}::cmake_automoc_parser - --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} - COMMENT "Running Automoc file extraction" - COMMAND_EXPAND_LISTS - ) - add_dependencies(${target}_automoc_json_extraction ${target}_autogen) + set (use_dep_files FALSE) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.17") # Requires automoc changes present only in 3.17 + if(CMAKE_GENERATOR STREQUAL "Ninja" OR CMAKE_GENERATOR STREQUAL "Ninja Multi-Config") + set(use_dep_files TRUE) + endif() + endif() + + if (NOT use_dep_files) + add_custom_target(${target}_automoc_json_extraction + DEPENDS ${QT_CMAKE_EXPORT_NAMESPACE}::cmake_automoc_parser + BYPRODUCTS ${type_list_file} + COMMAND + ${QT_CMAKE_EXPORT_NAMESPACE}::cmake_automoc_parser + --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} + COMMENT "Running Automoc file extraction" + COMMAND_EXPAND_LISTS + ) + add_dependencies(${target}_automoc_json_extraction ${target}_autogen) + else() + set(cmake_autogen_timestamp_file + "${target_binary_dir}/${target}_autogen/timestamp" + ) + + add_custom_command(OUTPUT ${type_list_file} + DEPENDS ${QT_CMAKE_EXPORT_NAMESPACE}::cmake_automoc_parser + ${cmake_autogen_timestamp_file} + COMMAND + ${QT_CMAKE_EXPORT_NAMESPACE}::cmake_automoc_parser + --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} + COMMENT "Running Automoc file extraction" + COMMAND_EXPAND_LISTS + ) + + endif() set(automoc_args "@${type_list_file}") set(automoc_dependencies "${type_list_file}") endif() |