Skip to content

Commit 32e9e2d

Browse files
committed
[Build] Add SWIFT_SYSTEM_NAME setting.
This lets us override the library subdir name when its derivation isn't straightforwardly just the lower-case version of `CMAKE_SYSTEM_NAME`. rdar://123381867
1 parent 1b514e4 commit 32e9e2d

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ project(Foundation
1313
LANGUAGES C Swift)
1414
enable_testing()
1515

16+
if(NOT SWIFT_SYSTEM_NAME)
17+
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
18+
set(SWIFT_SYSTEM_NAME macosx)
19+
else()
20+
set(SWIFT_SYSTEM_NAME "$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>")
21+
endif()
22+
endif()
23+
1624
# NOTE(compnerd) default to /MD or /MDd by default based on the configuration.
1725
# Cache the variable to allow the user to alter the configuration.
1826
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" CACHE
@@ -99,13 +107,13 @@ if(NOT BUILD_SHARED_LIBS)
99107
endif()
100108

101109
install(TARGETS CoreFoundation CFXMLInterface
102-
DESTINATION lib/swift_static/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>)
110+
DESTINATION lib/swift_static/${SWIFT_SYSTEM_NAME})
103111

104112
if(BUILD_NETWORKING)
105113
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS
106114
CFURLSessionInterface)
107115
install(TARGETS CFURLSessionInterface
108-
DESTINATION lib/swift_static/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>)
116+
DESTINATION lib/swift_static/${SWIFT_SYSTEM_NAME})
109117
endif()
110118
endif()
111119

Sources/BlocksRuntime/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ set_target_properties(BlocksRuntime PROPERTIES
1111
add_library(BlocksRuntime::BlocksRuntime ALIAS BlocksRuntime)
1212

1313
install(TARGETS BlocksRuntime
14-
ARCHIVE DESTINATION lib/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>
15-
LIBRARY DESTINATION lib/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>)
14+
ARCHIVE DESTINATION lib/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/${SWIFT_SYSTEM_NAME}
15+
LIBRARY DESTINATION lib/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/${SWIFT_SYSTEM_NAME})

Sources/Tools/plutil/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows")
2828
endif()
2929

3030
set_target_properties(plutil PROPERTIES
31-
INSTALL_RPATH "$ORIGIN/../lib/swift/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>")
31+
INSTALL_RPATH "$ORIGIN/../lib/swift/${SWIFT_SYSTEM_NAME}")
3232

3333

3434
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS plutil)

Sources/UUID/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if(NOT BUILD_SHARED_LIBS)
2828
# TODO(drexin): should be installed in architecture specific folder, once
2929
# the layout is fixed for non-Darwin platforms
3030
install(TARGETS uuid
31-
ARCHIVE DESTINATION lib/swift_static/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>
32-
LIBRARY DESTINATION lib/swift_static/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>
31+
ARCHIVE DESTINATION lib/swift_static/${SWIFT_SYSTEM_NAME}
32+
LIBRARY DESTINATION lib/swift_static/${SWIFT_SYSTEM_NAME}
3333
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
3434
endif()

cmake/modules/SwiftSupport.cmake

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,7 @@ endfunction()
4949
# Sets ${result_var_name} with the converted OS name derived from
5050
# CMAKE_SYSTEM_NAME.
5151
function(get_swift_host_os result_var_name)
52-
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
53-
set(${result_var_name} macosx PARENT_SCOPE)
54-
else()
55-
string(TOLOWER ${CMAKE_SYSTEM_NAME} cmake_system_name_lc)
56-
set(${result_var_name} ${cmake_system_name_lc} PARENT_SCOPE)
57-
endif()
52+
set(${result_var_name} ${SWIFT_SYSTEM_NAME} PARENT_SCOPE)
5853
endfunction()
5954

6055
function(_install_target module)

0 commit comments

Comments
 (0)