|
| 1 | +#.rst: |
| 2 | +# Findinih |
| 3 | +# -------- |
| 4 | +# |
| 5 | +# Find the inih Library |
| 6 | +# |
| 7 | +# Imported Targets |
| 8 | +# ^^^^^^^^^^^^^^^^ |
| 9 | +# |
| 10 | +# This module defines the following :prop_tgt:`IMPORTED` targets: |
| 11 | +# |
| 12 | +# ``inih::inih`` |
| 13 | +# The ``inih`` library, if found. |
| 14 | +# |
| 15 | +# Result Variables |
| 16 | +# ^^^^^^^^^^^^^^^^ |
| 17 | +# |
| 18 | +# This module will set the following variables in your project: |
| 19 | +# |
| 20 | +# ``INIH_INCLUDE_DIRS`` |
| 21 | +# where to find inih headers. |
| 22 | +# ``INIH_LIBRARIES`` |
| 23 | +# the libraries to link against to use inih. |
| 24 | +# ``INIH_FOUND`` |
| 25 | +# true if the inih headers and libraries were found. |
| 26 | + |
| 27 | +find_package(PkgConfig QUIET) |
| 28 | + |
| 29 | +pkg_check_modules(PC_INIH QUIET libinih) |
| 30 | + |
| 31 | +# Look for the header file. |
| 32 | +find_path(INIH_INCLUDE_DIR |
| 33 | + NAMES ini.h |
| 34 | + HINTS ${PC_INIH_INCLUDE_DIRS}) |
| 35 | + |
| 36 | +# Look for the library. |
| 37 | +# Allow INIH_LIBRARY to be set manually, as the location of the inih library |
| 38 | +if(NOT INIH_LIBRARY) |
| 39 | + find_library(INIH_LIBRARY |
| 40 | + NAMES libinih inih |
| 41 | + HINTS ${PC_INIH_LIBRARY_DIRS}) |
| 42 | +endif() |
| 43 | + |
| 44 | +include(FindPackageHandleStandardArgs) |
| 45 | +find_package_handle_standard_args(inih |
| 46 | + REQUIRED_VARS INIH_LIBRARY INIH_INCLUDE_DIR) |
| 47 | + |
| 48 | +if(INIH_FOUND) |
| 49 | + set(INIH_INCLUDE_DIRS ${INIH_INCLUDE_DIR}) |
| 50 | + |
| 51 | + if(NOT INIH_LIBRARIES) |
| 52 | + set(INIH_LIBRARIES ${INIH_LIBRARIES}) |
| 53 | + endif() |
| 54 | + |
| 55 | + if(NOT TARGET inih::inih) |
| 56 | + add_library(inih::inih UNKNOWN IMPORTED) |
| 57 | + set_target_properties(inih::inih PROPERTIES |
| 58 | + INTERFACE_INCLUDE_DIRECTORIES "${INIH_INCLUDE_DIRS}" |
| 59 | + IMPORTED_LOCATION "${INIH_LIBRARY}") |
| 60 | + endif() |
| 61 | +endif() |
| 62 | + |
| 63 | +mark_as_advanced(INIH_INCLUDE_DIR INIH_LIBRARY) |
0 commit comments