cmake: fix manual library discovery
authorMichael Wallner <mike@php.net>
Mon, 30 Nov 2020 14:36:42 +0000 (15:36 +0100)
committerMichael Wallner <mike@php.net>
Mon, 30 Nov 2020 14:36:42 +0000 (15:36 +0100)
CMake/CheckDependency.cmake

index eec8d9b3a80fede9735a02ba618df9f4ae83bd56..7932b55a3c9783f1f7a2747b32324687c7a37ada 100644 (file)
@@ -17,14 +17,14 @@ function(check_dependency NAME LIB)
     endif()
 
     message(STATUS "Checking for library '${LIB}' ...")
-    find_library(${NAME}_FOUND NAMES ${LIB} ${ARGN})
-    if(${NAME}_FOUND)
-        mark_as_advanced(${NAME}_FOUND)
-        message(STATUS "  Found '${${NAME}_FOUND}'")
+    find_library(${NAME}_LIB NAMES ${LIB})
+    if(${NAME}_LIB)
+        mark_as_advanced(${NAME}_LIB)
+        message(STATUS "  Found '${${NAME}_LIB}'")
 
         set(${NAME}_INCLUDES "")
         foreach(PATH IN_LIST CMAKE_PREFIX_PATHS)
-            if(LIB${LIB} MATCHES "^${PATH}")
+            if(${NAME}_LIB MATCHES "^${PATH}")
                 set(${NAME}_INCLUDES "${PATH}/include")
                 break()
             endif()
@@ -33,7 +33,7 @@ function(check_dependency NAME LIB)
         add_library(Imported::${NAME} INTERFACE IMPORTED)
         set_target_properties(Imported::${NAME} PROPERTIES
                 INTERFACE_INCLUDE_DIRECTORIES "${${NAME}_INCLUDES}"
-                INTERFACE_LINK_LIBRARIES ${${NAME}_FOUND})
+                INTERFACE_LINK_LIBRARIES ${${NAME}_LIB})
 
         set(${NAME} Imported::${NAME} CACHE INTERNAL "${NAME} import target")
         set(${HAVE} 1 CACHE INTERNAL "${HAVE}")