Skip to content

Commit 54c20a3

Browse files
authored
Merge pull request #619 from artemcm/WorkaroundOlderCMake
Add workaround for building executables with older CMake versions.
2 parents 391204e + 444d48f commit 54c20a3

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Sources/swift-driver/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,18 @@ target_link_libraries(swift-driver PUBLIC
1212
SwiftDriver
1313
SwiftDriverExecution)
1414

15+
# This is a fairly egregious workaround for the fact that in versions < 3.17,
16+
# executables do not get `-rpath` linker arguments for their linked library
17+
# dependencies (direct and transitive)
18+
if(CMAKE_VERSION VERSION_LESS 3.17)
19+
get_target_property(TSC_UTIL_LIB TSCUtility LOCATION)
20+
get_filename_component(TSC_LIB_DIR ${TSC_UTIL_LIB} DIRECTORY)
1521

22+
get_target_property(LLBUILD_LIB llbuildSwift LOCATION)
23+
get_filename_component(LLBUILD_LIB_DIR ${LLBUILD_LIB} DIRECTORY)
24+
25+
get_target_property(ARGPARSE_LIB ArgumentParser LOCATION)
26+
get_filename_component(ARGPARSE_LIB_DIR ${ARGPARSE_LIB} DIRECTORY)
27+
28+
target_link_options(swift-driver PUBLIC "LINKER:-rpath,${CMAKE_LIBRARY_OUTPUT_DIRECTORY},-rpath,${TSC_LIB_DIR},-rpath,${LLBUILD_LIB_DIR},-rpath,${ARGPARSE_LIB_DIR}")
29+
endif()

Sources/swift-help/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,15 @@ target_link_libraries(swift-help PUBLIC
1313
ArgumentParser
1414
TSCBasic)
1515

16+
# This is a fairly egregious workaround for the fact that in versions < 3.17,
17+
# executables do not get `-rpath` linker arguments for their linked library
18+
# dependencies (direct and transitive)
19+
if(CMAKE_VERSION VERSION_LESS 3.17)
20+
get_target_property(TSC_UTIL_LIB TSCUtility LOCATION)
21+
get_filename_component(TSC_LIB_DIR ${TSC_UTIL_LIB} DIRECTORY)
22+
23+
get_target_property(ARGPARSE_LIB ArgumentParser LOCATION)
24+
get_filename_component(ARGPARSE_LIB_DIR ${ARGPARSE_LIB} DIRECTORY)
25+
26+
target_link_options(swift-help PUBLIC "LINKER:-rpath,${CMAKE_LIBRARY_OUTPUT_DIRECTORY},-rpath,${TSC_LIB_DIR},-rpath,${ARGPARSE_LIB_DIR}")
27+
endif()

0 commit comments

Comments
 (0)