@@ -51,11 +51,8 @@ if (SWIFT_SWIFT_PARSER)
51
51
cmake_parse_arguments (ARGS "" "" "PUBLIC" ${ARGN} )
52
52
53
53
foreach (DEPENDENCY ${ARGS_PUBLIC} )
54
- # This is a hack to workaround a cmake bug that results in multiple ninja targets producing
55
- # the same file in a downstream SourceKit target. This should use `PUBLIC`, the dependency
56
- # directly (rather than `TARGET_OBJECTS`), and no `add_dependencies`.
57
54
target_link_libraries (${TARGET} PRIVATE
58
- $< TARGET_OBJECTS: $ {DEPENDENCY}>
55
+ $ {DEPENDENCY}
59
56
)
60
57
add_dependencies (${TARGET} ${DEPENDENCY} )
61
58
@@ -69,23 +66,54 @@ if (SWIFT_SWIFT_PARSER)
69
66
endforeach ()
70
67
endfunction ()
71
68
69
+ set (SWIFT_SYNTAX_MODULES
70
+ SwiftBasicFormat
71
+ SwiftParser
72
+ SwiftParserDiagnostics
73
+ SwiftDiagnostics
74
+ SwiftSyntax
75
+ SwiftOperators
76
+ SwiftSyntaxBuilder
77
+ _SwiftSyntaxMacros
78
+ SwiftCompilerSupport
79
+ )
80
+
81
+ # Compute the list of SwiftSyntax targets
82
+ list (TRANSFORM SWIFT_SYNTAX_MODULES PREPEND "SwiftSyntax::"
83
+ OUTPUT_VARIABLE SWIFT_SYNTAX_TARGETS )
84
+
72
85
# TODO: Change to target_link_libraries when cmake is fixed
73
86
force_target_link_libraries (swiftASTGen PUBLIC
74
- SwiftSyntax::SwiftBasicFormat
75
- SwiftSyntax::SwiftParser
76
- SwiftSyntax::SwiftParserDiagnostics
77
- SwiftSyntax::SwiftDiagnostics
78
- SwiftSyntax::SwiftSyntax
79
- SwiftSyntax::SwiftOperators
80
- SwiftSyntax::SwiftSyntaxBuilder
81
- SwiftSyntax::_SwiftSyntaxMacros
82
- SwiftSyntax::SwiftCompilerSupport
87
+ ${SWIFT_SYNTAX_TARGETS}
83
88
)
84
89
target_link_libraries (swiftASTGen PUBLIC
85
90
swiftAST
86
91
swift_CompilerPluginSupport
87
92
)
88
93
94
+ set (SWIFT_SYNTAX_LIBRARIES_SOURCE_DIR
95
+ "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR} /lib/swift/host" )
96
+ set (SWIFT_SYNTAX_LIBRARIES_DEST_DIR
97
+ "${CMAKE_LIBRARY_OUTPUT_DIRECTORY} /swift/host" )
98
+
99
+ # Determine the SwiftSyntax shared library files that were built as
100
+ # part of earlyswiftsyntax.
101
+ list (TRANSFORM SWIFT_SYNTAX_MODULES PREPEND ${CMAKE_SHARED_LIBRARY_PREFIX}
102
+ OUTPUT_VARIABLE SWIFT_SYNTAX_SHARED_LIBRARIES )
103
+ list (TRANSFORM SWIFT_SYNTAX_SHARED_LIBRARIES APPEND
104
+ ${CMAKE_SHARED_LIBRARY_SUFFIX}
105
+ OUTPUT_VARIABLE SWIFT_SYNTAX_SHARED_LIBRARIES )
106
+
107
+ # Copy over all of the shared libraries from earlyswiftsyntax so they can
108
+ # be found via RPATH.
109
+ foreach (sharedlib ${SWIFT_SYNTAX_SHARED_LIBRARIES} )
110
+ add_custom_command (
111
+ TARGET swiftASTGen PRE_BUILD
112
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SWIFT_SYNTAX_LIBRARIES_SOURCE_DIR} /${sharedlib} ${SWIFT_SYNTAX_LIBRARIES_DEST_DIR} /${sharedlib}
113
+ COMMENT "Copying ${sharedlib} "
114
+ )
115
+ endforeach ()
116
+
89
117
target_include_directories (swiftASTGen PUBLIC
90
118
"${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR} /lib/swift/host" )
91
119
0 commit comments