cmake: macos build
authorMichael Wallner <mike@php.net>
Fri, 2 Oct 2020 21:11:45 +0000 (23:11 +0200)
committerMichael Wallner <mike@php.net>
Fri, 2 Oct 2020 21:11:45 +0000 (23:11 +0200)
CMake/CheckDependency.cmake
src/libmemcachedprotocol/CMakeLists.txt
src/libmemcachedutil/CMakeLists.txt

index 3cb575354562ac81a36956531a1201a396a47786..1003d68c28b0e4d759186ff9ee08e9de619869be 100644 (file)
@@ -3,40 +3,55 @@ find_package(PkgConfig)
 include(SafeString)
 include(CheckHeader)
 
+function(check_dependency_basic NAME LIB HEADER)
+       set(FOUND 1)
+       message("-- Checking for library '${LIB}' with header '${HEADER}' ...")
+       find_library(LIB${LIB} NAMES ${LIB})
+       if(NOT LIB${LIB})
+               set(FOUND 0)
+       endif()
+       if(HEADER)
+               safe_string(${HEADER} HEADER_CONST)
+               check_header(${HEADER})
+               if(NOT HAVE_${HEADER_CONST})
+                       set(FOUND 0)
+               else()
+                       find_path(${HEADER_CONST}_ROOT ${HEADER})
+                       if(NOT ${HEADER_CONST}_ROOT)
+                               set(FOUND 0)
+                       endif()
+               endif()
+       endif()
+       if(FOUND)
+               message("--   Found library '${LIB${LIB}}'")
+               message("--   Found include '${${HEADER_CONST}_ROOT}'")
+       else()
+               message("--   No library '${LIB}' found")
+       endif()
+       set(${NAME} ${FOUND} PARENT_SCOPE)
+       set(${NAME}_LIBRARIES ${LIB${LIB}} PARENT_SCOPE)
+       set(${NAME}_INCLUDEDIR ${${HEADER_CONST}_ROOT} PARENT_SCOPE)
+endfunction()
+
 function(check_dependency NAME LIB HEADER)
     if(PKG_CONFIG_FOUND)
         pkg_check_modules(${NAME} lib${LIB}${ARGN})
         if(NOT ${NAME}_FOUND)
             pkg_check_modules(${NAME} ${LIB}${ARGN})
         endif()
-        set(${NAME} ${${NAME}_FOUND} PARENT_SCOPE)
-               set(${NAME}_LIBRARIES ${${NAME}_LDFLAGS} PARENT_SCOPE)
-        set(${NAME}_INCLUDEDIR ${${NAME}_INCLUDEDIR} PARENT_SCOPE)
+               if(NOT ${NAME}_FOUND)
+                       check_dependency_basic(${NAME} ${LIB} ${HEADER})
+               else()  
+                       set(${NAME} ${${NAME}_FOUND} PARENT_SCOPE)
+                       set(${NAME}_LIBRARIES ${${NAME}_LDFLAGS} PARENT_SCOPE)
+                       set(${NAME}_INCLUDEDIR ${${NAME}_INCLUDEDIR} PARENT_SCOPE)
 
-        safe_string(${LIB} LIB_CONST)
-        set(HAVE_${NAME} ${${NAME}_FOUND} PARENT_SCOPE)
-        safe_string(${HEADER} HEADER_CONST)
-        find_path(HAVE_${HEADER_CONST} ${HEADER} PATHS ${${NAME}_INCLUDEDIR})
+                       safe_string(${LIB} LIB_CONST)
+                       set(HAVE_${NAME} ${${NAME}_FOUND} PARENT_SCOPE)
+                       safe_string(${HEADER} HEADER_CONST)
+                       find_path(HAVE_${HEADER_CONST} ${HEADER} PATHS ${${NAME}_INCLUDEDIR})
+               endif()
     else()
-        set(FOUND 1)
-        find_library(LIB${LIB} NAMES ${LIB})
-        if(NOT LIB${LIB})
-            set(FOUND 0)
-        endif()
-        if(HEADER)
-            safe_string(${HEADER} HEADER_CONST)
-            check_header(${HEADER})
-            if(NOT HAVE_${HEADER_CONST})
-                set(FOUND 0)
-            else()
-                find_path(${HEADER_CONST}_ROOT ${HEADER})
-                if(NOT ${HEADER_CONST}_ROOT)
-                    set(FOUND 0)
-                endif()
-            endif()
-        endif()
-        set(${NAME} ${FOUND} PARENT_SCOPE)
-        set(${NAME}_LIBRARIES ${LIB${LIB}} PARENT_SCOPE)
-        set(${NAME}_INCLUDEDIR ${${HEADER_CONST}_ROOT} PARENT_SCOPE)
+               check_dependency_basic(${NAME} ${LIB} ${HEADER})
     endif()
 endfunction()
index 84b7fa1fb9687f1822c32373869487423848ce76..e239d21c95d821e385149fabe80c97d288eaf066 100644 (file)
@@ -14,6 +14,11 @@ set_target_properties(libmemcachedprotocol PROPERTIES
         SOVERSION ${LIBMEMCACHEDPROTOCOL_SO_VERSION}
         VERSION v${LIBMEMCACHEDPROTOCOL_VERSION})
 target_compile_definitions(libmemcachedprotocol PRIVATE -DBUILDING_LIBMEMCACHED)
+if(CMAKE_CXX_COMPILER_ID STREQUAL AppleClang)
+       set_target_properties(libmemcachedprotocol PROPERTIES
+               LINK_FLAGS "-Wl,-undefined,dynamic_lookup"
+               )
+endif()
 target_link_libraries(libmemcachedprotocol PUBLIC Threads::Threads)
 target_include_directories(libmemcachedprotocol PRIVATE
         ${CMAKE_SOURCE_DIR}/src
index e1834f265070a7a15681ae65c2eba10c02a8aed7..c1110b476ace4f31f0ae7001c877f4dc89b580e0 100644 (file)
@@ -15,6 +15,11 @@ set_target_properties(libmemcachedutil PROPERTIES
         SOVERSION ${LIBMEMCACHEDUTIL_SO_VERSION}
         VERSION v${LIBMEMCACHEDUTIL_VERSION})
 target_compile_definitions(libmemcachedutil PRIVATE -DBUILDING_LIBMEMCACHED)
+if(CMAKE_CXX_COMPILER_ID STREQUAL AppleClang)
+       set_target_properties(libmemcachedutil PROPERTIES
+               LINK_FLAGS "-Wl,-undefined,dynamic_lookup"
+               )
+endif()
 target_link_libraries(libmemcachedutil PUBLIC Threads::Threads)
 target_include_directories(libmemcachedutil PRIVATE
         ${CMAKE_SOURCE_DIR}/src