Skip to content

Commit 066dc94

Browse files
authored
Merge pull request #78860 from etcwilde/ewilde/stdlib-rebuild-platform-arch-dirs
CMake: Add install platform and architecture subdirs
2 parents 674c762 + a9da4a5 commit 066dc94

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

Runtimes/Core/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ option(SwiftCore_ENABLE_INTERNAL_CHECKS "" OFF)
113113
defaulted_set(SwiftCore_OBJECT_FORMAT STRING "Object format: ELF COFF")
114114
defaulted_set(SwiftCore_THREADING_PACKAGE STRING "Threading Package: C11 Linux PThreads Win32")
115115

116+
option(SwiftCore_INSTALL_NESTED_SUBDIR "Install libraries under a platform and architecture subdirectory" ON)
117+
set(SwiftCore_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>$<$<BOOL:${SwiftCore_INSTALL_NESTED_SUBDIR}>:/${SwiftCore_PLATFORM_SUBDIR}/${SwiftCore_ARCH_SUBDIR}>")
118+
set(SwiftCore_INSTALL_SWIFTMODULEDIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>$<$<BOOL:${SwiftCore_INSTALL_NESTED_SUBDIR}>:/${SwiftCore_PLATFORM_SUBDIR}>")
119+
116120
# TODO: Most of these should be attached to specific targets rather than applied
117121
# globally. They can be applied as part of the library interface if they
118122
# affect the behavior of libraries that build against a given target.

Runtimes/Core/cmake/caches/Vendors/Apple/apple-common.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ set(SwiftCore_ENABLE_RUNTIME_FUNCTION_COUNTERS ON CACHE BOOL "")
1313
set(SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT ON CACHE BOOL "")
1414
set(SwiftCore_ENABLE_FILESYSTEM_SUPPORT ON CACHE BOOL "")
1515

16+
set(SwiftCore_INSTALL_NESTED_SUBDIR OFF CACHE BOOL "")
17+
1618
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -g -DNDEBUG" CACHE STRING "")
1719
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -g -DNDEBUG" CACHE STRING "")
1820
set(CMAKE_Swift_FLAGS_MINSIZEREL "-Osize -g" CACHE STRING "")

Runtimes/Core/cmake/modules/EmitSwiftInterface.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ function(install_swift_interface target)
2121
if(SwiftCore_ENABLE_LIBRARY_EVOLUTION)
2222
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_PROPERTY:${target},Swift_MODULE_NAME>.swiftinterface"
2323
RENAME "${SwiftCore_MODULE_TRIPLE}.swiftinterface"
24-
DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/$<TARGET_PROPERTY:${target},Swift_MODULE_NAME>.swiftmodule")
24+
DESTINATION "${SwiftCore_INSTALL_SWIFTMODULEDIR}/$<TARGET_PROPERTY:${target},Swift_MODULE_NAME>.swiftmodule")
2525

2626
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_PROPERTY:${target},Swift_MODULE_NAME>.private.swiftinterface"
2727
RENAME "${SwiftCore_MODULE_TRIPLE}.private.swiftinterface"
28-
DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/$<TARGET_PROPERTY:${target},Swift_MODULE_NAME>.swiftmodule")
28+
DESTINATION "${SwiftCore_INSTALL_SWIFTMODULEDIR}/$<TARGET_PROPERTY:${target},Swift_MODULE_NAME>.swiftmodule")
2929
endif()
3030
endfunction()

Runtimes/Core/core/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,12 @@ elseif(NOT APPLE AND NOT LINUX AND NOT ANDROID AND UNIX)
326326
target_link_libraries(swiftCore PRIVATE "${EXECINFO_LIBRARY}")
327327
endif()
328328

329-
install(TARGETS swiftCore)
329+
install(TARGETS swiftCore
330+
ARCHIVE DESTINATION "${SwiftCore_INSTALL_LIBDIR}"
331+
LIBRARY DESTINATION "${SwiftCore_INSTALL_LIBDIR}"
332+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
330333
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Swift.swiftmodule"
331-
DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/Swift.swiftmodule"
334+
DESTINATION "${SwiftCore_INSTALL_SWIFTMODULEDIR}/Swift.swiftmodule"
332335
RENAME "${SwiftCore_MODULE_TRIPLE}.swiftmodule")
333336
emit_swift_interface(swiftCore)
334337
install_swift_interface(swiftCore)

Runtimes/Core/runtime/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ if("${SwiftCore_OBJECT_FORMAT}" STREQUAL "elfx")
151151
"${SwiftCore_SWIFTC_SOURCE_DIR}/include"
152152
"${PROJECT_BINARY_DIR}/include")
153153
target_link_libraries(swiftrt PRIVATE swiftShims)
154+
# The driver requires that swifrt.o is under `usr/lib/swift/<platform>/<arch>`
155+
# Regardless of settings
154156
install(FILES $<TARGET_OBJECTS:swiftrt>
155157
DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/${SwiftCore_PLATFORM_SUBDIR}/${SwiftCore_ARCH_SUBDIR}"
156158
RENAME swiftrt.o)
@@ -160,6 +162,8 @@ elseif("${SwiftCore_OBJECT_FORMAT}" STREQUAL "coffx")
160162
$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:SWIFT_STATIC_STDLIB>)
161163
target_link_libraries(swiftrt PRIVATE swiftShims)
162164
install(FILES $<TARGET_OBJECTS:swiftrt>
165+
# The driver requires that swifrt.obj is under `usr/lib/swift/<platform>/<arch>`
166+
# Regardless of settings
163167
DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/${SwiftCore_PLATFORM_SUBDIR}/${SwiftCore_ARCH_SUBDIR}"
164168
RENAME swiftrt.obj)
165169
elseif(NOT "${SwiftCore_OBJECT_FORMAT}" STREQUAL "x")

0 commit comments

Comments
 (0)