cmake: IMPORT, EXPORT and RPATH improvements
authorMichael Wallner <mike@php.net>
Tue, 15 Sep 2020 06:27:51 +0000 (08:27 +0200)
committerMichael Wallner <mike@php.net>
Tue, 15 Sep 2020 06:27:51 +0000 (08:27 +0200)
CMake/_Include.cmake
CMakeConfig.txt
src/bin/CMakeLists.txt
src/libhashkit/CMakeLists.txt
src/libmemcached/CMakeLists.txt
src/libmemcachedprotocol/CMakeLists.txt
src/libmemcachedprotocol/ascii_handler.c
src/libmemcachedprotocol/binary_handler.c
src/libmemcachedutil/CMakeLists.txt
support/CMakeLists.txt
support/libmemcached-config.cmake.in [new file with mode: 0644]

index 00da54f9a46b0012a4bc9a0cb71759ea61be09b7..3b264670934b3098aa0d1029eff5ac82e8018119 100644 (file)
@@ -3,8 +3,10 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
 # globals
 include(CTest)
 include(GNUInstallDirs)
+include(CMakePackageConfigHelpers)
 
 find_package(PkgConfig)
+set(THREADS_PREFER_PTHREAD_FLAG ON)
 find_package(Threads REQUIRED)
 
 # locals
index 41b76324d486f8c2400b4e643e399876b2443955..0d584981c27737cb9e063010a4096428342adc22 100644 (file)
@@ -3,6 +3,15 @@ set(CMAKE_BUILD_TYPE Release
 set(CMAKE_INSTALL_PREFIX /usr/local
     CACHE PATH "install prefix")
 
+if(APPLE)
+    set(CMAKE_INSTALL_RPATH @loader_path
+        CACHE STRING "set relative rpath")
+elseif(UNIX)
+    # FIXME
+    set(CMAKE_INSTALL_RPATH $ORIGIN
+        CACHE STRING "set relative rpath")
+endif()
+
 option(BUILD_TESTING        "whether to enable build of the test suite"
         OFF)
 option(BUILD_DOCSONLY       "build *only* documentation"
index ee771891d7352ea7d15e9f1e064c73d48dff41ce..5e08ac649e3a6d9543e7225a8e580907c4b1ee4d 100644 (file)
@@ -14,7 +14,10 @@ foreach(CLIENT IN LISTS CLIENTS)
     add_executable(${CLIENT} ${CLIENT}.cc)
     target_include_directories(${CLIENT} PRIVATE ..)
     target_link_libraries(${CLIENT} PRIVATE libclient_utilities)
-    set_target_properties(${CLIENT} PROPERTIES INSTALL_RPATH $ORIGIN/../${CMAKE_INSTALL_LIBDIR})
+    if(CMAKE_INSTALL_RPATH)
+        set_target_properties(${CLIENT} PROPERTIES
+                INSTALL_RPATH ${CMAKE_INSTALL_RPATH}/../${CMAKE_INSTALL_LIBDIR})
+    endif()
     install(TARGETS ${CLIENT}
             RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 endforeach()
@@ -37,6 +40,10 @@ if(ENABLE_MEMASLAP)
                 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 PRIVATE libclient_utilities ${LIBEVENT_LIBRARIES} Threads::Threads)
+        if(CMAKE_INSTALL_RPATH)
+            set_target_properties(${CLIENT} PROPERTIES
+                    INSTALL_RPATH ${CMAKE_INSTALL_RPATH}/../${CMAKE_INSTALL_LIBDIR})
+        endif()
         install(TARGETS memaslap
                 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
     endif()
index f4657b6152a518ecf049ed74aabe1d9f027da19b..ffe4026b69bf4d48e81c06bfad0e974652e48386 100644 (file)
@@ -33,7 +33,7 @@ add_library(libhashkit SHARED
 add_library(hashkit ALIAS libhashkit)
 set_target_properties(libhashkit PROPERTIES
         LIBRARY_OUTPUT_NAME hashkit
-        INSTALL_RPATH $ORIGIN
+        LIBRARY_OUTPUT_NAME_DEBUG hashkit-dbg
         SOVERSION ${LIBHASHKIT_SO_VERSION}
         VERSION v${LIBHASHKIT_VERSION})
 target_compile_options(libhashkit PRIVATE -DBUILDING_HASHKIT)
@@ -47,10 +47,10 @@ target_include_directories(libhashkit PUBLIC
         $<INSTALL_INTERFACE:include>)
 configure_file(hashkitcon.h.in hashkitcon.h @ONLY)
 
-install(TARGETS libhashkit EXPORT libhashkit
+install(TARGETS libhashkit EXPORT libhashkit-targets
         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-export(EXPORT libhashkit)
-install(EXPORT libhashkit DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
+export(EXPORT libhashkit-targets NAMESPACE libmemcached::)
+install(EXPORT libhashkit-targets NAMESPACE libmemcached:: DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
 
 install_public_headers(
         libhashkit
index ff8993d0e8d16ff0c75cbb2716e31f589b44116e..a029ac58f235a9f3f12c0ce50456cf63313f5d11 100644 (file)
@@ -11,9 +11,11 @@ bison_target(CSL_PARSER csl/parser.yy ${CMAKE_CURRENT_BINARY_DIR}/csl/parser.cc
         DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/csl/parser.h
         COMPILE_FLAGS ${BISON_WARNINGS}
         )
+set_source_files_properties(${BISON_CSL_PARSER_OUTPUTS} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
 flex_target(CSL_SCANNER csl/scanner.l ${CMAKE_CURRENT_BINARY_DIR}/csl/scanner.cc
         DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/csl/scanner.h
         )
+set_source_files_properties(${FLEX_CSL_SCANNER_OUTPUTS} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
 add_flex_bison_dependency(CSL_SCANNER CSL_PARSER)
 
 if(HAVE_DTRACE)
@@ -91,7 +93,7 @@ add_library(libmemcached SHARED
 add_library(memcached ALIAS libmemcached)
 set_target_properties(libmemcached PROPERTIES
         LIBRARY_OUTPUT_NAME memcached
-        INSTALL_RPATH $ORIGIN
+        LIBRARY_OUTPUT_NAME_DEBUG memcached-dbg
         SOVERSION ${LIBMEMCACHED_SO_VERSION}
         VERSION v${LIBMEMCACHED_VERSION})
 target_compile_definitions(libmemcached PRIVATE -DBUILDING_LIBMEMCACHED)
@@ -106,10 +108,10 @@ target_include_directories(libmemcached PUBLIC
         $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
         $<INSTALL_INTERFACE:include>)
 
-install(TARGETS libmemcached EXPORT libmemcached
+install(TARGETS libmemcached EXPORT libmemcached-targets
         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-export(EXPORT libmemcached)
-install(EXPORT libmemcached DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
+export(EXPORT libmemcached-targets NAMESPACE libmemcached::)
+install(EXPORT libmemcached-targets NAMESPACE libmemcached:: DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
 
 install_public_headers(
         libmemcached
index 7080bd9e6dcddc0a1078376a0aaa1c57e2d12d78..14967dd55e0efa602e2d29295b375a6f15b954bc 100644 (file)
@@ -10,7 +10,7 @@ add_library(libmemcachedprotocol SHARED
 add_library(memcachedprotocol ALIAS libmemcachedprotocol)
 set_target_properties(libmemcachedprotocol PROPERTIES
         LIBRARY_OUTPUT_NAME memcachedprotocol
-        INSTALL_RPATH $ORIGIN
+        LIBRARY_OUTPUT_NAME_DEBUG memcachedprotocol-dbg
         SOVERSION ${LIBMEMCACHEDPROTOCOL_SO_VERSION}
         VERSION v${LIBMEMCACHEDPROTOCOL_VERSION})
 target_compile_definitions(libmemcachedprotocol PRIVATE -DBUILDING_LIBMEMCACHED)
@@ -24,7 +24,7 @@ target_include_directories(libmemcachedprotocol PUBLIC
         $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
         $<INSTALL_INTERFACE:include>)
 
-install(TARGETS libmemcachedprotocol EXPORT libmemcachedprotocol
+install(TARGETS libmemcachedprotocol EXPORT libmemcachedprotocol-targets
         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-export(EXPORT libmemcachedprotocol)
-install(EXPORT libmemcachedprotocol DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
+export(EXPORT libmemcachedprotocol-targets NAMESPACE libmemcached::)
+install(EXPORT libmemcachedprotocol-targets NAMESPACE libmemcached:: DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
index a6ecadabae201bf57f6c0b6222257ccbe5e0acbc..44c70e0daf87b729e16d5cc00e5172ea44ab1a52 100644 (file)
@@ -162,7 +162,7 @@ static uint16_t parse_ascii_key(char **start)
  * @param text the text to spool
  * @return status of the spool operation
  */
-static protocol_binary_response_status raw_response_handler(memcached_protocol_client_st *client, const char *text)
+static protocol_binary_response_status ascii_raw_response_handler(memcached_protocol_client_st *client, const char *text)
 {
   if (client->is_verbose)
   {
@@ -238,7 +238,7 @@ static void send_command_usage(memcached_protocol_client_st *client)
   };
 
   client->mute = false;
-  raw_response_handler(client, errmsg[client->ascii_command]);
+  ascii_raw_response_handler(client, errmsg[client->ascii_command]);
 }
 
 /**
@@ -252,9 +252,9 @@ static protocol_binary_response_status ascii_version_response_handler(const void
                                                                       uint32_t textlen)
 {
   memcached_protocol_client_st *client= (memcached_protocol_client_st*)cookie;
-  raw_response_handler(client, "VERSION ");
+  ascii_raw_response_handler(client, "VERSION ");
   client->root->spool(client, text, textlen);
-  raw_response_handler(client, "\r\n");
+  ascii_raw_response_handler(client, "\r\n");
   return PROTOCOL_BINARY_RESPONSE_SUCCESS;
 }
 
@@ -336,15 +336,15 @@ static protocol_binary_response_status ascii_stat_response_handler(const void *c
 
   if (key != NULL)
   {
-    raw_response_handler(client, "STAT ");
+    ascii_raw_response_handler(client, "STAT ");
     client->root->spool(client, key, keylen);
-    raw_response_handler(client, " ");
+    ascii_raw_response_handler(client, " ");
     client->root->spool(client, body, bodylen);
-    raw_response_handler(client, "\r\n");
+    ascii_raw_response_handler(client, "\r\n");
   }
   else
   {
-    raw_response_handler(client, "END\r\n");
+    ascii_raw_response_handler(client, "END\r\n");
   }
 
   return PROTOCOL_BINARY_RESPONSE_SUCCESS;
@@ -525,7 +525,7 @@ static void process_delete(memcached_protocol_client_st *client,
 
   if (client->root->callback->interface.v1.delete_object == NULL)
   {
-    raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+    ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
     return;
   }
 
@@ -533,17 +533,17 @@ static void process_delete(memcached_protocol_client_st *client,
 
   if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS)
   {
-    raw_response_handler(client, "DELETED\r\n");
+    ascii_raw_response_handler(client, "DELETED\r\n");
   }
   else if (rval == PROTOCOL_BINARY_RESPONSE_KEY_ENOENT)
   {
-    raw_response_handler(client, "NOT_FOUND\r\n");
+    ascii_raw_response_handler(client, "NOT_FOUND\r\n");
   }
   else
   {
     char msg[80];
     snprintf(msg, sizeof(msg), "SERVER_ERROR: delete_object failed %u\r\n",(uint32_t)rval);
-    raw_response_handler(client, msg);
+    ascii_raw_response_handler(client, msg);
   }
 }
 
@@ -573,7 +573,7 @@ static void process_arithmetic(memcached_protocol_client_st *client,
   {
     if (client->root->callback->interface.v1.increment == NULL)
     {
-      raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+      ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
       return;
     }
     rval= client->root->callback->interface.v1.increment(client,
@@ -587,7 +587,7 @@ static void process_arithmetic(memcached_protocol_client_st *client,
   {
     if (client->root->callback->interface.v1.decrement == NULL)
     {
-      raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+      ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
       return;
     }
     rval= client->root->callback->interface.v1.decrement(client,
@@ -602,11 +602,11 @@ static void process_arithmetic(memcached_protocol_client_st *client,
   {
     char buffer[80];
     snprintf(buffer, sizeof(buffer), "%"PRIu64"\r\n", result);
-    raw_response_handler(client, buffer);
+    ascii_raw_response_handler(client, buffer);
   }
   else
   {
-    raw_response_handler(client, "NOT_FOUND\r\n");
+    ascii_raw_response_handler(client, "NOT_FOUND\r\n");
   }
 }
 
@@ -620,7 +620,7 @@ static void process_stats(memcached_protocol_client_st *client,
 {
   if (client->root->callback->interface.v1.stat == NULL)
   {
-    raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+    ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
     return;
   }
 
@@ -646,7 +646,7 @@ static void process_version(memcached_protocol_client_st *client,
 
   if (client->root->callback->interface.v1.version == NULL)
   {
-    raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+    ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
     return;
   }
 
@@ -665,7 +665,7 @@ static void process_flush(memcached_protocol_client_st *client,
 
   if (client->root->callback->interface.v1.flush_object == NULL)
   {
-    raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+    ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
     return;
   }
 
@@ -683,9 +683,9 @@ static void process_flush(memcached_protocol_client_st *client,
   protocol_binary_response_status rval;
   rval= client->root->callback->interface.v1.flush_object(client, timeout);
   if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS)
-    raw_response_handler(client, "OK\r\n");
+    ascii_raw_response_handler(client, "OK\r\n");
   else
-    raw_response_handler(client, "SERVER_ERROR: internal error\r\n");
+    ascii_raw_response_handler(client, "SERVER_ERROR: internal error\r\n");
 }
 
 /**
@@ -712,7 +712,7 @@ static inline int process_storage_command(memcached_protocol_client_st *client,
   if (nkey == 0)
   {
     /* return error */
-    raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
+    ascii_raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
     return -1;
   }
 
@@ -721,7 +721,7 @@ static inline int process_storage_command(memcached_protocol_client_st *client,
   if (errno != 0)
   {
     /* return error */
-    raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
+    ascii_raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
     return -1;
   }
 
@@ -729,7 +729,7 @@ static inline int process_storage_command(memcached_protocol_client_st *client,
   if (errno != 0)
   {
     /* return error */
-    raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
+    ascii_raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
     return -1;
   }
 
@@ -737,7 +737,7 @@ static inline int process_storage_command(memcached_protocol_client_st *client,
   if (errno != 0)
   {
     /* return error */
-    raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
+    ascii_raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
     return -1;
   }
 
@@ -779,7 +779,7 @@ static inline int process_storage_command(memcached_protocol_client_st *client,
     if (errno != 0)
     {
       /* return error */
-      raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
+      ascii_raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
       return -1;
     }
     /* FALLTHROUGH */
@@ -827,7 +827,7 @@ static inline int process_storage_command(memcached_protocol_client_st *client,
 
   if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS)
   {
-    raw_response_handler(client, "STORED\r\n");
+    ascii_raw_response_handler(client, "STORED\r\n");
   }
   else
   {
@@ -835,20 +835,20 @@ static inline int process_storage_command(memcached_protocol_client_st *client,
     {
       if (rval == PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS)
       {
-        raw_response_handler(client, "EXISTS\r\n");
+        ascii_raw_response_handler(client, "EXISTS\r\n");
       }
       else if (rval == PROTOCOL_BINARY_RESPONSE_KEY_ENOENT)
       {
-        raw_response_handler(client, "NOT_FOUND\r\n");
+        ascii_raw_response_handler(client, "NOT_FOUND\r\n");
       }
       else
       {
-        raw_response_handler(client, "NOT_STORED\r\n");
+        ascii_raw_response_handler(client, "NOT_STORED\r\n");
       }
     }
     else
     {
-      raw_response_handler(client, "NOT_STORED\r\n");
+      ascii_raw_response_handler(client, "NOT_STORED\r\n");
     }
   }
 
@@ -869,7 +869,7 @@ static int process_cas_command(memcached_protocol_client_st *client,
 
   if (client->root->callback->interface.v1.replace == NULL)
   {
-    raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+    ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
     return false;
   }
 
@@ -888,7 +888,7 @@ static int process_set_command(memcached_protocol_client_st *client,
 
   if (client->root->callback->interface.v1.set == NULL)
   {
-    raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+    ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
     return false;
   }
 
@@ -907,7 +907,7 @@ static int process_add_command(memcached_protocol_client_st *client,
 
   if (client->root->callback->interface.v1.add == NULL)
   {
-    raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+    ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
     return false;
   }
 
@@ -926,7 +926,7 @@ static int process_replace_command(memcached_protocol_client_st *client,
 
   if (client->root->callback->interface.v1.replace == NULL)
   {
-    raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+    ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
     return false;
   }
 
@@ -945,7 +945,7 @@ static int process_append_command(memcached_protocol_client_st *client,
 
   if (client->root->callback->interface.v1.append == NULL)
   {
-    raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+    ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
     return false;
   }
 
@@ -964,7 +964,7 @@ static int process_prepend_command(memcached_protocol_client_st *client,
 
   if (client->root->callback->interface.v1.prepend == NULL)
   {
-    raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
+    ascii_raw_response_handler(client, "SERVER_ERROR: callback not implemented\r\n");
     return false;
   }
 
@@ -1012,7 +1012,7 @@ memcached_protocol_event_t memcached_ascii_protocol_process_data(memcached_proto
       }
       else
       {
-        raw_response_handler(client, "SERVER_ERROR: Command not implemented\n");
+        ascii_raw_response_handler(client, "SERVER_ERROR: Command not implemented\n");
       }
     }
     else
@@ -1120,7 +1120,7 @@ memcached_protocol_event_t memcached_ascii_protocol_process_data(memcached_proto
         }
         else
         {
-          raw_response_handler(client, "OK\r\n");
+          ascii_raw_response_handler(client, "OK\r\n");
         }
         break;
 
index 37cd3778a76e665fa3bbe656f07646c8fb8c9332..8435cc985e3422fa6d4fc09eed66376ae1cf74d5 100644 (file)
@@ -59,7 +59,7 @@
  * @param response the packet to send
  * @return The status of the operation
  */
-static protocol_binary_response_status raw_response_handler(const void *cookie,
+static protocol_binary_response_status binary_raw_response_handler(const void *cookie,
                                                             protocol_binary_request_header *request,
                                                             protocol_binary_response_header *response)
 {
@@ -1055,14 +1055,14 @@ static protocol_binary_response_status execute_command(memcached_protocol_client
   case 0:
     if (client->root->callback->interface.v0.comcode[cc] != NULL)
     {
-      rval= client->root->callback->interface.v0.comcode[cc](client, header, raw_response_handler);
+      rval= client->root->callback->interface.v0.comcode[cc](client, header, binary_raw_response_handler);
     }
     break;
 
   case 1:
     if (comcode_v0_v1_remap[cc] != NULL)
     {
-      rval= comcode_v0_v1_remap[cc](client, header, raw_response_handler);
+      rval= comcode_v0_v1_remap[cc](client, header, binary_raw_response_handler);
     }
     break;
 
@@ -1078,7 +1078,7 @@ static protocol_binary_response_status execute_command(memcached_protocol_client
   if (rval == PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND &&
       client->root->callback->unknown != NULL)
   {
-    rval= client->root->callback->unknown(client, header, raw_response_handler);
+    rval= client->root->callback->unknown(client, header, binary_raw_response_handler);
   }
 
   if (rval != PROTOCOL_BINARY_RESPONSE_SUCCESS &&
@@ -1095,7 +1095,7 @@ static protocol_binary_response_status execute_command(memcached_protocol_client
         },
       }
     };
-    rval= raw_response_handler(client, header, (void*)&response);
+    rval= binary_raw_response_handler(client, header, (void *) &response);
   }
 
   if (client->root->callback->post_execute != NULL)
@@ -1183,7 +1183,7 @@ void memcached_binary_protocol_set_callbacks(memcached_protocol_st *instance, me
 memcached_binary_protocol_raw_response_handler memcached_binary_protocol_get_raw_response_handler(const void *cookie)
 {
   (void)cookie;
-  return raw_response_handler;
+  return binary_raw_response_handler;
 }
 
 void memcached_binary_protocol_set_pedantic(memcached_protocol_st *instance, bool enable)
index cb281c3be8191af1be1f4a8dd306e405ec4639cc..56fb0b0867ff8da6b52452af70da520038623278 100644 (file)
@@ -11,7 +11,7 @@ add_library(libmemcachedutil SHARED
 add_library(memcachedutil ALIAS libmemcachedutil)
 set_target_properties(libmemcachedutil PROPERTIES
         LIBRARY_OUTPUT_NAME memcachedutil
-        INSTALL_RPATH $ORIGIN
+        LIBRARY_OUTPUT_NAME_DEBUG memcachedutil-dbg
         SOVERSION ${LIBMEMCACHEDUTIL_SO_VERSION}
         VERSION v${LIBMEMCACHEDUTIL_VERSION})
 target_compile_definitions(libmemcachedutil PRIVATE -DBUILDING_LIBMEMCACHED)
@@ -25,7 +25,7 @@ target_include_directories(libmemcachedutil PUBLIC
         $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
         $<INSTALL_INTERFACE:include>)
 
-install(TARGETS libmemcachedutil EXPORT libmemcachedutil
+install(TARGETS libmemcachedutil EXPORT libmemcachedutil-targets
         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-export(EXPORT libmemcachedutil)
-install(EXPORT libmemcachedutil DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
+export(EXPORT libmemcachedutil-targets NAMESPACE libmemcached::)
+install(EXPORT libmemcachedutil-targets NAMESPACE libmemcached:: DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
index d3f877bd5dbbab0b757440cb8437eb494b8b3ae0..beefd5da95de7f4bda01f805f515190969d2099a 100644 (file)
@@ -5,7 +5,7 @@ install(FILES ax_libmemcached.m4
 
 configure_file(example.cnf.in example.cnf @ONLY)
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/example.cnf
-        DESTINATION ${CMAKE_INSTALL_DATADIR}/libmemcached
+        DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}
         )
 
 configure_file(libmemcached.pc.in libmemcached.pc @ONLY)
@@ -21,3 +21,26 @@ if(BUILD_TESTING)
     configure_file(memcached.pwdb.in memcached.pwdb @ONLY)
     configure_file(memcached.conf.in memcached.conf @ONLY)
 endif()
+
+configure_package_config_file(libmemcached-config.cmake.in
+        libmemcached-config.cmake
+        INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake/)
+write_basic_package_version_file(libhashkit-version.cmake
+        VERSION ${LIBHASHKIT_VERSION}
+        COMPATIBILITY SameMajorVersion)
+write_basic_package_version_file(libmemcached-version.cmake
+        VERSION ${LIBMEMCACHED_VERSION}
+        COMPATIBILITY SameMajorVersion)
+write_basic_package_version_file(libmemcachedprotocol-version.cmake
+        VERSION ${LIBMEMCACHEDPROTOCOL_VERSION}
+        COMPATIBILITY SameMajorVersion)
+write_basic_package_version_file(libmemcachedutil-version.cmake
+        VERSION ${LIBMEMCACHEDUTIL_VERSION}
+        COMPATIBILITY SameMajorVersion)
+install(FILES
+        ${CMAKE_CURRENT_BINARY_DIR}/libmemcached-config.cmake
+        ${CMAKE_CURRENT_BINARY_DIR}/libhashkit-version.cmake
+        ${CMAKE_CURRENT_BINARY_DIR}/libmemcached-version.cmake
+        ${CMAKE_CURRENT_BINARY_DIR}/libmemcachedprotocol-version.cmake
+        ${CMAKE_CURRENT_BINARY_DIR}/libmemcachedutil-version.cmake
+        DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake/)
diff --git a/support/libmemcached-config.cmake.in b/support/libmemcached-config.cmake.in
new file mode 100644 (file)
index 0000000..d6fd629
--- /dev/null
@@ -0,0 +1,10 @@
+@PACKAGE_INIT@
+
+include(CMakeFindDependencyMacro)
+find_dependency(Threads)
+
+include(${CMAKE_CURRENT_LIST_DIR}/libhashkit-targets.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/libmemcached-targets.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/libmemcachedprotocol-targets.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/libmemcachedutil-targets.cmake)
+