From c561bcceed0300a14e2062958afce62776be4b6f Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 4 Jun 2024 15:06:37 +0200 Subject: [PATCH] CMake: Fix framework headers not being copied after rm-ing build dir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a build dir is removed using rm -r *, this still leaves dot files around, specifically the .ninja_log file. Because of a possibly unspecified behavior of listing directories as OUTPUTs in a add_custom_command call for the ${target}_copy_fw_sync_headers custom target, we end up with a situation where the custom command is not rerun by ninja because the directory OUTPUT was encountered in the .ninja_log file. Make sure to specify an additional file as an OUTPUT, to ensure the command does rerun, and thus copies all headers from the syncqt staging directory. Amends 103eca1070a75bfa97d0b72b94e0c759ef0bcd1c Pick-to: 6.5 6.7 6.8 Fixes: QTBUG-126056 Change-Id: I5664cf074158199e0c7fd5e312ecf739133d7f2e Reviewed-by: Tor Arne Vestbø --- cmake/QtFrameworkHelpers.cmake | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cmake/QtFrameworkHelpers.cmake b/cmake/QtFrameworkHelpers.cmake index 71227a0ea8c..0a37573ff6d 100644 --- a/cmake/QtFrameworkHelpers.cmake +++ b/cmake/QtFrameworkHelpers.cmake @@ -117,18 +117,31 @@ function(qt_copy_framework_headers target) "${output_dir}/${fw_versioned_header_dir}" ) + set(copy_fw_sync_headers_marker_file + "${CMAKE_CURRENT_BINARY_DIR}/${target}_fw_sync_headers_marker_file" + ) + + set(copy_fw_sync_headers_marker_file_command + "${CMAKE_COMMAND}" -E touch "${copy_fw_sync_headers_marker_file}" + ) + if(CMAKE_GENERATOR MATCHES "^Ninja") add_custom_command( - OUTPUT "${output_dir}/${fw_versioned_header_dir}" + OUTPUT + "${output_dir}/${fw_versioned_header_dir}" + "${copy_fw_sync_headers_marker_file}" DEPENDS ${target}_sync_headers COMMAND ${copy_fw_sync_headers_command} + COMMAND ${copy_fw_sync_headers_marker_file_command} VERBATIM ) add_custom_target(${target}_copy_fw_sync_headers DEPENDS "${output_dir}/${fw_versioned_header_dir}") else() add_custom_target(${target}_copy_fw_sync_headers - COMMAND ${copy_fw_sync_headers_command}) + COMMAND ${copy_fw_sync_headers_command} + COMMAND ${copy_fw_sync_headers_marker_file_command} + ) endif() if(out_files)