diff options
author | Ruslan Baratov <ruslan_baratov@yahoo.com> | 2016-09-30 23:30:57 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-10-03 17:42:27 (GMT) |
commit | dc6d8066607435a0d4b6338bc53e0b1ac746bd35 (patch) | |
tree | bd3368be75c92bc776ba126c984c98e5abd07436 /Tests/MacRuntimePath | |
parent | 484dc1e5d85f4f468e27816eab0fccc9c7d6ec11 (diff) | |
download | CMake-dc6d8066607435a0d4b6338bc53e0b1ac746bd35.zip CMake-dc6d8066607435a0d4b6338bc53e0b1ac746bd35.tar.gz CMake-dc6d8066607435a0d4b6338bc53e0b1ac746bd35.tar.bz2 |
Add a BUILD_RPATH target property specifying build-tree RPATH entries
Users may need to add custom `RPATH` entries to be able to run binaries
from their build tree without setting `LD_LIBRARY_PATH`. Provide a way
to do this that does not affect the install-tree `RPATH`.
Diffstat (limited to 'Tests/MacRuntimePath')
-rw-r--r-- | Tests/MacRuntimePath/A/CMakeLists.txt | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Tests/MacRuntimePath/A/CMakeLists.txt b/Tests/MacRuntimePath/A/CMakeLists.txt index ade0a3c..bf937e6 100644 --- a/Tests/MacRuntimePath/A/CMakeLists.txt +++ b/Tests/MacRuntimePath/A/CMakeLists.txt @@ -40,21 +40,30 @@ target_link_libraries(test3 framework) add_executable(test4 test1.cpp) target_link_libraries(test4 shared2) +# executable to test a shared library dependency with build rpath +add_executable(test5 test1.cpp) + +# avoid linking by 'target_link_libraries' so CMake +# will not be able to set correct RPATH automatically +add_dependencies(test5 shared) +target_link_libraries(test5 "$<TARGET_FILE:shared>") +set_target_properties(test5 PROPERTIES BUILD_RPATH "@loader_path/../lib") + set_target_properties(shared shared2 framework PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") -set_target_properties(test1 test2 test3 test4 PROPERTIES +set_target_properties(test1 test2 test3 test4 test5 PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") foreach(config ${CMAKE_CONFIGURATION_TYPES}) string(TOUPPER ${config} CONFIG) set_target_properties(shared shared2 framework PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${CONFIG} "${CMAKE_CURRENT_BINARY_DIR}/${config}/lib") - set_target_properties(test1 test2 test3 test4 PROPERTIES + set_target_properties(test1 test2 test3 test4 test5 PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${CONFIG} "${CMAKE_CURRENT_BINARY_DIR}/${config}/bin") endforeach() -foreach(test test1 test2 test3 test4) +foreach(test test1 test2 test3 test4 test5) add_custom_target(${test}_run ALL COMMAND ${test} DEPENDS ${test} |