Skip to content

Commit

Permalink
[Build] Use SWIFT_SYSTEM_NAME rather than just lowercasing.
Browse files Browse the repository at this point in the history
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 apple#420.
  • Loading branch information
al45tair committed Sep 18, 2024
1 parent 3d2dc41 commit e5e0aa4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ cmake_minimum_required(VERSION 3.16)
project(SwiftCollections
LANGUAGES C Swift)

if(NOT SWIFT_SYSTEM_NAME)
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(SWIFT_SYSTEM_NAME macosx)
else()
set(SWIFT_SYSTEM_NAME "$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>")
endif()
endif()

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)

set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
Expand Down
7 changes: 1 addition & 6 deletions cmake/modules/SwiftSupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,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)
Expand Down

0 comments on commit e5e0aa4

Please sign in to comment.