mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-29 04:09:35 +03:00
Add policy CMP0215 to emit `.swiftmodule` from a dedicated `-emit-module` build edge for importable Swift targets in the Ninja generator. Downstream targets can begin compiling as soon as the module interface is ready, overlapping with upstream object compilation and linking. When CMP0215 is NEW and CMP0157 is NEW, separate module emission is enabled by default. The `Swift_SEPARATE_MODULE_EMISSION` target property (initialized by the `CMAKE_Swift_SEPARATE_MODULE_EMISSION` variable) can override this per target. The compile edge still passes `-emit-module` so that swiftc continues to produce `.swiftdoc`; only the `.swiftmodule` output moves to the new edge. Also fix swiftmodule dependency edges in cmNinjaNormalTargetGenerator to use IsLanguageUsed instead of GetLinkerLanguage, so C/C++ targets whose linker language propagated to Swift do not produce spurious implicit dependencies. Closes: #27748
15 lines
378 B
CMake
15 lines
378 B
CMake
cmake_policy(SET CMP0157 NEW)
|
|
cmake_policy(SET CMP0215 NEW)
|
|
|
|
if(NOT CMAKE_GENERATOR MATCHES "Ninja")
|
|
message(SEND_ERROR "this test must use a Ninja generator, found ${CMAKE_GENERATOR} ")
|
|
endif()
|
|
|
|
set(CMAKE_NINJA_FORCE_RESPONSE_FILE TRUE)
|
|
|
|
enable_language(Swift)
|
|
|
|
add_library(L STATIC L.swift)
|
|
add_library(LClient STATIC LClient.swift)
|
|
target_link_libraries(LClient PRIVATE L)
|