Skip to content

Commit 8e80abf

Browse files
committed
swift-syntax-parser-tool: tweak the build rules
Adjust the build rules to add a build RPATH into the executable to ensure that `lib_InternalSwiftSyntaxParser.so` is properly found when running the tests. This also should ensure that we always use the correct version, irrespective of the setting of `LD_LIBRARY_PATH`. This RPATH is marked as a `BUILD_RPATH` and will be stripped if the tool is installed. Adjust the dependencies to be clearer using generator expressions and use the `target_compile_options` rather than the more fragile `set_target_properties` to add `-fblocks` to the compilation. This is now possible as we are ensured that we are using CMake 3.15+.
1 parent 0395920 commit 8e80abf

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

tools/swift-syntax-parser-test/CMakeLists.txt

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,21 @@ add_swift_host_tool(swift-syntax-parser-test
77
Support
88
SWIFT_COMPONENT tools
99
)
10-
if(NOT SWIFT_BUILT_STANDALONE AND NOT CMAKE_C_COMPILER_ID MATCHES Clang)
11-
add_dependencies(swift-syntax-parser-test clang)
12-
endif()
13-
target_link_libraries(swift-syntax-parser-test
14-
PRIVATE
15-
libSwiftSyntaxParser
16-
)
17-
1810
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
1911
set_target_properties(swift-syntax-parser-test PROPERTIES
2012
BUILD_WITH_INSTALL_RPATH YES
2113
INSTALL_RPATH @executable_path/../lib)
14+
elseif(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
15+
set_target_properties(swift-syntax-parser-test PROPERTIES
16+
BUILD_WITH_INSTALL_RPATH YES
17+
INSTALL_RPATH ${SWIFT_LIBRARY_OUTPUT_INTDIR})
2218
endif()
19+
target_compile_options(swift-syntax-parser-test PRIVATE
20+
-fblocks)
21+
target_link_libraries(swift-syntax-parser-test PRIVATE
22+
$<$<NOT:$<PLATFORM_ID:Darwin>>:BlocksRuntime>
23+
libSwiftSyntaxParser)
2324

24-
set_property(TARGET swift-syntax-parser-test APPEND_STRING PROPERTY
25-
COMPILE_FLAGS " -fblocks")
26-
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
27-
target_link_libraries(swift-syntax-parser-test PRIVATE
28-
BlocksRuntime)
25+
if(NOT SWIFT_BUILT_STANDALONE AND NOT CMAKE_C_COMPILER_ID MATCHES Clang)
26+
add_dependencies(swift-syntax-parser-test clang)
2927
endif()

0 commit comments

Comments
 (0)