From fec5a5a6302e3bd30b71cbb8a22706d417eb5e72 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Wed, 18 Sep 2024 09:50:19 +0100 Subject: [PATCH] [Build] Use `SWIFT_SYSTEM_NAME` rather than just lowercasing. Lowercasing `CMAKE_SYSTEM_NAME` to find the name Swift uses for a platform is not guaranteed to work. Instead, use the `SWIFT_SYSTEM_NAME` variable, which lets us override the name when building the Static SDK for Linux. Fixes #420. --- CMakeLists.txt | 8 ++++++++ cmake/modules/SwiftSupport.cmake | 7 +------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 939a29e4..5931546d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,14 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY MultiThreadedDLL) +if(NOT SWIFT_SYSTEM_NAME) + if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + set(SWIFT_SYSTEM_NAME macosx) + else() + set(SWIFT_SYSTEM_NAME "$") + endif() +endif() + set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY MultiThreadedDLL) diff --git a/cmake/modules/SwiftSupport.cmake b/cmake/modules/SwiftSupport.cmake index 21b9d693..508bb62b 100644 --- a/cmake/modules/SwiftSupport.cmake +++ b/cmake/modules/SwiftSupport.cmake @@ -63,12 +63,7 @@ endfunction() # Sets ${result_var_name} with the converted OS name derived from # CMAKE_SYSTEM_NAME. function(get_swift_host_os result_var_name) - if(CMAKE_SYSTEM_NAME STREQUAL Darwin) - set(${result_var_name} macosx PARENT_SCOPE) - else() - string(TOLOWER ${CMAKE_SYSTEM_NAME} cmake_system_name_lc) - set(${result_var_name} ${cmake_system_name_lc} PARENT_SCOPE) - endif() + set(${result_var_name} ${SWIFT_SYSTEM_NAME} PARENT_SCOPE) endfunction() function(_install_target module)