summaryrefslogtreecommitdiff
path: root/Modules/CMakeSwiftInformation.cmake
diff options
context:
space:
mode:
authorCraig Hutchinson <54269136+CraigHutchinson@users.noreply.github.com>2023-01-13 13:34:16 +0000
committerBrad King <brad.king@kitware.com>2023-01-17 09:20:39 -0500
commit9a013c9e9d344f9703f339c6aeab9dcc303b53c0 (patch)
tree154b926732b7d29f63f42bc745ef20d19a47642c /Modules/CMakeSwiftInformation.cmake
parent485a72dc64602a0e1513744bd3855333e1dfb1da (diff)
downloadcmake-9a013c9e9d344f9703f339c6aeab9dcc303b53c0.tar.gz
Swift: Use macOS-style linker flags on iOS, tvOS, and watchOS too
Without this, building a shared Swift library with `CMAKE_SYSTEM_NAME=iOS` produces the error `ld: unknown option: -soname`. iOS is an Apple platform, and so should use the `-install_name` option.
Diffstat (limited to 'Modules/CMakeSwiftInformation.cmake')
-rw-r--r--Modules/CMakeSwiftInformation.cmake6
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake
index 62f7ef2a41..707635bcec 100644
--- a/Modules/CMakeSwiftInformation.cmake
+++ b/Modules/CMakeSwiftInformation.cmake
@@ -20,7 +20,8 @@ endif()
set(CMAKE_EXE_EXPORTS_Swift_FLAG "-emit-module -emit-module-path <SWIFT_MODULE> ${CMAKE_Swift_IMPLIB_LINKER_FLAGS}")
set(CMAKE_INCLUDE_FLAG_Swift "-I ")
-if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS"
+ OR CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS")
set(CMAKE_SHARED_LIBRARY_SONAME_Swift_FLAG "-Xlinker -install_name -Xlinker ")
elseif(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
set(CMAKE_SHARED_LIBRARY_SONAME_Swift_FLAG "-Xlinker -soname -Xlinker ")
@@ -29,7 +30,8 @@ endif()
if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
set(CMAKE_EXECUTABLE_RUNTIME_Swift_FLAG "-Xlinker -rpath -Xlinker ")
set(CMAKE_SHARED_LIBRARY_RUNTIME_Swift_FLAG "-Xlinker -rpath -Xlinker ")
- if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
+ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS"
+ OR CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS")
set(CMAKE_EXECUTABLE_RUNTIME_Swift_FLAG_SEP "")
set(CMAKE_SHARED_LIBRARY_RUNTIME_Swift_FLAG_SEP "")
else()