Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: Add install platform and architecture subdirs #78860

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Runtimes/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ option(SwiftCore_ENABLE_INTERNAL_CHECKS "" OFF)
defaulted_set(SwiftCore_OBJECT_FORMAT STRING "Object format: ELF COFF")
defaulted_set(SwiftCore_THREADING_PACKAGE STRING "Threading Package: C11 Linux PThreads Win32")

option(SwiftCore_INSTALL_NESTED_SUBDIR "Install libraries under a platform and architecture subdirectory" ON)
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}>")
set(SwiftCore_INSTALL_SWIFTMODULEDIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>$<$<BOOL:${SwiftCore_INSTALL_NESTED_SUBDIR}>:/${SwiftCore_PLATFORM_SUBDIR}>")

# TODO: Most of these should be attached to specific targets rather than applied
# globally. They can be applied as part of the library interface if they
# affect the behavior of libraries that build against a given target.
Expand Down
2 changes: 2 additions & 0 deletions Runtimes/Core/cmake/caches/Vendors/Apple/apple-common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ set(SwiftCore_ENABLE_RUNTIME_FUNCTION_COUNTERS ON CACHE BOOL "")
set(SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT ON CACHE BOOL "")
set(SwiftCore_ENABLE_FILESYSTEM_SUPPORT ON CACHE BOOL "")

set(SwiftCore_INSTALL_NESTED_SUBDIR OFF CACHE BOOL "")

set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -g -DNDEBUG" CACHE STRING "")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -g -DNDEBUG" CACHE STRING "")
set(CMAKE_Swift_FLAGS_MINSIZEREL "-Osize -g" CACHE STRING "")
4 changes: 2 additions & 2 deletions Runtimes/Core/cmake/modules/EmitSwiftInterface.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ function(install_swift_interface target)
if(SwiftCore_ENABLE_LIBRARY_EVOLUTION)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_PROPERTY:${target},Swift_MODULE_NAME>.swiftinterface"
RENAME "${SwiftCore_MODULE_TRIPLE}.swiftinterface"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/$<TARGET_PROPERTY:${target},Swift_MODULE_NAME>.swiftmodule")
DESTINATION "${SwiftCore_INSTALL_SWIFTMODULEDIR}/$<TARGET_PROPERTY:${target},Swift_MODULE_NAME>.swiftmodule")

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_PROPERTY:${target},Swift_MODULE_NAME>.private.swiftinterface"
RENAME "${SwiftCore_MODULE_TRIPLE}.private.swiftinterface"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/$<TARGET_PROPERTY:${target},Swift_MODULE_NAME>.swiftmodule")
DESTINATION "${SwiftCore_INSTALL_SWIFTMODULEDIR}/$<TARGET_PROPERTY:${target},Swift_MODULE_NAME>.swiftmodule")
endif()
endfunction()
7 changes: 5 additions & 2 deletions Runtimes/Core/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,12 @@ elseif(NOT APPLE AND NOT LINUX AND NOT ANDROID AND UNIX)
target_link_libraries(swiftCore PRIVATE "${EXECINFO_LIBRARY}")
endif()

install(TARGETS swiftCore)
install(TARGETS swiftCore
ARCHIVE DESTINATION "${SwiftCore_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${SwiftCore_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Swift.swiftmodule"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/Swift.swiftmodule"
DESTINATION "${SwiftCore_INSTALL_SWIFTMODULEDIR}/Swift.swiftmodule"
RENAME "${SwiftCore_MODULE_TRIPLE}.swiftmodule")
emit_swift_interface(swiftCore)
install_swift_interface(swiftCore)
Expand Down
4 changes: 4 additions & 0 deletions Runtimes/Core/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ if("${SwiftCore_OBJECT_FORMAT}" STREQUAL "elfx")
"${SwiftCore_SWIFTC_SOURCE_DIR}/include"
"${PROJECT_BINARY_DIR}/include")
target_link_libraries(swiftrt PRIVATE swiftShims)
# The driver requires that swifrt.o is under `usr/lib/swift/<platform>/<arch>`
# Regardless of settings
install(FILES $<TARGET_OBJECTS:swiftrt>
DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/${SwiftCore_PLATFORM_SUBDIR}/${SwiftCore_ARCH_SUBDIR}"
RENAME swiftrt.o)
Expand All @@ -158,6 +160,8 @@ elseif("${SwiftCore_OBJECT_FORMAT}" STREQUAL "coffx")
$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:SWIFT_STATIC_STDLIB>)
target_link_libraries(swiftrt PRIVATE swiftShims)
install(FILES $<TARGET_OBJECTS:swiftrt>
# The driver requires that swifrt.obj is under `usr/lib/swift/<platform>/<arch>`
# Regardless of settings
DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/${SwiftCore_PLATFORM_SUBDIR}/${SwiftCore_ARCH_SUBDIR}"
RENAME swiftrt.obj)
elseif(NOT "${SwiftCore_OBJECT_FORMAT}" STREQUAL "x")
Expand Down