mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Update CMP0215 to avoid attempting to iterate through the flags looking for `-emit-module-path` ins the user-specified flags. We don't do this anywhere else in the code. The existing implementation didn't handle correctly parsing the flag so `-I blah/my-emit-module-path/` and `-Xcc -emit-module-path ...` would both trigger it, result in the compiler not emitting any module. Furthermore, it didn't include the user-specified module path as part of the build graph resulting in an incorrect build graph that would never resolve. The only two appropriate layouts for the module are either the flat binary module file with the name `<module-name>.swiftmodule`, or the nested form with `<module-name>.swiftmodule/<module-triple>.swiftmodule`. The noted Swift-Syntax situation passes the explicit `-emit-module-path` to get to the latter form. This form is automatically emitted by CMake when CMP0195 is `NEW`, removing the need for the flag. The Swift project generally recommends the nested directory structure since it gathers all of the generated interface outputs from the compiler (textual swift interfaces, swiftdoc, sourceinfo, and the binary swiftmodule file) in a single place, and since it uses the module triple in the filename, cleanly allows fat mach-o binaries on Apple platforms. Fixes: #28021
17 lines
562 B
CMake
17 lines
562 B
CMake
cmake_policy(SET CMP0157 NEW)
|
|
cmake_policy(SET CMP0195 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()
|
|
|
|
enable_language(Swift)
|
|
|
|
# A standalone library with a custom module output path (like swiftCore
|
|
# in the Swift stdlib). The link edge must depend on the actual
|
|
# emit-module output, not GetSwiftModulePath().
|
|
add_library(L STATIC L.swift)
|
|
set_target_properties(L PROPERTIES
|
|
Swift_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/custom)
|