@@ -58,26 +58,33 @@ if (SWIFT_SWIFT_PARSER)
5858 ${CMAKE_SHARED_LIBRARY_SUFFIX}
5959 OUTPUT_VARIABLE SWIFT_SYNTAX_SHARED_LIBRARIES)
6060
61- # The complete set of files that get installed.
62- set (SWIFT_SYNTAX_DEST_FILES)
61+ # Interface library to collect swiftinterfaces and swiftmodules from
62+ # SwiftSyntax
63+ add_library (swiftSyntaxLibraries INTERFACE )
6364
6465 # Copy over all of the shared libraries from earlyswiftsyntax so they can
6566 # be found via RPATH.
6667 foreach (sharedlib ${SWIFT_SYNTAX_SHARED_LIBRARIES} )
6768 add_custom_command (
68- OUTPUT ${SWIFT_HOST_LIBRARIES_DEST_DIR} /${sharedlib}
69+ OUTPUT "${SWIFT_HOST_LIBRARIES_DEST_DIR} /${sharedlib} "
70+ DEPENDS "${SWIFT_SYNTAX_LIBRARIES_SOURCE_DIR} /${sharedlib} "
6971 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SWIFT_SYNTAX_LIBRARIES_SOURCE_DIR} /${sharedlib} ${SWIFT_HOST_LIBRARIES_DEST_DIR} /${sharedlib}
72+ )
73+
74+ add_custom_target (copy_swiftSyntaxLibrary_${sharedlib}
75+ DEPENDS "${SWIFT_HOST_LIBRARIES_DEST_DIR} /${sharedlib} "
7076 COMMENT "Copying ${sharedlib} "
7177 )
7278
73- list ( APPEND SWIFT_SYNTAX_DEST_FILES ${SWIFT_HOST_LIBRARIES_DEST_DIR} / ${sharedlib} )
79+ add_dependencies (swiftSyntaxLibraries copy_swiftSyntaxLibrary_ ${sharedlib} )
7480 endforeach ()
7581
7682 # Copy all of the Swift modules from earlyswiftsyntax so they can be found
7783 # in the same relative place within the build directory as in the final
7884 # toolchain.
7985 list (TRANSFORM SWIFT_SYNTAX_MODULES APPEND ".swiftmodule"
8086 OUTPUT_VARIABLE SWIFT_SYNTAX_MODULE_DIRS)
87+
8188 foreach (module_dir ${SWIFT_SYNTAX_MODULE_DIRS} )
8289 # Find all of the source module files.
8390 file (GLOB module_files
@@ -93,17 +100,18 @@ if (SWIFT_SWIFT_PARSER)
93100
94101 add_custom_command (
95102 OUTPUT ${dest_module_files}
103+ DEPENDS ${module_files}
96104 COMMAND ${CMAKE_COMMAND} -E make_directory ${SWIFT_HOST_LIBRARIES_DEST_DIR} /${module_dir}
97105 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${module_files} ${SWIFT_HOST_LIBRARIES_DEST_DIR} /${module_dir} /
106+ )
107+
108+ add_custom_target (copy_swiftSyntaxModule_${module_dir}
109+ DEPENDS ${dest_module_files}
98110 COMMENT "Copying ${module_dir} "
99111 )
100112
101- list ( APPEND SWIFT_SYNTAX_DEST_FILES ${dest_module_files } )
113+ add_dependencies (swiftSyntaxLibraries copy_swiftSyntaxModule_ ${module_dir } )
102114 endforeach ()
103-
104- # Add a custom target to copy over the SwiftSyntax build products into
105- # their final places.
106- add_custom_target (swiftSyntaxLibraries DEPENDS ${SWIFT_SYNTAX_DEST_FILES} )
107115endif ()
108116
109117# Workaround a cmake bug, see the corresponding function in swift-syntax
0 commit comments