Skip to content

[CMake/Macros] Set correct RPATH #616

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

Merged
merged 2 commits into from
Aug 17, 2024
Merged
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
11 changes: 8 additions & 3 deletions Sources/TestingMacros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,16 @@ else()
add_library(TestingMacros SHARED)

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)
set_property(TARGET TestingMacros PROPERTY BUILD_WITH_INSTALL_RPATH YES)

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(plugin_destination_dir "lib/swift/host/plugins/testing")
set_property(TARGET TestingMacros PROPERTY INSTALL_RPATH)
else()
set(plugin_destination_dir "lib/swift/host/plugins")
# RPATH 'lib/swift/{system}' and 'lib/swift/host'
set_property(TARGET TestingMacros PROPERTY
INSTALL_RPATH "$ORIGIN/../../<LOWER_CASE:${CMAKE_SYSTEM_NAME}>;$ORIGIN/..")
endif()

install(TARGETS TestingMacros
Expand Down Expand Up @@ -103,6 +104,10 @@ target_sources(TestingMacros PRIVATE
TestDeclarationMacro.swift
TestingMacrosMain.swift)

target_compile_options(TestingMacros PRIVATE
"SHELL:-Xfrontend -disable-implicit-string-processing-module-import"
"SHELL:-Xfrontend -disable-implicit-backtracing-module-import")

target_link_libraries(TestingMacros PRIVATE
SwiftSyntax::SwiftSyntax
SwiftSyntax::SwiftSyntaxMacroExpansion
Expand Down