cmake
authorMichael Wallner <mike@php.net>
Mon, 2 Nov 2020 10:13:37 +0000 (11:13 +0100)
committerMichael Wallner <mike@php.net>
Mon, 2 Nov 2020 10:13:37 +0000 (11:13 +0100)
CMake/CheckDependency.cmake
CMake/CheckTbb.cmake
CMake/_Include.cmake
src/bin/CMakeLists.txt
src/libmemcached/CMakeLists.txt
src/libmemcachedutil/CMakeLists.txt
test/CMakeLists.txt

index f57d12aea1b6951f92961e0a369050cef4f82c6c..bb6fd7d0a68c9f5986b1cca6091e541858407641 100644 (file)
@@ -25,6 +25,7 @@ function(check_dependency_basic NAME LIB HEADER)
        if(FOUND)
                message("--   Found library '${LIB${LIB}}'")
                message("--   Found include '${${HEADER_CONST}_ROOT}'")
+        set(${NAME} ${NAME} PARENT_SCOPE)
         add_library(${NAME} INTERFACE IMPORTED)
         set_target_properties(${NAME} PROPERTIES
                 INTERFACE_INCLUDE_DIRECTORIES ${${HEADER_CONST}_ROOT}
@@ -42,7 +43,7 @@ function(check_dependency NAME LIB HEADER)
             pkg_check_modules(${NAME} ${LIB}${ARGN})
         endif()
         if(${NAME}_FOUND)
-            add_library(${NAME} ALIAS PkgConfig::${NAME})
+            set(${NAME} PkgConfig::${NAME} PARENT_SCOPE)
         endif()
     endif()
     if(NOT ${NAME}_FOUND)
index 1245e03ba618ed80aea593df28fe1833efecf612..11abb4ab0928602f19da00ba1f3281e404dbc066 100644 (file)
@@ -5,8 +5,8 @@ function(CHECK_TBB)
         check_dependency(LIBTBB tbb tbb/task.h)
         if(HAVE_LIBTBB)
             cmake_push_check_state(RESET)
-            get_property(LIBTBB_INCLUDEDIR TARGET LIBTBB PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
-            get_property(LIBTBB_LIBRARIES TARGET LIBTBB PROPERTY INTERFACE_LINK_LIBRARIES)
+            get_property(LIBTBB_INCLUDEDIR TARGET ${LIBTBB} PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+            get_property(LIBTBB_LIBRARIES TARGET ${LIBTBB} PROPERTY INTERFACE_LINK_LIBRARIES)
             set(CMAKE_REQUIRED_INCLUDES "${LIBTBB_INCLUDEDIR}")
             set(CMAKE_REQUIRED_LIBRARIES "${LIBTBB_LIBRARIES}")
             set(CMAKE_REQUIRED_FLAGS -std=c++17)
index 93f4fb4ed3dc23257fb78d2f170127b0c1de1cf5..579d85324ee464d255474ebb4be00032f02ddda0 100644 (file)
@@ -128,6 +128,7 @@ check_decl(abi::__cxa_demangle cxxabi.h)
 find_package(Backtrace)
 if(Backtrace_FOUND)
     set(HAVE_BACKTRACE 1)
+    set(BACKTRACE BACKTRACE)
     add_library(BACKTRACE INTERFACE IMPORTED)
     set_target_properties(BACKTRACE PROPERTIES
             INTERFACE_LINK_LIBRARIES "${Backtrace_LIBRARIES}"
index 988f4809a21806109e6916948aa15511aa5fce99..54b1fa76f8814f211e922be7855771df89b7e170 100644 (file)
@@ -34,7 +34,7 @@ if(HAVE_MEMASLAP)
             memaslap/ms_task.c
             memaslap/ms_thread.c)
     target_include_directories(memaslap PRIVATE memaslap)
-    target_link_libraries(memaslap PRIVATE libclient_common Threads::Threads LIBEVENT)
+    target_link_libraries(memaslap PRIVATE libclient_common Threads::Threads ${LIBEVENT})
     if(CMAKE_INSTALL_RPATH)
         set_target_properties(${CLIENT} PROPERTIES
                 INSTALL_RPATH ${CMAKE_INSTALL_RPATH}/../${CMAKE_INSTALL_LIBDIR})
index 4f48301153f36b1f77ee333958ddb07b01815dc0..6dd760d3847fa837d318b93fae5f12e0ba3f0369 100644 (file)
@@ -93,10 +93,10 @@ set_target_properties(libmemcached PROPERTIES
 target_compile_definitions(libmemcached PRIVATE -DBUILDING_LIBMEMCACHED)
 target_link_libraries(libmemcached PUBLIC libhashkit Threads::Threads ${CMAKE_DL_LIBS})
 if(HAVE_BACKTRACE)
-    target_link_libraries(libmemcached PRIVATE BACKTRACE)
+    target_link_libraries(libmemcached PRIVATE ${BACKTRACE})
 endif()
 if(HAVE_LIBSASL)
-    target_link_libraries(libmemcached PUBLIC LIBSASL)
+    target_link_libraries(libmemcached PUBLIC ${LIBSASL})
 endif()
 target_include_directories(libmemcached PRIVATE
         ${CMAKE_SOURCE_DIR}/src
@@ -127,11 +127,13 @@ add_library(libmemcachedinternal STATIC
 add_library(memcachedinternal ALIAS libmemcachedinternal)
 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 ${CMAKE_DL_LIBS} ${Backtrace_LIBRARIES})
+target_link_libraries(libmemcachedinternal PUBLIC libhashkit Threads::Threads ${CMAKE_DL_LIBS})
 if(HAVE_LIBSASL)
-    target_link_libraries(libmemcachedinternal PUBLIC LIBSASL)
+    target_link_libraries(libmemcachedinternal PUBLIC ${LIBSASL})
+endif()
+if(HAVE_BACKTRACE)
+    target_link_libraries(libmemcachedinternal PRIVATE ${BACKTRACE})
 endif()
-target_include_directories(libmemcachedinternal PRIVATE ${Backtrace_INCLUDE_DIR})
 target_include_directories(libmemcachedinternal PRIVATE
         ${CMAKE_SOURCE_DIR}/src
         ${CMAKE_BINARY_DIR}/src
index 328088008b5d5466bde7f7957d524e28f3e2877c..6bad745b5e5e8e6ade09c0106e476f872104dbb6 100644 (file)
@@ -23,7 +23,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL AppleClang)
 endif()
 target_link_libraries(libmemcachedutil PUBLIC Threads::Threads)
 if(HAVE_LIBSASL)
-    target_link_libraries(libmemcachedutil PUBLIC LIBSASL)
+    target_link_libraries(libmemcachedutil PUBLIC ${LIBSASL})
 endif()
 target_include_directories(libmemcachedutil PRIVATE
         ${CMAKE_SOURCE_DIR}/src
index 040a8c61550b31113f62c47fb9a815952b1d4812..75fb187b04e60eb71a4ce8cdbcb5dfd118e32d92 100644 (file)
@@ -31,7 +31,7 @@ target_link_libraries(runtests PRIVATE libhashkit libmemcachedinternal libmemcac
 check_tbb()
 if(HAVE_TBB)
     message("HAVE TBB")
-    target_link_libraries(runtests PRIVATE LIBTBB)
+    target_link_libraries(runtests PRIVATE ${LIBTBB})
 endif()
 
 add_dependencies(runtests ${CLIENTS})