|
| 1 | +# TODO |
| 2 | +# Find the nfb-framework includes and library |
| 3 | +# |
| 4 | +# This module defines the following IMPORTED targets: |
| 5 | +# |
| 6 | +# nfb::nfb - The "nfb" library, if found. |
| 7 | +# |
| 8 | +# This module will set the following variables in your project: |
| 9 | +# |
| 10 | +# NFB_INCLUDE_DIRS - where to find <nfb/nfb.h>, etc. |
| 11 | +# NFB_LIBRARIES - List of libraries when using nfb-framework. |
| 12 | +# NFB_FOUND - True if the framework has been found. |
| 13 | + |
| 14 | +# Use pkg-config (if available) to get the library directories and then use |
| 15 | +# these values as hints for find_path() and find_library() functions. |
| 16 | +find_package(PkgConfig QUIET) |
| 17 | +if (PKG_CONFIG_FOUND) |
| 18 | + pkg_check_modules(PC_NEMEA QUIET nemea) |
| 19 | +endif() |
| 20 | + |
| 21 | +find_path( |
| 22 | + NEMEA_INCLUDE_DIR unirec/unirec.h |
| 23 | + HINTS ${PC_NEMEA_INCLUDEDIR} ${PC_NEMEA_INCLUDE_DIRS} |
| 24 | + PATH_SUFFIXES include |
| 25 | +) |
| 26 | + |
| 27 | +message(STATUS "NEMEA_INCLUDE_DIR: ${NEMEA_INCLUDE_DIR}") |
| 28 | + |
| 29 | +find_library( |
| 30 | + NEMEA_LIBRARY NAMES unirec++ |
| 31 | + HINTS ${PC_NEMEA_LIBDIR} ${PC_NEMEA_LIBRARY_DIRS} |
| 32 | + PATH_SUFFIXES lib lib64 |
| 33 | +) |
| 34 | + |
| 35 | +message(STATUS "NEMEA_LIBRARY: ${NEMEA_LIBRARY}") |
| 36 | + |
| 37 | +if (PC_NEMEA_VERSION) |
| 38 | + set(NEMEA_VERSION_STRING ${PC_NEMEA_VERSION}) |
| 39 | +endif() |
| 40 | + |
| 41 | +# Handle find_package() arguments (i.e. QUIETLY and REQUIRED) and set |
| 42 | +# NEMEA_FOUND to TRUE if all listed variables are filled. |
| 43 | +include(FindPackageHandleStandardArgs) |
| 44 | +find_package_handle_standard_args( |
| 45 | + Nemea |
| 46 | + REQUIRED_VARS NEMEA_LIBRARY NEMEA_INCLUDE_DIR |
| 47 | + VERSION_VAR NEMEA_VERSION_STRING |
| 48 | +) |
| 49 | + |
| 50 | +set(NEMEA_INCLUDE_DIRS ${NFB_INCLUDE_DIR}) |
| 51 | +set(NEMEA_LIBRARIES ${NFB_LIBRARY}) |
| 52 | +mark_as_advanced(NEMEA_INCLUDE_DIR NEMEA_LIBRARY) |
| 53 | + |
| 54 | +if (NEMEA_FOUND) |
| 55 | + # Create imported library with all dependencies |
| 56 | + if (NOT TARGET nemea::nemea AND EXISTS "${NEMEA_LIBRARIES}") |
| 57 | + add_library(nemea::nemea UNKNOWN IMPORTED) |
| 58 | + set_target_properties(nemea::nemea PROPERTIES |
| 59 | + IMPORTED_LINK_INTERFACE_LANGUAGES "C" |
| 60 | + IMPORTED_LOCATION "${NEMEA_LIBRARIES}" |
| 61 | + INTERFACE_INCLUDE_DIRECTORIES "${NEMEA_INCLUDE_DIRS}") |
| 62 | + endif() |
| 63 | +else() |
| 64 | + message(FATAL_ERROR "Nemea not found") |
| 65 | + add_library(nfb::nfb INTERFACE IMPORTED) |
| 66 | +endif() |
0 commit comments