mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-08 14:50:10 -06:00
Swift: Fix swiftmodule dependency
Fix a bug in the split build model where we generate a dependency on the swiftmodule of a target that does not emit a swiftmodule. This fix drops the erroneous swiftmodule dependency edge, avoiding the broken dependency graph. Incremental builds still work with the new model because of the swiftmodule dependency edges between Swift compilation steps. Fixes: #26922
This commit is contained in:
@@ -1578,7 +1578,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
|
||||
}
|
||||
|
||||
// Add dependencies on swiftmodule files when using the swift linker
|
||||
if (this->TargetLinkLanguage(config) == "Swift") {
|
||||
if (!this->GetLocalGenerator()->IsSplitSwiftBuild() &&
|
||||
this->TargetLinkLanguage(config) == "Swift") {
|
||||
if (cmComputeLinkInformation* cli =
|
||||
this->GeneratorTarget->GetLinkInformation(config)) {
|
||||
for (auto const& dependency : cli->GetItems()) {
|
||||
|
||||
0
Tests/RunCMake/Swift/C.c
Normal file
0
Tests/RunCMake/Swift/C.c
Normal file
10
Tests/RunCMake/Swift/MultiLangChain.cmake
Normal file
10
Tests/RunCMake/Swift/MultiLangChain.cmake
Normal file
@@ -0,0 +1,10 @@
|
||||
cmake_policy(SET CMP0157 NEW)
|
||||
cmake_policy(SET CMP0195 NEW)
|
||||
|
||||
enable_language(Swift C)
|
||||
|
||||
add_library(L L.swift)
|
||||
add_library(C C.c)
|
||||
target_link_libraries(C PRIVATE L)
|
||||
add_library(E E.swift)
|
||||
target_link_libraries(E PRIVATE C)
|
||||
@@ -30,6 +30,17 @@ block()
|
||||
endif()
|
||||
endblock()
|
||||
|
||||
# Older Xcode versions didn't support Swift static libraries.
|
||||
if(NOT (RunCMake_GENERATOR STREQUAL "Xcode" AND XCODE_VERSION VERSION_LESS 9.0))
|
||||
block()
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/MultiLangChain-build)
|
||||
run_cmake(MultiLangChain)
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
set(RunCMake_TEST_OUTPUT_MERGE 1)
|
||||
run_cmake_command(MultiLangChain-build ${CMAKE_COMMAND} --build .)
|
||||
endblock()
|
||||
endif()
|
||||
|
||||
if(RunCMake_GENERATOR MATCHES "Ninja.*")
|
||||
block()
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0195-NEW-build)
|
||||
|
||||
Reference in New Issue
Block a user