[PATCH] D24184: [CMake] Use CMake's default RPATH for the unit tests

Diana Picus via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 2 05:49:31 PDT 2016

rovka created this revision.
rovka added a reviewer: beanz.
rovka added a subscriber: llvm-commits.

In the top-level CMakeLists.txt, we set CMAKE_BUILD_WITH_INSTALL_RPATH to ON,
and then for the unit tests we set it to <test>/../../lib. This works for tests
that live in unittest/<whatever>, but not for those that live in subdirectories
e.g. unittest/Transforms/IPO or unittest/ExecutionEngine/Orc. When building
with BUILD_SHARED_LIBRARIES, such tests don't manage to find their libraries and
are consequently not run (due to a bug in LIT, this isn't even reported!).

Since the tests are run from the build directory, it makes sense to set their
RPATH for the build tree, rather than the install tree. This is the default in
CMake since 2.6, so all we have to do is set CMAKE_BUILD_WITH_INSTALL_RPATH to
OFF for the unit tests.



Index: unittests/CMakeLists.txt
--- unittests/CMakeLists.txt
+++ unittests/CMakeLists.txt
@@ -1,11 +1,9 @@
 set_target_properties(UnitTests PROPERTIES FOLDER "Tests")
-if (APPLE)
-  set(CMAKE_INSTALL_RPATH "@executable_path/../../lib")
+# People tend to run the tests _before_ installing, so we don't want the install
+# rpath here.
 function(add_llvm_unittest test_dirname)
   add_unittest(UnitTests ${test_dirname} ${ARGN})

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24184.70146.patch
Type: text/x-patch
Size: 660 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160902/4451d135/attachment.bin>

More information about the llvm-commits mailing list