Skip to content

Commit c5c7ed1

Browse files
committed
build: hoist LINK_LIBRARIES out of _add_swift_executable_single
Hoist the responsibility for adding the linked libraries out of `_add_swift_executable_single` to the invoker. This impacts only `swift_add_target_executable`. This continues to bring the computation of the properties nearer the site of definition.
1 parent 43742d7 commit c5c7ed1

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

Diff for: cmake/modules/AddSwift.cmake

+3-7
Original file line numberDiff line numberDiff line change
@@ -2506,6 +2506,9 @@ function(_add_swift_executable_single name)
25062506
if(SWIFTEXE_SINGLE_EXCLUDE_FROM_ALL)
25072507
message(SEND_ERROR "${name} is using EXCLUDE_FROM_ALL option which is deprecated.")
25082508
endif()
2509+
if(SWIFTEXE_SINGLE_LINK_LIBRARIES)
2510+
message(SEND_ERROR "${name} is using LINK_LIBRARIES parameter which is deprecated. Please use target_link_libraries instead")
2511+
endif()
25092512

25102513
# Check arguments.
25112514
precondition(SWIFTEXE_SINGLE_SDK MESSAGE "Should specify an SDK")
@@ -2540,12 +2543,6 @@ function(_add_swift_executable_single name)
25402543
LINK_LIBRARIES_VAR_NAME link_libraries
25412544
LIBRARY_SEARCH_DIRECTORIES_VAR_NAME library_search_directories)
25422545

2543-
_list_add_string_suffix(
2544-
"${SWIFTEXE_SINGLE_LINK_LIBRARIES}"
2545-
"-${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_LIB_SUBDIR}-${SWIFTEXE_SINGLE_ARCHITECTURE}"
2546-
SWIFTEXE_SINGLE_LINK_LIBRARIES_TARGETS)
2547-
set(SWIFTEXE_SINGLE_LINK_LIBRARIES ${SWIFTEXE_SINGLE_LINK_LIBRARIES_TARGETS})
2548-
25492546
handle_swift_sources(
25502547
dependency_target
25512548
unused_module_dependency_target
@@ -2609,7 +2606,6 @@ function(_add_swift_executable_single name)
26092606
BINARY_DIR ${SWIFT_RUNTIME_OUTPUT_INTDIR}
26102607
LIBRARY_DIR ${SWIFT_LIBRARY_OUTPUT_INTDIR})
26112608

2612-
target_link_libraries("${name}" PRIVATE ${SWIFTEXE_SINGLE_LINK_LIBRARIES})
26132609
swift_common_llvm_config("${name}" ${SWIFTEXE_SINGLE_LLVM_LINK_COMPONENTS})
26142610

26152611
# NOTE(compnerd) use the C linker language to invoke `clang` rather than

Diff for: stdlib/cmake/modules/AddSwiftStdlib.cmake

+8-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,14 @@ function(add_swift_target_executable name)
4545
DEPENDS ${SWIFTEXE_TARGET_DEPENDS_with_suffix}
4646
LLVM_LINK_COMPONENTS ${SWIFTEXE_TARGET_LLVM_LINK_COMPONENTS}
4747
SDK "${sdk}"
48-
ARCHITECTURE "${arch}"
49-
LINK_LIBRARIES ${SWIFTEXE_TARGET_LINK_LIBRARIES})
48+
ARCHITECTURE "${arch}")
49+
50+
_list_add_string_suffix(
51+
"${SWIFTEXE_TARGET_LINK_LIBRARIES}"
52+
"-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch}"
53+
SWIFTEXE_TARGET_LINK_LIBRARIES_TARGETS)
54+
target_link_libraries(${VARIANT_NAME} PRIVATE
55+
${SWIFTEXE_TARGET_LINK_LIBRARIES_TARGETS})
5056

5157
if(NOT "${VARIANT_SUFFIX}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SUFFIX}")
5258
# By default, don't build executables for target SDKs to avoid building

0 commit comments

Comments
 (0)