Skip to content

Commit 540f008

Browse files
authored
Merge pull request #1366 from bnbarham/more-workarounds
[CMake] Workaround stale object files causing rebuilds
2 parents 579e2bc + 7dc6057 commit 540f008

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cmake/modules/AddSwiftHostLibrary.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ function(add_swift_host_library name)
3030
COMMAND "${CMAKE_COMMAND}" -E make_directory ${module_base}
3131
COMMENT "Generating module directory for ${name}")
3232

33+
# Touch the library and objects to workaround their mtime not being updated
34+
# when there are no real changes (eg. a file was updated with a comment).
35+
# Ideally this should be done in the driver, which could only update the
36+
# files that have changed.
37+
add_custom_command(
38+
TARGET ${name}
39+
POST_BUILD
40+
COMMAND "${CMAKE_COMMAND}" -E touch_nocreate $<TARGET_FILE:${name}> $<TARGET_OBJECTS:${name}>
41+
COMMAND_EXPAND_LISTS
42+
COMMENT "Update mtime of library outputs workaround")
43+
3344
# Install the Swift module into the appropriate location.
3445
set_target_properties(${name}
3546
PROPERTIES Swift_MODULE_DIRECTORY ${module_dir}

0 commit comments

Comments
 (0)