Skip to content

Commit 0bbc160

Browse files
committed
build: strength reduce add_dependencies usage
The two invocations here both had a single parameter passed to it. Replace it with `add_dependencies` which already actually supports multiple dependencies specified. Sink the custom wrapper into the usage location in `AddSwiftStdlib.cmake`.
1 parent 8e73658 commit 0bbc160

File tree

2 files changed

+18
-26
lines changed

2 files changed

+18
-26
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,6 @@ set(SWIFTLIB_DIR
1212
set(SWIFTSTATICLIB_DIR
1313
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/swift_static")
1414

15-
function(add_dependencies_multiple_targets)
16-
cmake_parse_arguments(
17-
ADMT # prefix
18-
"" # options
19-
"" # single-value args
20-
"TARGETS;DEPENDS" # multi-value args
21-
${ARGN})
22-
precondition(ADMT_UNPARSED_ARGUMENTS NEGATE MESSAGE "unrecognized arguments: ${ADMT_UNPARSED_ARGUMENTS}")
23-
24-
if(NOT "${ADMT_DEPENDS}" STREQUAL "")
25-
foreach(target ${ADMT_TARGETS})
26-
add_dependencies("${target}" ${ADMT_DEPENDS})
27-
endforeach()
28-
endif()
29-
endfunction()
30-
3115
function(_compute_lto_flag option out_var)
3216
string(TOLOWER "${option}" lowercase_option)
3317
if (lowercase_option STREQUAL "full")
@@ -522,6 +506,7 @@ function(_add_swift_host_library_single target)
522506

523507
add_library("${target}" ${libkind} ${ASHLS_SOURCES})
524508
_set_target_prefix_and_suffix("${target}" "${libkind}" "${SWIFT_HOST_VARIANT_SDK}")
509+
add_dependencies(${target} ${LLVM_COMMON_DEPENDS})
525510

526511
if(SWIFT_HOST_VARIANT_SDK STREQUAL WINDOWS)
527512
swift_windows_include_for_arch(${SWIFT_HOST_VARIANT_ARCH} SWIFTLIB_INCLUDE)
@@ -562,13 +547,6 @@ function(_add_swift_host_library_single target)
562547
set_target_properties("${target}" PROPERTIES BUILD_WITH_INSTALL_RPATH YES)
563548
set_target_properties("${target}" PROPERTIES FOLDER "Swift libraries")
564549

565-
# Handle linking and dependencies.
566-
add_dependencies_multiple_targets(
567-
TARGETS "${target}"
568-
DEPENDS
569-
${gyb_dependency_targets}
570-
${LLVM_COMMON_DEPENDS})
571-
572550
# Call llvm_config() only for libraries that are part of the compiler.
573551
swift_common_llvm_config("${target}" ${ASHLS_LLVM_LINK_COMPONENTS})
574552

@@ -731,6 +709,7 @@ function(add_swift_host_tool executable)
731709
_add_host_variant_link_flags(${executable})
732710
target_link_directories(${executable} PRIVATE
733711
${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR})
712+
add_dependencies(${executable} ${LLVM_COMMON_DEPENDS})
734713

735714
set_target_properties(${executable} PROPERTIES
736715
FOLDER "Swift executables")
@@ -744,9 +723,6 @@ function(add_swift_host_tool executable)
744723
INSTALL_RPATH "@executable_path/../lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}")
745724
endif()
746725

747-
add_dependencies_multiple_targets(
748-
TARGETS ${executable}
749-
DEPENDS ${LLVM_COMMON_DEPENDS})
750726
llvm_update_compile_flags(${executable})
751727
swift_common_llvm_config(${executable} ${ASHT_LLVM_LINK_COMPONENTS})
752728
set_output_directory(${executable}

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22
include(AddSwift)
33
include(SwiftSource)
44

5+
function(add_dependencies_multiple_targets)
6+
cmake_parse_arguments(
7+
ADMT # prefix
8+
"" # options
9+
"" # single-value args
10+
"TARGETS;DEPENDS" # multi-value args
11+
${ARGN})
12+
precondition(ADMT_UNPARSED_ARGUMENTS NEGATE MESSAGE "unrecognized arguments: ${ADMT_UNPARSED_ARGUMENTS}")
13+
14+
if(NOT "${ADMT_DEPENDS}" STREQUAL "")
15+
foreach(target ${ADMT_TARGETS})
16+
add_dependencies("${target}" ${ADMT_DEPENDS})
17+
endforeach()
18+
endif()
19+
endfunction()
20+
521
# Usage:
622
# _add_target_variant_c_compile_link_flags(
723
# SDK sdk

0 commit comments

Comments
 (0)