diff --git a/cmake/QtFrameworkHelpers.cmake b/cmake/QtFrameworkHelpers.cmake index c15f74e5422..338febbb8c0 100644 --- a/cmake/QtFrameworkHelpers.cmake +++ b/cmake/QtFrameworkHelpers.cmake @@ -88,10 +88,12 @@ function(qt_copy_framework_headers target) set(out_files "") set(in_files "") + set(out_dirs "") set(copy_commands "") foreach(type IN ITEMS PUBLIC PRIVATE QPA RHI SSG) set(in_files_${type} "") set(fw_output_header_dir "${output_dir_${type}}") + list(APPEND out_dirs "${fw_output_header_dir}") foreach(hdr IN LISTS arg_${type}) get_filename_component(in_file_path ${hdr} ABSOLUTE) get_filename_component(in_file_name ${hdr} NAME) @@ -108,13 +110,32 @@ function(qt_copy_framework_headers target) list(REMOVE_DUPLICATES out_files) list(REMOVE_DUPLICATES in_files) + + set(copy_fw_sync_headers_command + "${CMAKE_COMMAND}" -E copy_directory + "${module_build_interface_include_dir}/.syncqt_staging" + "${output_dir}/${fw_versioned_header_dir}" + ) + + if(CMAKE_GENERATOR MATCHES "^Ninja") + add_custom_command( + OUTPUT "${output_dir}/${fw_versioned_header_dir}" + DEPENDS ${target}_sync_headers + COMMAND ${copy_fw_sync_headers_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}) + endif() + add_custom_command( - OUTPUT "${output_dir}/${fw_versioned_header_dir}" ${out_files} - DEPENDS ${in_files} ${target}_sync_headers + OUTPUT ${out_files} + DEPENDS ${target}_copy_fw_sync_headers ${in_files} COMMAND - ${CMAKE_COMMAND} -E copy_directory - "${module_build_interface_include_dir}/.syncqt_staging" - "${output_dir}/${fw_versioned_header_dir}" + ${CMAKE_COMMAND} -E make_directory ${out_dirs} ${copy_commands} VERBATIM COMMENT "Copy the ${target} header files to the framework directory"