fix #132: build static libs
authorMichael Wallner <mike@php.net>
Tue, 7 Feb 2023 20:59:00 +0000 (21:59 +0100)
committerMichael Wallner <mike@php.net>
Tue, 21 Feb 2023 12:25:56 +0000 (13:25 +0100)
CMakeConfig.txt
src/libhashkit/CMakeLists.txt
src/libmemcached/CMakeLists.txt
src/libmemcachedprotocol/CMakeLists.txt
src/libmemcachedutil/CMakeLists.txt
src/p9y/CMakeLists.txt

index d8afcaefc3ceae4cee6a09a0eacb45d0eb0b67e4..714ee94e9be2a4e9bad17cd0574d85cb7ad52691 100644 (file)
@@ -23,6 +23,8 @@ else()
     set(TARGET_NAMELINK_COMPONENT NAMELINK_COMPONENT dev DESTINATION ${CMAKE_INSTALL_LIBDIR})
 endif()
 
+option(BUILD_SHARED_LIBS    "whether to build shared libraries"
+        ON)
 option(BUILD_TESTING        "whether to enable build of the test suite"
         $ENV{BUILD_TESTING})
 option(BUILD_DOCSONLY       "build *only* documentation"
index fb732fcfaf22f0df0c3461bd1cf1952070596014..9ed0a3acddd4c68c1fd05df086b2fe5216c731c5 100644 (file)
@@ -21,7 +21,7 @@ set(libhashkit_sources
         strerror.cc
         string.cc
         )
-add_library(libhashkit SHARED)
+add_library(libhashkit)
 add_library(hashkit ALIAS libhashkit)
 set_target_properties(libhashkit PROPERTIES
         CXX_STANDARD ${CXX_STANDARD}
index 81d84638d13767d71a2f46466d6c376d4ac0ae71..075a630838e0892320b4f4d0f44763ba5554a949 100644 (file)
@@ -85,7 +85,7 @@ if(W_NO_DEPRECATED_REGISTER)
         )
 endif()
 
-add_library(libmemcached SHARED)
+add_library(libmemcached)
 add_library(memcached ALIAS libmemcached)
 set_target_properties(libmemcached PROPERTIES
         CXX_STANDARD ${CXX_STANDARD}
index b28afe7200ed258e4d6ae1c88b45df4d62fdb3ad..a32f264b88ca175c7eae4411cd17a051a7e072cd 100644 (file)
@@ -9,7 +9,7 @@ set(libmemcachedprotocol_sources
         pedantic.c
         ../libmemcached/byteorder.cc
         )
-add_library(libmemcachedprotocol SHARED)
+add_library(libmemcachedprotocol)
 add_library(memcachedprotocol ALIAS libmemcachedprotocol)
 set_target_properties(libmemcachedprotocol PROPERTIES
         CXX_STANDARD ${CXX_STANDARD}
index 78e87d305fe1bac2dac89c87a178d37bcda9512b..400be003350c4a8d313a5722472bbe18735a48d2 100644 (file)
@@ -6,7 +6,7 @@ set(libmemcachedutil_sources
         ping.cc
         version.cc
         )
-add_library(libmemcachedutil SHARED)
+add_library(libmemcachedutil)
 add_library(memcachedutil ALIAS libmemcachedutil)
 if(CMAKE_USE_PTHREADS_INIT)
     target_sources(libmemcachedutil PRIVATE pool.cc)
index 6906b8f0154f0febcf41541ccbc35dd3210480fc..67d84fde0c608eae7a10dc280d2c2747aeda272e 100644 (file)
@@ -20,6 +20,17 @@ target_include_directories(p9y PRIVATE
     ${CMAKE_BINARY_DIR}/include
     )
 
+install(TARGETS p9y EXPORT p9y-targets
+        RUNTIME COMPONENT bin DESTINATION ${CMAKE_INSTALL_BINDIR}
+        ARCHIVE COMPONENT lib DESTINATION ${CMAKE_INSTALL_LIBDIR}
+        LIBRARY COMPONENT lib DESTINATION ${CMAKE_INSTALL_LIBDIR}
+        ${TARGET_NAMELINK_COMPONENT}
+        )
+export(EXPORT p9y-targets NAMESPACE libmemcached::)
+install(EXPORT p9y-targets NAMESPACE libmemcached::
+        COMPONENT dev
+        DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
+
 if(NOT HAVE_GETOPT_H)
     target_sources(p9y PRIVATE getopt.c)
 endif()