-
Notifications
You must be signed in to change notification settings - Fork 100
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
Configure CMake build to install content into toolchain #581
Conversation
0d05234
to
a0b2146
Compare
35786c8
to
5e09d09
Compare
@swift-ci Please test |
@swift-ci Please test |
@@ -97,16 +97,9 @@ target_link_libraries(Testing PRIVATE | |||
add_dependencies(Testing | |||
TestingMacros) | |||
target_compile_options(Testing PRIVATE | |||
-enable-library-evolution) | |||
-enable-library-evolution | |||
-emit-module-interface -emit-module-interface-path $<TARGET_PROPERTY:Testing,Swift_MODULE_DIRECTORY>/Testing.swiftinterface) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to stop emitting .swiftinterface
unless it's macOS because .swiftinterface
is not installed and useless.
(Should we stop -enable-library-evolution
too?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need -enable-library-evolution
to avoid folks directly linking our C++ module?
Sources/CMakeLists.txt
Outdated
# TestingMacros uses `ExternalProject` and we cannot directly query the | ||
# properties of its targets here. | ||
if(NOT SwiftTesting_BuildMacrosAsExecutables) | ||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these not be checking CMAKE_HOST_SYSTEM_NAME
?
target_link_options(TestingMacros PRIVATE "-no-toolchain-stdlib-rpath") | ||
# Not setting RPATH means it requires all the dependencies are already loaded | ||
# in the process, because 'plugin' directory wouldn't contain any dependencies. | ||
set_property(TARGET TestingMacros PROPERTY INSTALL_RPATH) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use set_target_properties
to avoid calling the function twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to unset a property using set_target_properties
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it critical to change it? Or just an efficiency thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Efficiency and stylistic thing I think. I believe this also work,
set_target_properties(TestingMacros PROPERTIES
INSTALL_RPATH ""
BUILD_WITH_INSTALL_RPATH YES)
but I just wanted to clear the property. tbh, I'm not sure which is more correct. Explicit empty list (""
) or clearing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you can do both with set_property
set_property(TARGET TestingMacros
PROPERTY INSTALL_RPATH
PROPERTY BUILD_WITH_INSTALL_RPATH YES)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, are you sure? I don't think this handles multiple PROPERTY
pairs
https://github.com/Kitware/CMake/blob/5e734dd25a466d8f6e328bf6fc49bc44a4c4c480/Source/cmSetPropertyCommand.cxx#L387
@swift-ci Please test |
Add `SwiftTesting_MACRO` configuration option: * By default, the plugin is built using `SwiftTesting_MACRO_*` options * If it's explicitly "NO" (or other 'false' value), build Testing library without using the plugin * Otherwise, use the passed-in value as the plugin path Update macOS install location to 'usr/lib/swift/testing' for libraries, and 'usr/lib/host/plugins/testing' for plugin. Correct the install RPATH.
@swift-ci Please test |
@swift-ci Please test |
set(SwiftTesting_MACRO_Swift_COMPILER ${CMAKE_Swift_COMPILER}) | ||
endif() | ||
if(NOT SwiftTesting_MACRO_Swift_FLAGS) | ||
set(SwiftTesting_MACRO_Swift_FLAGS ${CMAKE_Swift_FLAGS}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What flags are you hoping to pull here?
This seems risky given that these flags might be for an entirely different machine than the one the macros will build for/run on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually a leftover from when I was trying around. Let me remove this as a followup.
target_link_options(TestingMacros PRIVATE "-no-toolchain-stdlib-rpath") | ||
# Not setting RPATH means it requires all the dependencies are already loaded | ||
# in the process, because 'plugin' directory wouldn't contain any dependencies. | ||
set_property(TARGET TestingMacros PROPERTY INSTALL_RPATH) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you can do both with set_property
set_property(TARGET TestingMacros
PROPERTY INSTALL_RPATH
PROPERTY BUILD_WITH_INSTALL_RPATH YES)
(Supersedes #531)
This includes several changes to the CMake rules to support installing built content into a toolchain.
Motivation:
This is necessary to support including swift-testing in Swift 6 toolchains.
Checklist: