Skip to content

Commit a7a8ba1

Browse files
authored
[CMake] Add dep in add_swift_target_library_single from install component (#70490)
While `add_swift_target_library` has code to add a dependency from the install component to the target, similar code was missing from `add_swift_target_library_single`, probably because `add_swift_target_library` calls `add_swift_target_library_single`, so the extra dependency is not necessary. However, there's usages of `add_swift_target_library_single` outside `add_swift_target_library` which were creating targets that were not dependencies of their install components. Some of those cases are the embedded stdlib targets, which are installed as part of the `stdlib` component. It normally does not matter when using `build-script`, because those targets are build as part of `all`, but it does matter if one is using CMake/Ninja directly or in cases where `build-script` is not used. Trying to use targets like `install-stdlib` will had missed building the embedded stdlib, and failed the installation.
1 parent e9fcb12 commit a7a8ba1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,7 @@ function(add_swift_target_library_single target name)
10431043
add_custom_target("${target}"
10441044
DEPENDS
10451045
"${swift_module_dependency_target}")
1046+
add_dependencies("${install_in_component}" "${target}")
10461047

10471048
return()
10481049
endif()
@@ -1076,6 +1077,7 @@ function(add_swift_target_library_single target name)
10761077
if (SWIFTLIB_SINGLE_ONLY_SWIFTMODULE)
10771078
add_custom_target("${target}"
10781079
DEPENDS "${swift_module_dependency_target}")
1080+
add_dependencies("${install_in_component}" "${target}")
10791081
return()
10801082
endif()
10811083

@@ -1084,6 +1086,9 @@ function(add_swift_target_library_single target name)
10841086
${SWIFTLIB_SINGLE_EXTERNAL_SOURCES}
10851087
${INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS}
10861088
${SWIFTLIB_SINGLE_XCODE_WORKAROUND_SOURCES})
1089+
if (NOT SWIFTLIB_SINGLE_OBJECT_LIBRARY)
1090+
add_dependencies("${install_in_component}" "${target}")
1091+
endif()
10871092
# NOTE: always inject the LLVMSupport directory before anything else. We want
10881093
# to ensure that the runtime is built with our local copy of LLVMSupport
10891094
target_include_directories(${target} BEFORE PRIVATE

0 commit comments

Comments
 (0)