@@ -917,11 +917,16 @@ function(_compile_swift_files
917917 # list in the Python script.
918918 string (REPLACE ";" "'\n '" source_files_quoted "${source_files} " )
919919 string (SHA1 file_name "'${source_files_quoted} '" )
920+ set (file_path_target "filelist-${file_name} " )
920921 set (file_path "${CMAKE_CURRENT_BINARY_DIR} /${file_name} .txt" )
921- file (WRITE "${file_path} .tmp" "'${source_files_quoted} '" )
922- add_custom_command (
923- OUTPUT "${file_path} "
924- COMMAND ${CMAKE_COMMAND} -E copy_if_different "${file_path} .tmp" "${file_path} " )
922+
923+ if (NOT TARGET ${file_path_target} )
924+ file (WRITE "${file_path} .tmp" "'${source_files_quoted} '" )
925+ add_custom_command_target(unused_var
926+ COMMAND ${CMAKE_COMMAND} -E copy_if_different "${file_path} .tmp" "${file_path} "
927+ CUSTOM_TARGET_NAME ${file_path_target}
928+ OUTPUT "${file_path} " )
929+ endif ()
925930
926931 # If this platform/architecture combo supports backward deployment to old
927932 # Objective-C runtimes, we need to copy a YAML file with legacy type layout
@@ -950,7 +955,7 @@ function(_compile_swift_files
950955 OUTPUT ${standard_outputs}
951956 DEPENDS
952957 "${line_directive_tool} "
953- "${file_path } "
958+ "${file_path_target } "
954959 ${swift_compiler_tool_dep}
955960 ${source_files} ${SWIFTFILE_DEPENDS}
956961 ${swift_ide_test_dependency}
@@ -993,7 +998,7 @@ function(_compile_swift_files
993998 OUTPUT ${module_outputs}
994999 DEPENDS
9951000 "${line_directive_tool} "
996- "${file_path } "
1001+ "${file_path_target } "
9971002 ${swift_compiler_tool_dep}
9981003 ${source_files} ${SWIFTFILE_DEPENDS}
9991004 ${swift_ide_test_dependency}
@@ -1022,7 +1027,7 @@ function(_compile_swift_files
10221027 DEPENDS
10231028 "${module_dependency_target} "
10241029 "${line_directive_tool} "
1025- "${file_path } "
1030+ "${file_path_target } "
10261031 ${swift_compiler_tool_dep}
10271032 ${source_files} ${SWIFTFILE_DEPENDS}
10281033 ${swift_ide_test_dependency}
@@ -1063,7 +1068,7 @@ function(_compile_swift_files
10631068 ${maccatalyst_module_outputs}
10641069 DEPENDS
10651070 "${line_directive_tool} "
1066- "${file_path } "
1071+ "${file_path_target } "
10671072 ${swift_compiler_tool_dep}
10681073 ${source_files}
10691074 ${SWIFTFILE_DEPENDS}
@@ -1093,7 +1098,7 @@ function(_compile_swift_files
10931098 OUTPUT ${sib_outputs}
10941099 DEPENDS
10951100 "${line_directive_tool} "
1096- "${file_path } "
1101+ "${file_path_target } "
10971102 ${swift_compiler_tool_dep}
10981103 ${source_files} ${SWIFTFILE_DEPENDS}
10991104 ${copy_legacy_layouts_dep}
@@ -1113,7 +1118,7 @@ function(_compile_swift_files
11131118 OUTPUT ${sibopt_outputs}
11141119 DEPENDS
11151120 "${line_directive_tool} "
1116- "${file_path } "
1121+ "${file_path_target } "
11171122 ${swift_compiler_tool_dep}
11181123 ${source_files} ${SWIFTFILE_DEPENDS}
11191124 ${copy_legacy_layouts_dep}
@@ -1134,7 +1139,7 @@ function(_compile_swift_files
11341139 OUTPUT ${sibgen_outputs}
11351140 DEPENDS
11361141 "${line_directive_tool} "
1137- "${file_path } "
1142+ "${file_path_target } "
11381143 ${swift_compiler_tool_dep}
11391144 ${source_files} ${SWIFTFILE_DEPENDS}
11401145 ${copy_legacy_layouts_dep}
0 commit comments