Skip to content

Commit be38d8a

Browse files
authored
cmake: simplify Swift module dependency for Swift host tools. NFC (swiftlang#18600)
1 parent ba3fa2f commit be38d8a

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2314,13 +2314,28 @@ macro(add_swift_lib_subdirectory name)
23142314
endmacro()
23152315

23162316
function(add_swift_host_tool executable)
2317+
set(ADDSWIFTHOSTTOOL_multiple_parameter_options
2318+
SWIFT_COMPONENT
2319+
COMPILE_FLAGS
2320+
DEPENDS
2321+
SWIFT_MODULE_DEPENDS)
2322+
23172323
cmake_parse_arguments(
23182324
ADDSWIFTHOSTTOOL # prefix
23192325
"" # options
23202326
"" # single-value args
2321-
"SWIFT_COMPONENT;COMPILE_FLAGS;DEPENDS" # multi-value args
2327+
"${ADDSWIFTHOSTTOOL_multiple_parameter_options}" # multi-value args
23222328
${ARGN})
23232329

2330+
# Configure variables for this subdirectory.
2331+
set(VARIANT_SUFFIX "-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH}")
2332+
set(MODULE_VARIANT_SUFFIX "-swiftmodule${VARIANT_SUFFIX}")
2333+
2334+
foreach(mod ${ADDSWIFTHOSTTOOL_SWIFT_MODULE_DEPENDS})
2335+
list(APPEND ADDSWIFTHOSTTOOL_DEPENDS "swift${mod}${MODULE_VARIANT_SUFFIX}")
2336+
list(APPEND ADDSWIFTHOSTTOOL_DEPENDS "swift${mod}${VARIANT_SUFFIX}")
2337+
endforeach()
2338+
23242339
# Create the executable rule.
23252340
add_swift_executable(
23262341
${executable}
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
1-
macro(add_swift_module_depends results target)
2-
list(APPEND ${results} "${target}-macosx")
3-
list(APPEND ${results} "${target}-macosx-x86_64")
4-
list(APPEND ${results} "${target}-swiftmodule-macosx-x86_64")
5-
endmacro()
6-
7-
add_swift_module_depends(all_depends swiftTestUtils)
8-
add_swift_module_depends(all_depends swiftSwiftSyntax)
9-
101
add_swift_host_tool(swift-swiftsyntax-test
112
main.swift
123
ClassifiedSyntaxTreePrinter.swift
134
empty.c # FIXME: If there is no C file in the target Xcode skips the linking phase and doesn't create the executable
145
COMPILE_FLAGS "-module-name" "main"
15-
DEPENDS ${all_depends}
6+
SWIFT_MODULE_DEPENDS TestUtils SwiftSyntax
167
)

0 commit comments

Comments
 (0)