Skip to content

Commit 81c5202

Browse files
committed
Install C and C++ libraries in the arch directory
* Update the C and C++ libraries to also install the arch sub-directory. * Simplify the logic to gather the arch and triple data.
1 parent e91ff61 commit 81c5202

File tree

5 files changed

+11
-27
lines changed

5 files changed

+11
-27
lines changed

Sources/CoreFoundation/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ install(DIRECTORY
148148

149149
if(NOT BUILD_SHARED_LIBS)
150150
install(TARGETS CoreFoundation
151-
ARCHIVE DESTINATION lib/swift_static/${SwiftFoundation_PLATFORM}
152-
LIBRARY DESTINATION lib/swift_static/${SwiftFoundation_PLATFORM}
151+
ARCHIVE DESTINATION lib/swift_static/${SwiftFoundation_PLATFORM}$<$<BOOL:${SwiftFoundation_INSTALL_ARCH_SUBDIR}>:/${SwiftFoundation_ARCH}>
152+
LIBRARY DESTINATION lib/swift_static/${SwiftFoundation_PLATFORM}$<$<BOOL:${SwiftFoundation_INSTALL_ARCH_SUBDIR}>:/${SwiftFoundation_ARCH}>
153153
RUNTIME DESTINATION bin)
154154
endif()

Sources/_CFURLSessionInterface/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ target_link_libraries(_CFURLSessionInterface PRIVATE
3737
if(NOT BUILD_SHARED_LIBS)
3838
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS _CFURLSessionInterface)
3939
install(TARGETS _CFURLSessionInterface
40-
ARCHIVE DESTINATION lib/swift_static/${SwiftFoundation_PLATFORM}
41-
LIBRARY DESTINATION lib/swift_static/${SwiftFoundation_PLATFORM}
40+
ARCHIVE DESTINATION lib/swift_static/${SwiftFoundation_PLATFORM}$<$<BOOL:${SwiftFoundation_INSTALL_ARCH_SUBDIR}>:/${SwiftFoundation_ARCH}>
41+
LIBRARY DESTINATION lib/swift_static/${SwiftFoundation_PLATFORM}$<$<BOOL:${SwiftFoundation_INSTALL_ARCH_SUBDIR}>:/${SwiftFoundation_ARCH}>
4242
RUNTIME DESTINATION bin)
4343
endif()

Sources/_CFXMLInterface/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ endif()
3939
if(NOT BUILD_SHARED_LIBS)
4040
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS _CFXMLInterface)
4141
install(TARGETS _CFXMLInterface
42-
ARCHIVE DESTINATION lib/swift_static/${SwiftFoundation_PLATFORM}
43-
LIBRARY DESTINATION lib/swift_static/${SwiftFoundation_PLATFORM}
42+
ARCHIVE DESTINATION lib/swift_static/${SwiftFoundation_PLATFORM}$<$<BOOL:${SwiftFoundation_INSTALL_ARCH_SUBDIR}>:/${SwiftFoundation_ARCH}>
43+
LIBRARY DESTINATION lib/swift_static/${SwiftFoundation_PLATFORM}$<$<BOOL:${SwiftFoundation_INSTALL_ARCH_SUBDIR}>:/${SwiftFoundation_ARCH}>
4444
RUNTIME DESTINATION bin)
4545
endif()

Sources/plutil/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ target_link_libraries(plutil PRIVATE
2323
Foundation)
2424

2525
set_target_properties(plutil PROPERTIES
26-
INSTALL_RPATH "$ORIGIN/../lib/swift/${SwiftFoundation_PLATFORM}")
26+
INSTALL_RPATH "$ORIGIN/../lib/swift/${SwiftFoundation_PLATFORM}$<$<BOOL:${SwiftFoundation_INSTALL_ARCH_SUBDIR}>:/${SwiftFoundation_ARCH}>")
2727

2828
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS plutil)
2929
install(TARGETS plutil

cmake/modules/FoundationSwiftSupport.cmake

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,16 @@ if(NOT SwiftFoundation_MODULE_TRIPLE)
2929
endif()
3030

3131
if(NOT SwiftFoundation_ARCH)
32-
if(CMAKE_Swift_COMPILER_VERSION VERSION_EQUAL 0.0.0 OR CMAKE_Swift_COMPILER_VERSION VERSION_GREATER_EQUAL 6.2)
33-
# For newer compilers, we can use the -print-target-info command to get the architecture.
34-
string(JSON module_arch GET "${target_info_json}" "target" "arch")
35-
else()
36-
# For older compilers, extract the value from `SwiftFoundation_MODULE_TRIPLE`.
37-
string(REGEX MATCH "^[^-]+" module_arch "${SwiftFoundation_MODULE_TRIPLE}")
38-
endif()
39-
32+
# Use the -print-target-info command to get the architecture.
33+
string(JSON module_arch GET "${target_info_json}" "target" "arch")
4034
set(SwiftFoundation_ARCH "${module_arch}" CACHE STRING "Arch folder name used to install libraries")
4135
mark_as_advanced(SwiftFoundation_ARCH)
4236
message(CONFIGURE_LOG "Swift arch: ${SwiftFoundation_ARCH}")
4337
endif()
4438

4539
if(NOT SwiftFoundation_PLATFORM)
46-
if(CMAKE_Swift_COMPILER_VERSION VERSION_EQUAL 0.0.0 OR CMAKE_Swift_COMPILER_VERSION VERSION_GREATER_EQUAL 6.2)
47-
# For newer compilers, we can use the -print-target-info command to get the platform.
48-
string(JSON swift_platform GET "${target_info_json}" "target" "platform")
49-
else()
50-
# For older compilers, compile the value from `CMAKE_SYSTEM_NAME`.
51-
if(APPLE)
52-
set(swift_platform macosx)
53-
else()
54-
set(swift_platform "$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>")
55-
endif()
56-
endif()
57-
40+
# Use the -print-target-info command to get the platform.
41+
string(JSON swift_platform GET "${target_info_json}" "target" "platform")
5842
set(SwiftFoundation_PLATFORM "${swift_platform}" CACHE STRING "Platform folder name used to install libraries")
5943
mark_as_advanced(SwiftFoundation_PLATFORM)
6044
message(CONFIGURE_LOG "Swift platform: ${SwiftFoundation_PLATFORM}")

0 commit comments

Comments
 (0)