File: FindHamlib.cmake

package info (click to toggle)
js8call 2.5.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,720 kB
  • sloc: cpp: 562,651; sh: 898; python: 132; ansic: 102; makefile: 4
file content (64 lines) | stat: -rw-r--r-- 1,699 bytes parent folder | download | duplicates (3)
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
60
61
62
63
64
#
# Find the hamlib library
#
# This will define the following variables::
#
#  Hamlib_FOUND		- True if the system has the usb library
#  Hamlib_VERSION	- The verion of the usb library which was found
#
# and the following imported targets::
#
#  Hamlib::Hamlib	- The hamlib library
#

include (LibFindMacros)

libfind_pkg_detect (Hamlib hamlib
  FIND_PATH hamlib/rig.h PATH_SUFFIXES hamlib
  FIND_LIBRARY hamlib
  )

libfind_package (Hamlib Usb)

libfind_process (Hamlib)

if (NOT Hamlib_PKGCONF_FOUND)
  if (WIN32)
    set (Hamlib_LIBRARIES ${Hamlib_LIBRARIES};${Usb_LIBRARY};ws2_32)
  else ()
    set (Hamlib_LIBRARIES ${Hamlib_LIBRARIES};m;dl)
  endif ()
elseif (UNIX AND NOT APPLE)
  set (Hamlib_LIBRARIES ${Hamlib_PKGCONF_STATIC_LDFLAGS})
endif ()

# fix up extra link libraries for macOS as target_link_libraries gets
# it wrong for frameworks
unset (_next_is_framework)
unset (_Hamlib_EXTRA_LIBS)
foreach (_lib IN LISTS Hamlib_LIBRARIES Hamlib_PKGCONF_LDFLAGS)
  if (_next_is_framework)
    list (APPEND _Hamlib_EXTRA_LIBS "-framework ${_lib}")
    unset (_next_is_framework)
  elseif (${_lib} STREQUAL "-framework")
    set (_next_is_framework TRUE)
  else ()
    list (APPEND _Hamlib_EXTRA_LIBS ${_lib})
  endif ()
endforeach ()

if (Hamlib_FOUND AND NOT TARGET Hamlib::Hamlib)
  add_library (Hamlib::Hamlib UNKNOWN IMPORTED)
  set_target_properties (Hamlib::Hamlib PROPERTIES
    IMPORTED_LOCATION "${Hamlib_LIBRARY}"
    INTERFACE_COMPILE_OPTIONS "${Hamlib_PKGCONF_STATIC_OTHER}"
    INTERFACE_INCLUDE_DIRECTORIES "${Hamlib_INCLUDE_DIR}"
    INTERFACE_LINK_LIBRARIES "${_Hamlib_EXTRA_LIBS}"
    )
endif ()

mark_as_advanced (
  Hamlib_INCLUDE_DIR
  Hamlib_LIBRARY
  Hamlib_LIBRARIES
  )