Skip to content

Commit a182bdf

Browse files
committed
[CMake] Update source file list only if different
Use 'copy_if_different' instead of 'file(GENERATE'. Somehow 'file(GENERATE' failed with CMake Error: Files to be generated by multiple different commands:
1 parent b888abf commit a182bdf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

stdlib/cmake/modules/SwiftSource.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,10 @@ function(_compile_swift_files
921921
string(REPLACE ";" "'\n'" source_files_quoted "${source_files}")
922922
string(SHA1 file_name "'${source_files_quoted}'")
923923
set(file_path "${CMAKE_CURRENT_BINARY_DIR}/${file_name}.txt")
924-
file(GENERATE OUTPUT "${file_path}" CONTENT "'${source_files_quoted}'")
924+
file(WRITE "${file_path}.tmp" "'${source_files_quoted}'")
925+
add_custom_command(
926+
OUTPUT "${file_path}"
927+
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${file_path}.tmp" "${file_path}")
925928

926929
# If this platform/architecture combo supports backward deployment to old
927930
# Objective-C runtimes, we need to copy a YAML file with legacy type layout

0 commit comments

Comments
 (0)