cmake: fix INSTALL_RPATH
authorMichael Wallner <mike@php.net>
Mon, 14 Sep 2020 09:01:28 +0000 (11:01 +0200)
committerMichael Wallner <mike@php.net>
Mon, 14 Sep 2020 09:05:39 +0000 (11:05 +0200)
src/bin/CMakeLists.txt
src/libhashkit/CMakeLists.txt
src/libmemcached/CMakeLists.txt
src/libmemcachedprotocol/CMakeLists.txt
src/libmemcachedutil/CMakeLists.txt

index a568dd1c20a9142c3d26ecfa7630cac9fcc31e48..ee771891d7352ea7d15e9f1e064c73d48dff41ce 100644 (file)
@@ -13,7 +13,8 @@ target_include_directories(libclient_utilities PUBLIC
 foreach(CLIENT IN LISTS CLIENTS)
     add_executable(${CLIENT} ${CLIENT}.cc)
     target_include_directories(${CLIENT} PRIVATE ..)
-    target_link_libraries(${CLIENT} libclient_utilities)
+    target_link_libraries(${CLIENT} PRIVATE libclient_utilities)
+    set_target_properties(${CLIENT} PROPERTIES INSTALL_RPATH $ORIGIN/../${CMAKE_INSTALL_LIBDIR})
     install(TARGETS ${CLIENT}
             RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endforeach()
@@ -24,9 +25,9 @@ target_sources(memcapable PRIVATE ../libmemcached/byteorder.cc)
 
 # extra libs
 
-target_link_libraries(memcapable Threads::Threads)
-target_link_libraries(memping libmemcachedutil)
-target_link_libraries(memslap Threads::Threads)
+target_link_libraries(memcapable PRIVATE Threads::Threads)
+target_link_libraries(memping PRIVATE libmemcachedutil)
+target_link_libraries(memslap PRIVATE Threads::Threads)
 
 # memaslap is special
 
@@ -35,7 +36,7 @@ if(ENABLE_MEMASLAP)
         add_executable(memaslap memaslap.c
                 ms_conn.c ms_setting.c ms_sigsegv.c ms_stats.c ms_task.c ms_thread.c)
         target_include_directories(memaslap PRIVATE ${LIBEVENT_INCLUDEDIR})
-        target_link_libraries(memaslap libclient_utilities ${LIBEVENT_LIBRARIES} Threads::Threads)
+        target_link_libraries(memaslap PRIVATE libclient_utilities ${LIBEVENT_LIBRARIES} Threads::Threads)
         install(TARGETS memaslap
                 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
     endif()
index a75e08e7a6095cdc5ffdaac1bb9919aec89ded9c..f4657b6152a518ecf049ed74aabe1d9f027da19b 100644 (file)
@@ -31,7 +31,11 @@ add_library(libhashkit SHARED
         string.cc
         )
 add_library(hashkit ALIAS libhashkit)
-set_target_properties(libhashkit PROPERTIES LIBRARY_OUTPUT_NAME hashkit)
+set_target_properties(libhashkit PROPERTIES
+        LIBRARY_OUTPUT_NAME hashkit
+        INSTALL_RPATH $ORIGIN
+        SOVERSION ${LIBHASHKIT_SO_VERSION}
+        VERSION v${LIBHASHKIT_VERSION})
 target_compile_options(libhashkit PRIVATE -DBUILDING_HASHKIT)
 target_include_directories(libhashkit PRIVATE
         ${CMAKE_SOURCE_DIR}/src
@@ -43,7 +47,6 @@ target_include_directories(libhashkit PUBLIC
         $<INSTALL_INTERFACE:include>)
 configure_file(hashkitcon.h.in hashkitcon.h @ONLY)
 
-set_target_properties(libhashkit PROPERTIES SOVERSION ${LIBHASHKIT_SO_VERSION})
 install(TARGETS libhashkit EXPORT libhashkit
         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
 export(EXPORT libhashkit)
index 96338c9b84a5b613406722f27fda40bcf52462d5..ff8993d0e8d16ff0c75cbb2716e31f589b44116e 100644 (file)
@@ -89,7 +89,11 @@ set(LIBMEMCACHED_SOURCES
 add_library(libmemcached SHARED
         ${LIBMEMCACHED_SOURCES})
 add_library(memcached ALIAS libmemcached)
-set_target_properties(libmemcached PROPERTIES LIBRARY_OUTPUT_NAME memcached)
+set_target_properties(libmemcached PROPERTIES
+        LIBRARY_OUTPUT_NAME memcached
+        INSTALL_RPATH $ORIGIN
+        SOVERSION ${LIBMEMCACHED_SO_VERSION}
+        VERSION v${LIBMEMCACHED_VERSION})
 target_compile_definitions(libmemcached PRIVATE -DBUILDING_LIBMEMCACHED)
 target_link_libraries(libmemcached PUBLIC libhashkit Threads::Threads ${LIBSASL_LIBRARIES} ${CMAKE_DL_LIBS})
 target_include_directories(libmemcached PRIVATE ${LIBSASL_INCLUDEDIR})
@@ -102,7 +106,6 @@ target_include_directories(libmemcached PUBLIC
         $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
         $<INSTALL_INTERFACE:include>)
 
-set_target_properties(libmemcached PROPERTIES SOVERSION ${LIBMEMCACHED_SO_VERSION})
 install(TARGETS libmemcached EXPORT libmemcached
         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
 export(EXPORT libmemcached)
index a826e0aa12e1399b11589c5cab1ce37d07297610..7080bd9e6dcddc0a1078376a0aaa1c57e2d12d78 100644 (file)
@@ -8,7 +8,11 @@ add_library(libmemcachedprotocol SHARED
         pedantic.c
         )
 add_library(memcachedprotocol ALIAS libmemcachedprotocol)
-set_target_properties(libmemcachedprotocol PROPERTIES LIBRARY_OUTPUT_NAME memcachedprotocol)
+set_target_properties(libmemcachedprotocol PROPERTIES
+        LIBRARY_OUTPUT_NAME memcachedprotocol
+        INSTALL_RPATH $ORIGIN
+        SOVERSION ${LIBMEMCACHEDPROTOCOL_SO_VERSION}
+        VERSION v${LIBMEMCACHEDPROTOCOL_VERSION})
 target_compile_definitions(libmemcachedprotocol PRIVATE -DBUILDING_LIBMEMCACHED)
 target_link_libraries(libmemcachedprotocol PUBLIC libmemcached Threads::Threads)
 target_include_directories(libmemcachedprotocol PRIVATE
@@ -20,7 +24,6 @@ target_include_directories(libmemcachedprotocol PUBLIC
         $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
         $<INSTALL_INTERFACE:include>)
 
-set_target_properties(libmemcachedprotocol PROPERTIES SOVERSION ${LIBMEMCACHEDPROTOCOL_SO_VERSION})
 install(TARGETS libmemcachedprotocol EXPORT libmemcachedprotocol
         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
 export(EXPORT libmemcachedprotocol)
index d087d63d19caa8c6be34a42c23014ae09234a726..cb281c3be8191af1be1f4a8dd306e405ec4639cc 100644 (file)
@@ -9,7 +9,11 @@ add_library(libmemcachedutil SHARED
         version.cc
         )
 add_library(memcachedutil ALIAS libmemcachedutil)
-set_target_properties(libmemcachedutil PROPERTIES LIBRARY_OUTPUT_NAME memcachedutil)
+set_target_properties(libmemcachedutil PROPERTIES
+        LIBRARY_OUTPUT_NAME memcachedutil
+        INSTALL_RPATH $ORIGIN
+        SOVERSION ${LIBMEMCACHEDUTIL_SO_VERSION}
+        VERSION v${LIBMEMCACHEDUTIL_VERSION})
 target_compile_definitions(libmemcachedutil PRIVATE -DBUILDING_LIBMEMCACHED)
 target_link_libraries(libmemcachedutil PUBLIC libmemcached Threads::Threads)
 target_include_directories(libmemcachedutil PRIVATE
@@ -21,7 +25,6 @@ target_include_directories(libmemcachedutil PUBLIC
         $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
         $<INSTALL_INTERFACE:include>)
 
-set_target_properties(libmemcachedutil PROPERTIES SOVERSION ${LIBMEMCACHEDUTIL_SO_VERSION})
 install(TARGETS libmemcachedutil EXPORT libmemcachedutil
         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
 export(EXPORT libmemcachedutil)