From d63dd8d081a6fcd0715cd13f26df59fb831769d2 Mon Sep 17 00:00:00 2001 From: "Iain R. Learmonth" Date: Sun, 18 Oct 2015 18:51:00 +0100 Subject: Imported Upstream version 1.5.0 --- CMake/Modules/Findhamlib.cmake | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 CMake/Modules/Findhamlib.cmake (limited to 'CMake/Modules/Findhamlib.cmake') diff --git a/CMake/Modules/Findhamlib.cmake b/CMake/Modules/Findhamlib.cmake new file mode 100644 index 00000000..abed74b2 --- /dev/null +++ b/CMake/Modules/Findhamlib.cmake @@ -0,0 +1,59 @@ +# - Try to find hamlib +# Once done, this will define: +# +# hamlib_FOUND - system has Hamlib-2 +# hamlib_INCLUDE_DIRS - the Hamlib-2 include directories +# hamlib_LIBRARIES - link these to use Hamlib-2 +# hamlib_STATIC_FOUND - system has Hamlib-2 static archive +# hamlib_STATIC_LIBRARIES - link these to use Hamlib-2 static archive + +include (LibFindMacros) + +# pkg-config? +find_path (__hamlib_pc_path NAMES hamlib.pc + PATH_SUFFIXES lib/pkgconfig +) +if (__hamlib_pc_path) + set (ENV{PKG_CONFIG_PATH} "${__hamlib_pc_path}" "$ENV{PKG_CONFIG_PATH}") + unset (__hamlib_pc_path CACHE) +endif () + +# Use pkg-config to get hints about paths, libs and, flags +unset (__pkg_config_checked_hamlib CACHE) +libfind_pkg_check_modules (PC_HAMLIB hamlib) + +if (NOT PC_HAMLIB_STATIC_LIBRARIES) + if (WIN32) + set (PC_HAMLIB_STATIC_LIBRARIES hamlib ws2_32) + else () + set (PC_HAMLIB_STATIC_LIBRARIES hamlib m dl usb) + endif () +endif () + +# The libraries +libfind_library (hamlib hamlib) +libfind_library (hamlib_STATIC libhamlib.a) + +find_path (hamlib_INCLUDE_DIR hamlib/rig.h) + +# Set the include dir variables and the libraries and let libfind_process do the rest +set (hamlib_PROCESS_INCLUDES hamlib_INCLUDE_DIR) +set (hamlib_PROCESS_LIBS hamlib_LIBRARY) +libfind_process (hamlib) + +set (hamlib_STATIC_PROCESS_INCLUDES hamlib_STATIC_INCLUDE_DIR) +set (hamlib_STATIC_PROCESS_LIBS hamlib_STATIC_LIBRARY PC_HAMLIB_STATIC_LIBRARIES) +libfind_process (hamlib_STATIC) + +# make sure we return a full path for the library we return +if (hamlib_FOUND) + list (REMOVE_ITEM hamlib_LIBRARIES hamlib) + if (hamlib_STATIC_LIBRARIES) + list (REMOVE_ITEM hamlib_STATIC_LIBRARIES hamlib) + endif () +endif () + +# Handle the QUIETLY and REQUIRED arguments and set HAMLIB_FOUND to +# TRUE if all listed variables are TRUE +include (FindPackageHandleStandardArgs) +find_package_handle_standard_args (hamlib DEFAULT_MSG hamlib_INCLUDE_DIRS hamlib_LIBRARY hamlib_LIBRARIES) -- cgit v1.2.3