mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
Wire up the flags needed to support module libraries built and used with Swift. We need to pass `-bundle` to the linker when linking module libraries on Darwin, and we need to pass `-export-dynamic` to the linker when emitting an executable that exports symbols on Linux. This patch wires up `CMAKE_SHARED_MODULE_CREATE_Swift_FLAGS` and `CMAKE_SHARED_MODULE_LOADER_Swift_FLAG` on Darwin, and hooks up `CMAKE_EXE_EXPORTS_Swift_FLAG` on Linux in order to support passing things correctly. We can't expose `CMAKE_EXE_LINKER_FLAGS` to Swift, as it contains flags that the Swift compiler doesn't recognize, but the other language-specific variables are safe to expose.
18 lines
828 B
CMake
18 lines
828 B
CMake
set(CMAKE_Swift_SYSROOT_FLAG "-sdk")
|
|
|
|
# Linker Selections
|
|
if("${CMAKE_GENERATOR}" STREQUAL Xcode)
|
|
# Xcode always uses clang to link, regardless of what the cmake link language
|
|
# is. Pass the clang flags when linking with Xcode.
|
|
set(CMAKE_Swift_USING_LINKER_APPLE_CLASSIC "-fuse-ld=ld" "LINKER:-ld_classic")
|
|
set(CMAKE_Swift_USING_LINKER_LLD "-fuse-ld=lld")
|
|
set(CMAKE_Swift_USING_LINKER_SYSTEM "-fuse-ld=ld")
|
|
set(CMAKE_SHARED_MODULE_LOADER_Swift_FLAG "-Wl,-bundle_loader,")
|
|
else()
|
|
set(CMAKE_Swift_USING_LINKER_APPLE_CLASSIC "-use-ld=ld" "LINKER:-ld_classic")
|
|
set(CMAKE_Swift_USING_LINKER_LLD "-use-ld=lld")
|
|
set(CMAKE_Swift_USING_LINKER_SYSTEM "-use-ld=ld")
|
|
set(CMAKE_SHARED_MODULE_LOADER_Swift_FLAG "-Xclang-linker -Wl,-bundle_loader,")
|
|
set(CMAKE_SHARED_MODULE_CREATE_Swift_FLAGS "-Xlinker -bundle")
|
|
endif()
|