| 1 |
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
| 2 |
# file Copyright.txt or https://cmake.org/licensing for details. |
| 3 |
|
| 4 |
#[=======================================================================[.rst: |
| 5 |
FindLerc |
| 6 |
-------- |
| 7 |
|
| 8 |
Find the native Lerc includes and library. |
| 9 |
|
| 10 |
IMPORTED Targets |
| 11 |
^^^^^^^^^^^^^^^^ |
| 12 |
|
| 13 |
This module defines :prop_tgt:`IMPORTED` target ``LERC::LERC``, if |
| 14 |
LERC has been found. |
| 15 |
|
| 16 |
Result Variables |
| 17 |
^^^^^^^^^^^^^^^^ |
| 18 |
|
| 19 |
This module defines the following variables: |
| 20 |
|
| 21 |
:: |
| 22 |
|
| 23 |
LERC_INCLUDE_DIRS - where to find Lerc_c_api.h, etc. |
| 24 |
LERC_LIBRARIES - List of libraries when using LERC. |
| 25 |
LERC_FOUND - True if LERC found. |
| 26 |
LERC_VERSION_STRING - version number as a string (ex: "4.0.1") |
| 27 |
|
| 28 |
#]=======================================================================] |
| 29 |
|
| 30 |
# Standard names to search for |
| 31 |
set(LERC_NAMES LercLib Lerc) |
| 32 |
|
| 33 |
find_path(LERC_INCLUDE_DIR |
| 34 |
NAMES Lerc_c_api.h |
| 35 |
PATH_SUFFIXES include) |
| 36 |
|
| 37 |
# Allow LERC_LIBRARY to be set manually, as the location of the deflate library |
| 38 |
if(NOT LERC_LIBRARY) |
| 39 |
find_library(LERC_LIBRARY_RELEASE |
| 40 |
NAMES ${LERC_NAMES} |
| 41 |
PATH_SUFFIXES lib) |
| 42 |
|
| 43 |
include(SelectLibraryConfigurations) |
| 44 |
select_library_configurations(LERC) |
| 45 |
endif() |
| 46 |
|
| 47 |
unset(LERC_NAMES) |
| 48 |
|
| 49 |
mark_as_advanced(LERC_INCLUDE_DIR) |
| 50 |
|
| 51 |
if(LERC_INCLUDE_DIR AND EXISTS "${LERC_INCLUDE_DIR}/Lerc_c_api.h") |
| 52 |
file(STRINGS "${LERC_INCLUDE_DIR}/Lerc_c_api.h" LERC_H REGEX "^#define[\t ]+LERC_VERSION_[A-Z]+[\t ]+[0-9]+") |
| 53 |
string(REGEX REPLACE "^.*#define[\t ]+LERC_VERSION_MAJOR[\t ]+([0-9]+).*$" "\\1" LERC_VERSION_MAJOR "${LERC_H}") |
| 54 |
string(REGEX REPLACE "^.*#define[\t ]+LERC_VERSION_MINOR[\t ]+([0-9]+).*$" "\\1" LERC_VERSION_MINOR "${LERC_H}") |
| 55 |
string(REGEX REPLACE "^.*#define[\t ]+LERC_VERSION_PATCH[\t ]+([0-9]+).*$" "\\1" LERC_VERSION_PATCH "${LERC_H}") |
| 56 |
set(LERC_VERSION_STRING "${LERC_VERSION_MAJOR}.${LERC_VERSION_MINOR}.${LERC_VERSION_PATCH}") |
| 57 |
unset(LERC_H) |
| 58 |
unset(LERC_VERSION_MAJOR) |
| 59 |
unset(LERC_VERSION_MINOR) |
| 60 |
unset(LERC_VERSION_PATCH) |
| 61 |
endif() |
| 62 |
|
| 63 |
|
| 64 |
include(FindPackageHandleStandardArgs) |
| 65 |
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LERC |
| 66 |
REQUIRED_VARS LERC_LIBRARY LERC_INCLUDE_DIR |
| 67 |
VERSION_VAR LERC_VERSION_STRING) |
| 68 |
|
| 69 |
if(LERC_FOUND) |
| 70 |
set(LERC_INCLUDE_DIRS ${LERC_INCLUDE_DIR}) |
| 71 |
|
| 72 |
if(NOT LERC_LIBRARIES) |
| 73 |
set(LERC_LIBRARIES ${LERC_LIBRARY}) |
| 74 |
endif() |
| 75 |
|
| 76 |
if(NOT TARGET LERC::LERC) |
| 77 |
add_library(LERC::LERC UNKNOWN IMPORTED) |
| 78 |
set_target_properties(LERC::LERC PROPERTIES |
| 79 |
INTERFACE_INCLUDE_DIRECTORIES "${LERC_INCLUDE_DIRS}") |
| 80 |
|
| 81 |
if(LERC_LIBRARY_RELEASE) |
| 82 |
set_property(TARGET LERC::LERC APPEND PROPERTY |
| 83 |
IMPORTED_CONFIGURATIONS RELEASE) |
| 84 |
set_target_properties(LERC::LERC PROPERTIES |
| 85 |
IMPORTED_LOCATION_RELEASE "${LERC_LIBRARY_RELEASE}") |
| 86 |
endif() |
| 87 |
|
| 88 |
if(LERC_LIBRARY_DEBUG) |
| 89 |
set_property(TARGET LERC::LERC APPEND PROPERTY |
| 90 |
IMPORTED_CONFIGURATIONS DEBUG) |
| 91 |
set_target_properties(LERC::LERC PROPERTIES |
| 92 |
IMPORTED_LOCATION_DEBUG "${LERC_LIBRARY_DEBUG}") |
| 93 |
endif() |
| 94 |
|
| 95 |
if(NOT LERC_LIBRARY_RELEASE AND NOT LERC_LIBRARY_DEBUG) |
| 96 |
set_target_properties(LERC::LERC PROPERTIES |
| 97 |
IMPORTED_LOCATION "${LERC_LIBRARY}") |
| 98 |
endif() |
| 99 |
endif() |
| 100 |
endif() |