From 9965708858da0dc334862d6f215b57b275ea1d28 Mon Sep 17 00:00:00 2001 From: casey langen Date: Sun, 30 Jul 2023 12:46:26 -0700 Subject: [PATCH] Add find_library_and_header() macro for cmake scripts to further validate installed dependencies. --- .cmake/FindVendorLibrary.cmake | 17 +++++++++++++++-- CMakeLists.txt | 4 ++-- src/plugins/server/CMakeLists.txt | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.cmake/FindVendorLibrary.cmake b/.cmake/FindVendorLibrary.cmake index 96d79213b..5f95685ef 100644 --- a/.cmake/FindVendorLibrary.cmake +++ b/.cmake/FindVendorLibrary.cmake @@ -1,4 +1,17 @@ macro(find_vendor_library target_var library_name) - find_library(${target_var} NAMES ${library_name} PATHS ${VENDOR_LINK_DIRECTORIES} NO_DEFAULT_PATH) - message(STATUS "[find-vendor-library] '${library_name}' resolved to '${${target_var}}'") + find_library(${target_var} NAMES ${library_name} PATHS ${VENDOR_LINK_DIRECTORIES} NO_DEFAULT_PATH NO_CACHE) + message(STATUS "[find-vendor-library] ${BoldBlue}'${library_name}' library resolved to '${${target_var}}'${ColorReset}") endmacro(find_vendor_library) + +macro(find_library_and_header target_var library_name header_name) + find_library(${target_var} NAMES ${library_name} NO_CACHE) + message(STATUS "[find-library-and-header] ${BoldBlue}'${library_name}' library resolved to '${${target_var}}'${ColorReset}") + + find_path(TEMP ${header_name} REQUIRED NO_CACHE) + if (${TEMP} MATCHES "TEMP-NOTFOUND") + message(STATUS "[find-library-and-header] ${BoldRed}'${header_name}' COULD NOT BE FOUND!${ColorReset}") + else() + message(STATUS "[find-library-and-header] ${BoldBlue}'${header_name}' resolved to '${TEMP}'${ColorReset}") + endif() + unset(TEMP) +endmacro(find_library_and_header) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cd2124bb..59af0afa5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,8 +89,8 @@ else() find_library(LIBCRYPTO NAMES crypto PATHS ${VENDOR_LINK_DIRECTORIES}) endif() -find_library(LIBZ NAMES z) -find_library(PTHREAD NAMES pthread) +find_library_and_header(LIBZ z zlib.h) +find_library_and_header(PTHREAD pthread pthread.h) set(musikcube_LINK_LIBS ${DEFAULT_OS_SYSTEM_LIBS} ${LIBCURL} ${LIBSSL} ${LIBCRYPTO} ${LIBZ} ${PTHREAD}) diff --git a/src/plugins/server/CMakeLists.txt b/src/plugins/server/CMakeLists.txt index 304f36b4a..04b376803 100644 --- a/src/plugins/server/CMakeLists.txt +++ b/src/plugins/server/CMakeLists.txt @@ -20,7 +20,7 @@ else() find_library(LIBGNUTLS NAMES gnutls) set(EXTRA_LIBS "${LIBGNUTLS}") endif() - find_library(LIBMICROHTTPD NAMES microhttpd) + find_library_and_header(LIBMICROHTTPD microhttpd microhttpd.h) endif() find_library(LIBZ NAMES z)