cpack
[m6w6/libmemcached] / src / libmemcached / CMakeLists.txt
index 819a98f7c225de3ad5d56cb973aec622329b4c4b..c3d5389312568cbf733802318d9f8fc84f42111b 100644 (file)
@@ -12,8 +12,12 @@ bison_target(CSL_PARSER csl/parser.yy ${CMAKE_CURRENT_BINARY_DIR}/csl/parser.cc
         COMPILE_FLAGS ${BISON_WARNINGS}
         )
 set_source_files_properties(${BISON_CSL_PARSER_OUTPUTS} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
+if(NOT HAVE_UNISTD_H)
+        set(FLEX_FLAGS --nounistd)
+endif()
 flex_target(CSL_SCANNER csl/scanner.l ${CMAKE_CURRENT_BINARY_DIR}/csl/scanner.cc
         DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/csl/scanner.h
+        COMPILE_FLAGS "${FLEX_FLAGS}"
         )
 set_source_files_properties(${FLEX_CSL_SCANNER_OUTPUTS} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
 add_flex_bison_dependency(CSL_SCANNER CSL_PARSER)
@@ -53,7 +57,6 @@ set(LIBMEMCACHED_SOURCES
         namespace.cc
         options.cc
         parse.cc
-        poll.cc
         purge.cc
         quit.cc
         response.cc
@@ -71,22 +74,44 @@ set(LIBMEMCACHED_SOURCES
         version.cc
         virtual_bucket.c)
 
+check_cxx_compiler_flag(-Wno-deprecated-register W_NO_DEPRECATED_REGISTER)
+
+if(W_NO_DEPRECATED_REGISTER)
+        set_source_files_properties(
+                ${FLEX_CSL_SCANNER_OUTPUTS}
+                ${BISON_CSL_PARSER_OUTPUTS}
+                PROPERTIES COMPILE_OPTIONS -Wno-deprecated-register
+        )
+endif()
+
 add_library(libmemcached SHARED
         ${LIBMEMCACHED_SOURCES})
 add_library(memcached ALIAS libmemcached)
 set_target_properties(libmemcached PROPERTIES
+        CXX_STANDARD ${CXX_STANDARD}
         LIBRARY_OUTPUT_NAME memcached
         LIBRARY_OUTPUT_NAME_DEBUG memcached-dbg
-        SOVERSION ${LIBMEMCACHED_SO_VERSION}
-        VERSION v${LIBMEMCACHED_VERSION})
+        SOVERSION ${LIBMEMCACHED_SO_VERSION})
 target_compile_definitions(libmemcached PRIVATE -DBUILDING_LIBMEMCACHED)
-target_link_libraries(libmemcached PUBLIC libhashkit Threads::Threads ${LIBSASL_LIBRARIES} ${CMAKE_DL_LIBS} ${Backtrace_LIBRARIES})
-target_include_directories(libmemcached PRIVATE ${Backtrace_INCLUDE_DIR})
+target_link_libraries(libmemcached PUBLIC libhashkit Threads::Threads ${CMAKE_DL_LIBS})
+target_link_libraries(libmemcached PRIVATE p9y)
+if(MSVC)
+    target_link_libraries(libmemcached PUBLIC wsock32 ws2_32)
+endif()
+if(HAVE_BACKTRACE)
+    target_link_libraries(libmemcached PUBLIC ${BACKTRACE})
+endif()
+if(HAVE_LIBSASL)
+    target_link_libraries(libmemcached PUBLIC ${LIBSASL})
+endif()
+if(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
+    # see https://docs.oracle.com/cd/E77782_01/html/E77789/bkamq.html#OSSCPgrxeu
+    target_link_libraries(libmemcached INTERFACE stdc++ gcc_s CrunG3 c)
+endif()
 target_include_directories(libmemcached PRIVATE
         ${CMAKE_SOURCE_DIR}/src
         ${CMAKE_BINARY_DIR}/src
         ${CMAKE_BINARY_DIR})
-target_include_directories(libmemcached PUBLIC ${LIBSASL_INCLUDEDIR})
 target_include_directories(libmemcached PUBLIC
         $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
         $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
@@ -95,9 +120,14 @@ target_include_directories(libmemcached PUBLIC
 enable_dtrace_for(libmemcached libmemcached_probes.d dtrace_probes.h)
 
 install(TARGETS libmemcached EXPORT libmemcached-targets
-        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+        LIBRARY
+        COMPONENT lib
+        NAMELINK_COMPONENT dev
+        DESTINATION ${CMAKE_INSTALL_LIBDIR})
 export(EXPORT libmemcached-targets NAMESPACE libmemcached::)
-install(EXPORT libmemcached-targets NAMESPACE libmemcached:: DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
+install(EXPORT libmemcached-targets NAMESPACE libmemcached::
+        COMPONENT dev
+        DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake)
 
 install_public_headers(
         libmemcached
@@ -110,15 +140,23 @@ install_public_headers(
 add_library(libmemcachedinternal STATIC
         ${LIBMEMCACHED_SOURCES})
 add_library(memcachedinternal ALIAS libmemcachedinternal)
-set_target_properties(libmemcachedinternal PROPERTIES LIBRARY_OUTPUT_NAME memcachedinternal)
+set_target_properties(libmemcachedinternal PROPERTIES CXX_STANDARD ${CXX_STANDARD} LIBRARY_OUTPUT_NAME memcachedinternal)
 target_compile_definitions(libmemcachedinternal PRIVATE -DBUILDING_LIBMEMCACHEDINTERNAL)
-target_link_libraries(libmemcachedinternal PUBLIC libhashkit Threads::Threads ${LIBSASL_LIBRARIES} ${CMAKE_DL_LIBS} ${Backtrace_LIBRARIES})
-target_include_directories(libmemcachedinternal PRIVATE ${Backtrace_INCLUDE_DIR})
+target_link_libraries(libmemcachedinternal PUBLIC libhashkit Threads::Threads ${CMAKE_DL_LIBS})
+target_link_libraries(libmemcachedinternal PRIVATE p9y)
+if(MSVC)
+    target_link_libraries(libmemcached PUBLIC wsock32 ws2_32)
+endif()
+if(HAVE_LIBSASL)
+    target_link_libraries(libmemcachedinternal PUBLIC ${LIBSASL})
+endif()
+if(HAVE_BACKTRACE)
+    target_link_libraries(libmemcachedinternal PUBLIC ${BACKTRACE})
+endif()
 target_include_directories(libmemcachedinternal PRIVATE
         ${CMAKE_SOURCE_DIR}/src
         ${CMAKE_BINARY_DIR}/src
         ${CMAKE_BINARY_DIR})
-target_include_directories(libmemcachedinternal PUBLIC ${LIBSASL_INCLUDEDIR})
 target_include_directories(libmemcachedinternal PUBLIC
         $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
         $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>