File: Findhamlib.cmake

package info (click to toggle)
soapyaudio 0~git20160607-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 652 kB
  • ctags: 823
  • sloc: cpp: 9,786; makefile: 10
file content (59 lines) | stat: -rw-r--r-- 1,924 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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)