From: Kefu Chai Date: Fri, 30 Aug 2019 08:21:03 +0000 (+0800) Subject: cmake: SKIP_RPATH if RPATH is not necessary X-Git-Tag: v14.2.22~22^2~4^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=80e36d12b90575d9d311be10d7f0f4a2bed6673d;p=ceph.git cmake: SKIP_RPATH if RPATH is not necessary some executables like ceph_test_mon_memory_target do not link against libraries built from source tree, like librados and libceph-common. so cmake does not set RPATH for them. hence cmake complains like: before this change, `CMAKE_INSTALL_RPATH` is set globally. so cmake is asked to rewrite the RPATH for all installed targets. but this is not needed. as some executables do not link against libceph-common. hence, cmake complains when installing them, like: CMake Error at src/test/mon/cmake_install.cmake:90 (file): file RPATH_CHANGE could not write new RPATH: /usr/lib64/ceph to the file: /home/abuild/rpmbuild/BUILDROOT/ceph-15.0.0-4347.g85a07b9.x86_64/usr/bin/ceph_test_log_rss_usage No valid ELF RPATH or RUNPATH entry exists in the file; after this change, `SKIP_RPATH` is set for those executables which do not link against any libraries created from ceph source tree. so we can avoid setting the RPATH for these executables when `make install`. the same applies to libceph-common. Fixes: https://tracker.ceph.com/issues/41524 Signed-off-by: Kefu Chai (cherry picked from commit 61708155b4d9d211b7da21aed8ccfe4c8ed3d932) --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 93a5290331cc5..ed4bbc75d44d6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -401,7 +401,7 @@ target_link_libraries(ceph-common ${ceph_common_deps}) # appease dpkg-shlibdeps set_target_properties(ceph-common PROPERTIES SOVERSION 0 - INSTALL_RPATH "") + SKIP_RPATH TRUE) if(NOT APPLE AND NOT FREEBSD) # Apple uses Mach-O, not ELF. so this option does not apply to APPLE. # diff --git a/src/test/mon/CMakeLists.txt b/src/test/mon/CMakeLists.txt index 4c8244a83abe3..1dfa017509919 100644 --- a/src/test/mon/CMakeLists.txt +++ b/src/test/mon/CMakeLists.txt @@ -51,17 +51,23 @@ target_link_libraries(unittest_mon_montypes mon global) add_executable(ceph_test_mon_memory_target test_mon_memory_target.cc) target_link_libraries(ceph_test_mon_memory_target Boost::system Threads::Threads) +set_target_properties(ceph_test_mon_memory_target PROPERTIES + SKIP_RPATH TRUE) install(TARGETS ceph_test_mon_memory_target DESTINATION ${CMAKE_INSTALL_BINDIR}) # ceph_test_mon_log_rss_usage add_executable(ceph_test_log_rss_usage test_log_rss_usage.cc) +set_target_properties(ceph_test_log_rss_usage PROPERTIES + SKIP_RPATH TRUE) install(TARGETS ceph_test_log_rss_usage DESTINATION ${CMAKE_INSTALL_BINDIR}) # ceph_test_mon_rss_usage add_executable(ceph_test_mon_rss_usage test_mon_rss_usage.cc) +set_target_properties(ceph_test_mon_rss_usage PROPERTIES + SKIP_RPATH TRUE) install(TARGETS ceph_test_mon_rss_usage DESTINATION ${CMAKE_INSTALL_BINDIR})