Skip to content

Commit 7020740

Browse files
authored
Merge pull request #21326 from xiaobai/swift_component_required
[CMake] Require SWIFT_COMPONENT for add_swift_host_tool
2 parents baf76c5 + 5d5d01a commit 7020740

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,26 +2322,26 @@ function(add_swift_host_tool executable)
23222322
"${ADDSWIFTHOSTTOOL_multiple_parameter_options}" # multi-value args
23232323
${ARGN})
23242324

2325+
precondition(ADDSWIFTHOSTTOOL_SWIFT_COMPONENT
2326+
MESSAGE "Swift Component is required to add a host tool")
2327+
23252328
# Create the executable rule.
23262329
add_swift_executable(
23272330
${executable}
23282331
${ADDSWIFTHOSTTOOL_UNPARSED_ARGUMENTS}
23292332
)
23302333

2331-
# And then create the install rule if we are asked to.
2332-
if (ADDSWIFTHOSTTOOL_SWIFT_COMPONENT)
2333-
swift_install_in_component(${ADDSWIFTHOSTTOOL_SWIFT_COMPONENT}
2334-
TARGETS ${executable}
2335-
RUNTIME DESTINATION bin)
2334+
swift_install_in_component(${ADDSWIFTHOSTTOOL_SWIFT_COMPONENT}
2335+
TARGETS ${executable}
2336+
RUNTIME DESTINATION bin)
23362337

2337-
swift_is_installing_component(${ADDSWIFTHOSTTOOL_SWIFT_COMPONENT}
2338-
is_installing)
2339-
2340-
if(NOT is_installing)
2341-
set_property(GLOBAL APPEND PROPERTY SWIFT_BUILDTREE_EXPORTS ${executable})
2342-
else()
2343-
set_property(GLOBAL APPEND PROPERTY SWIFT_EXPORTS ${executable})
2344-
endif()
2338+
swift_is_installing_component(${ADDSWIFTHOSTTOOL_SWIFT_COMPONENT}
2339+
is_installing)
2340+
2341+
if(NOT is_installing)
2342+
set_property(GLOBAL APPEND PROPERTY SWIFT_BUILDTREE_EXPORTS ${executable})
2343+
else()
2344+
set_property(GLOBAL APPEND PROPERTY SWIFT_EXPORTS ${executable})
23452345
endif()
23462346
endfunction()
23472347

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
add_swift_host_tool(swift-stdlib-tool
2-
swift-stdlib-tool.mm)
2+
swift-stdlib-tool.mm
3+
SWIFT_COMPONENT compiler)
34

45
find_library(FOUNDATION NAMES Foundation)
56
target_link_libraries(swift-stdlib-tool PRIVATE ${FOUNDATION})
6-
7-
swift_install_in_component(compiler
8-
TARGETS swift-stdlib-tool
9-
RUNTIME DESTINATION "bin")
10-

0 commit comments

Comments
 (0)