diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 99bc91a8c4..af18d21708 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -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()) { diff --git a/Tests/RunCMake/Swift/C.c b/Tests/RunCMake/Swift/C.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Tests/RunCMake/Swift/MultiLangChain.cmake b/Tests/RunCMake/Swift/MultiLangChain.cmake new file mode 100644 index 0000000000..f8dccc9d8e --- /dev/null +++ b/Tests/RunCMake/Swift/MultiLangChain.cmake @@ -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) diff --git a/Tests/RunCMake/Swift/RunCMakeTest.cmake b/Tests/RunCMake/Swift/RunCMakeTest.cmake index 63ad2323b7..bab92309a1 100644 --- a/Tests/RunCMake/Swift/RunCMakeTest.cmake +++ b/Tests/RunCMake/Swift/RunCMakeTest.cmake @@ -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)