Files
swift-mirror/tools/swift-syntax-parser-test/CMakeLists.txt
Saleem Abdulrasool 8e80abf4a3 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+.
2020-03-13 22:38:05 +00:00

28 lines
922 B
CMake

include(SwiftWindowsSupport)
swift_swap_compiler_if_needed("SwiftSyntaxParserTest")
add_swift_host_tool(swift-syntax-parser-test
swift-syntax-parser-test.cpp
LLVM_LINK_COMPONENTS
Support
SWIFT_COMPONENT tools
)
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set_target_properties(swift-syntax-parser-test PROPERTIES
BUILD_WITH_INSTALL_RPATH YES
INSTALL_RPATH @executable_path/../lib)
elseif(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
set_target_properties(swift-syntax-parser-test PROPERTIES
BUILD_WITH_INSTALL_RPATH YES
INSTALL_RPATH ${SWIFT_LIBRARY_OUTPUT_INTDIR})
endif()
target_compile_options(swift-syntax-parser-test PRIVATE
-fblocks)
target_link_libraries(swift-syntax-parser-test PRIVATE
$<$<NOT:$<PLATFORM_ID:Darwin>>:BlocksRuntime>
libSwiftSyntaxParser)
if(NOT SWIFT_BUILT_STANDALONE AND NOT CMAKE_C_COMPILER_ID MATCHES Clang)
add_dependencies(swift-syntax-parser-test clang)
endif()