| 1 |
# SPDX-FileCopyrightText: 2022 L. E. Segovia <[email protected]> |
| 2 |
# SPDX-License-Identifier: BSD-3-Clause |
| 3 |
|
| 4 |
#[=======================================================================[.rst: |
| 5 |
FindRaqm |
| 6 |
-------------- |
| 7 |
|
| 8 |
Find Raqm headers and libraries. |
| 9 |
|
| 10 |
Imported Targets |
| 11 |
^^^^^^^^^^^^^^^^ |
| 12 |
|
| 13 |
``Raqm::Raqm`` |
| 14 |
The Raqm library, if found. |
| 15 |
|
| 16 |
Result Variables |
| 17 |
^^^^^^^^^^^^^^^^ |
| 18 |
|
| 19 |
This will define the following variables in your project: |
| 20 |
|
| 21 |
``Raqm_FOUND`` |
| 22 |
true if (the requested version of) Raqm is available. |
| 23 |
``Raqm_VERSION`` |
| 24 |
the version of Raqm. |
| 25 |
``Raqm_LIBRARIES`` |
| 26 |
the libraries to link against to use Raqm. |
| 27 |
``Raqm_INCLUDE_DIRS`` |
| 28 |
where to find the Raqm headers. |
| 29 |
``Raqm_COMPILE_OPTIONS`` |
| 30 |
this should be passed to target_compile_options(), if the |
| 31 |
target is not used for linking |
| 32 |
|
| 33 |
#]=======================================================================] |
| 34 |
|
| 35 |
include(FindPackageHandleStandardArgs) |
| 36 |
|
| 37 |
find_package(PkgConfig QUIET) |
| 38 |
|
| 39 |
if (PkgConfig_FOUND) |
| 40 |
pkg_check_modules(PC_RAQM QUIET raqm) |
| 41 |
set(Raqm_VERSION ${PC_RAQM_VERSION}) |
| 42 |
set(Raqm_COMPILE_OPTIONS "${PC_RAQM_CFLAGS} ${PC_RAQM_CFLAGS_OTHER}") |
| 43 |
endif () |
| 44 |
|
| 45 |
find_path(Raqm_INCLUDE_DIR |
| 46 |
NAMES raqm.h |
| 47 |
HINTS ${PC_RAQM_INCLUDEDIR} ${PC_RAQM_INCLUDE_DIRS} |
| 48 |
) |
| 49 |
|
| 50 |
find_library(Raqm_LIBRARY |
| 51 |
NAMES ${Raqm_NAMES} raqm |
| 52 |
HINTS ${PC_RAQM_LIBDIR} ${PC_RAQM_LIBRARY_DIRS} |
| 53 |
) |
| 54 |
|
| 55 |
if (NOT Raqm_VERSION AND Raqm_INCLUDE_DIR) |
| 56 |
file(READ ${Raqm_INCLUDE_DIR}/raqm-version.h _raqm_version_content) |
| 57 |
|
| 58 |
string(REGEX MATCH "#define RAQM_VERSION_STRING[ \t]+\"([0-9.]+)\"\n" _version_match ${_raqm_version_content}) |
| 59 |
|
| 60 |
if (_version_match) |
| 61 |
set(Raqm_VERSION "${CMAKE_MATCH_1}") |
| 62 |
else() |
| 63 |
if(NOT Raqm_FIND_QUIETLY) |
| 64 |
message(WARNING "Failed to get version information from ${Raqm_INCLUDE_DIR}/raqm-version.h") |
| 65 |
endif() |
| 66 |
endif() |
| 67 |
endif() |
| 68 |
|
| 69 |
if (Raqm_INCLUDE_DIR AND Raqm_LIBRARY) |
| 70 |
set(Raqm_FOUND ON) |
| 71 |
else() |
| 72 |
set(Raqm_FOUND OFF) |
| 73 |
endif() |
| 74 |
|
| 75 |
find_package_handle_standard_args(Raqm |
| 76 |
FOUND_VAR Raqm_FOUND |
| 77 |
REQUIRED_VARS Raqm_INCLUDE_DIR Raqm_LIBRARY |
| 78 |
HANDLE_COMPONENTS |
| 79 |
VERSION_VAR Raqm_VERSION |
| 80 |
) |
| 81 |
|
| 82 |
if (Raqm_FOUND) |
| 83 |
if (Raqm_LIBRARY AND NOT TARGET Raqm::Raqm) |
| 84 |
add_library(Raqm::Raqm UNKNOWN IMPORTED GLOBAL) |
| 85 |
set_target_properties(Raqm::Raqm PROPERTIES |
| 86 |
IMPORTED_LOCATION "${Raqm_LIBRARY}" |
| 87 |
INTERFACE_COMPILE_OPTIONS "${PC_RAQM_CFLAGS_OTHER}" |
| 88 |
INTERFACE_INCLUDE_DIRECTORIES "${Raqm_INCLUDE_DIR}" |
| 89 |
INTERFACE_LINK_LIBRARIES "${PC_RAQM_LINK_LIBRARIES}" |
| 90 |
INTERFACE_LINK_DIRECTORIES "${PC_RAQM_LIBDIR}" |
| 91 |
) |
| 92 |
endif () |
| 93 |
|
| 94 |
mark_as_advanced( |
| 95 |
Raqm_INCLUDE_DIR |
| 96 |
Raqm_LIBRARY |
| 97 |
) |
| 98 |
|
| 99 |
set(Raqm_LIBRARIES ${Raqm_LIBRARY}) |
| 100 |
set(Raqm_INCLUDE_DIRS ${Raqm_INCLUDE_DIR}) |
| 101 |
endif() |