Browse Source

cmake: verify minimum codec2 version during discovery

Use pkg-config to verify that codec2 >= 1.1.1 is available before
searching for the headers and library.

If CODEC2_DIR is specified, treat it as an explicit user override and
search that installation directly. Otherwise, use pkg-config to validate
the minimum supported version. If pkg-config is unavailable or an older
codec2 version is installed, disable codec2 support while allowing the
rest of the project to configure normally.

Also update the pkg-config search hints to use the documented
PC_CODEC2_INCLUDE_DIRS and PC_CODEC2_LIBRARY_DIRS variables.

Signed-off-by: Robin Getz <rgetz503@gmail.com>
chirpmodem-v8.0.0
Robin Getz 4 months ago
parent
commit
6b353ffd1c
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 26
      cmake/Modules/FindCodec2.cmake

26
cmake/Modules/FindCodec2.cmake

@ -1,11 +1,29 @@ @@ -1,11 +1,29 @@
# If CODEC2_DIR is specified, treat it as an explicit user override and
# search that installation directly. Otherwise use pkg-config to verify
# the minimum supported codec2 version before locating the headers and
# library.
if (NOT CODEC2_FOUND)
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(PC_CODEC2 "codec2")
if (CODEC2_DIR)
message(STATUS "Using CODEC2_DIR: ${CODEC2_DIR}")
else()
find_package(PkgConfig QUIET)
if(NOT PKG_CONFIG_FOUND)
message(STATUS "codec2 support disabled: pkg-config is required to verify codec2 version.")
return()
endif()
pkg_check_modules(PC_CODEC2 QUIET codec2>=1.1.1)
if(NOT PC_CODEC2_FOUND)
message(STATUS "codec2 support disabled: codec2 >= 1.1.1 was not found.")
return()
endif()
endif()
FIND_PATH(CODEC2_INCLUDE_DIR
NAMES codec2/codec2.h
HINTS ${CODEC2_DIR}/include
${PC_CODEC2_INCLUDE_DIR}
${PC_CODEC2_INCLUDE_DIRS}
${CMAKE_INSTALL_PREFIX}/include
PATHS /usr/local/include
/usr/include
@ -15,7 +33,7 @@ if (NOT CODEC2_FOUND) @@ -15,7 +33,7 @@ if (NOT CODEC2_FOUND)
NAMES codec2 libcodec2
HINTS ${CODEC2_DIR}/lib
${CODEC2_DIR}/lib64
${PC_CODEC2_LIBDIR}
${PC_CODEC2_LIBRARY_DIRS}
${CMAKE_INSTALL_PREFIX}/lib
${CMAKE_INSTALL_PREFIX}/lib64
PATHS /usr/local/lib

Loading…
Cancel
Save