direwolf/cmake/modules/Findhamlib.cmake
Martin Cooper c8319fcc7b
Add new build config for Direwolf with Hamlib on Windows (#626)
* Add new build config for Direwolf with Hamlib on Windows

In parallel with the existing 64-bit Windows build, these changes add
a new matrix config for the same build but including Hamlib as part of
the build and package distribution. The resultant package zip file has
"-hamlib" appended to the name to distinguish it from the standard
Windows build.

Installing Hamlib as a build dependency using a package manager isn't
a viable option on Windows. Instead, we interrogate the GitHub release
assets to find the latest 4.x release of Hamlib, download and expand
the zip file for that release, and provide the path to the directory
for CMake configuration.

* Fix WIndows build errors

* Include Hamlib license-related files in Windows Hamlib zip
2025-11-30 16:51:24 -05:00

73 lines
1.5 KiB
CMake

# - Try to find Hamlib
#
# HAMLIB_FOUND - system has Hamlib
# HAMLIB_LIBRARIES - location of the library for hamlib
# HAMLIB_INCLUDE_DIRS - location of the include files for hamlib
#
# Requires these CMake modules:
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
#
# Original Author:
# 2019 Davide Gerhard <rainbow@irh.it>
set(HAMLIB_ROOT_DIR
"${HAMLIB_ROOT_DIR}"
CACHE
PATH
"Directory to search for hamlib")
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_HAMLIB hamlib)
endif()
find_path(HAMLIB_INCLUDE_DIR
NAMES hamlib/rig.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
HINTS
${PC_HAMLIB_INCLUDEDIR}
${HAMLIB_ROOT_DIR}
PATH_SUFFIXES
include
)
find_library(HAMLIB_LIBRARY
NAMES hamlib
PATHS
/usr/lib64/hamlib
/usr/lib/hamlib
/usr/lib64
/usr/lib
/usr/local/lib64/hamlib
/usr/local/lib/hamlib
/usr/local/lib64
/usr/local/lib
/opt/local/lib
/opt/local/lib/hamlib
HINTS
${PC_HAMLIB_LIBDIR}
${HAMLIB_ROOT_DIR}
PATH_SUFFIXES
lib/gcc
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(hamlib
DEFAULT_MSG
HAMLIB_LIBRARY
HAMLIB_INCLUDE_DIR
)
if(HAMLIB_FOUND)
list(APPEND HAMLIB_LIBRARIES ${HAMLIB_LIBRARY})
list(APPEND HAMLIB_INCLUDE_DIRS ${HAMLIB_INCLUDE_DIR})
if(WIN32 OR CYGWIN)
file(GLOB HAMLIB_DLLS ${HAMLIB_ROOT_DIR}/bin/*.dll)
endif()
mark_as_advanced(HAMLIB_ROOT_DIR)
endif()
mark_as_advanced(HAMLIB_INCLUDE_DIR HAMLIB_LIBRARY)