| 1 |
# - Try to find the popt options processing library |
| 2 |
# The module will set the following variables |
| 3 |
# |
| 4 |
# POPT_FOUND - System has popt |
| 5 |
# POPT_INCLUDE_DIR - The popt include directory |
| 6 |
# POPT_LIBRARY - The libraries needed to use popt |
| 7 |
# POPT_VERSION - The version of popt that was found |
| 8 |
# |
| 9 |
# This module also supports version requirements, e.g. |
| 10 |
# find_package(POPT 1.14 REQUIRED). popt does not expose its release |
| 11 |
# version in popt.h, so the version is obtained from pkg-config. A version |
| 12 |
# requirement therefore needs pkg-config and the popt.pc file to be available. |
| 13 |
|
| 14 |
# use pkg-config to get the directories and then use these values |
| 15 |
# in the FIND_PATH() and FIND_LIBRARY() calls |
| 16 |
|
| 17 |
find_package(PkgConfig QUIET) |
| 18 |
if (PKG_CONFIG_FOUND) |
| 19 |
pkg_search_module(PC_POPT QUIET popt) |
| 20 |
endif() |
| 21 |
|
| 22 |
# Find the include directories |
| 23 |
find_path(POPT_INCLUDE_DIR |
| 24 |
NAMES popt.h |
| 25 |
HINTS |
| 26 |
${PC_POPT_INCLUDEDIR} |
| 27 |
${PC_POPT_INCLUDE_DIRS} |
| 28 |
DOC "Path containing the popt.h include file" |
| 29 |
) |
| 30 |
|
| 31 |
find_library(POPT_LIBRARY |
| 32 |
NAMES popt |
| 33 |
HINTS |
| 34 |
${PC_POPT_LIBRARYDIR} |
| 35 |
${PC_POPT_LIBRARY_DIRS} |
| 36 |
DOC "popt library path" |
| 37 |
) |
| 38 |
|
| 39 |
include(FindPackageHandleStandardArgs) |
| 40 |
|
| 41 |
find_package_handle_standard_args(POPT |
| 42 |
REQUIRED_VARS POPT_INCLUDE_DIR POPT_LIBRARY |
| 43 |
VERSION_VAR PC_POPT_VERSION) |
| 44 |
|
| 45 |
mark_as_advanced(POPT_INCLUDE_DIR POPT_LIBRARY) |
| 46 |
|
| 47 |
if(POPT_FOUND AND NOT TARGET popt::popt) |
| 48 |
add_library(popt::popt UNKNOWN IMPORTED) |
| 49 |
set_target_properties(popt::popt PROPERTIES |
| 50 |
IMPORTED_LINK_INTERFACE_LANGUAGES "C" |
| 51 |
IMPORTED_LOCATION "${POPT_LIBRARY}" |
| 52 |
INTERFACE_INCLUDE_DIRECTORIES "${POPT_INCLUDE_DIR}" |
| 53 |
) |
| 54 |
endif() |