diff options
| author | Iain R. Learmonth <irl@debian.org> | 2015-10-18 18:51:00 +0100 |
|---|---|---|
| committer | Iain R. Learmonth <irl@debian.org> | 2015-10-18 18:51:00 +0100 |
| commit | d63dd8d081a6fcd0715cd13f26df59fb831769d2 (patch) | |
| tree | b9c1f6245147a310aac3762630bad389bbb57335 /CMake/Modules/Findhamlib.cmake | |
| parent | c720a3d55c5ec832c29cb7ce50b6fb4b70c55b11 (diff) | |
Imported Upstream version 1.5.0upstream/1.5.0
Diffstat (limited to 'CMake/Modules/Findhamlib.cmake')
| -rw-r--r-- | CMake/Modules/Findhamlib.cmake | 59 |
1 files changed, 59 insertions, 0 deletions
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) |
