| 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 |
FindWebP |
| 6 |
-------- |
| 7 |
|
| 8 |
Find the native WebP includes and library. |
| 9 |
|
| 10 |
IMPORTED Targets |
| 11 |
^^^^^^^^^^^^^^^^ |
| 12 |
|
| 13 |
This module defines :prop_tgt:`IMPORTED` target ``WebP::webp``, if |
| 14 |
WebP has been found. |
| 15 |
|
| 16 |
Result Variables |
| 17 |
^^^^^^^^^^^^^^^^ |
| 18 |
|
| 19 |
This module defines the following variables: |
| 20 |
|
| 21 |
:: |
| 22 |
|
| 23 |
WebP_INCLUDE_DIRS - where to find webp/*.h, etc. |
| 24 |
WebP_LIBRARIES - List of libraries when using webp. |
| 25 |
WebP_FOUND - True if webp found. |
| 26 |
|
| 27 |
Debug and Release variants are found separately. |
| 28 |
#]=======================================================================] |
| 29 |
|
| 30 |
# Standard names to search for |
| 31 |
set(WebP_NAMES webp) |
| 32 |
set(WebP_NAMES_DEBUG webpd) |
| 33 |
|
| 34 |
find_path(WebP_INCLUDE_DIR |
| 35 |
NAMES webp/decode.h |
| 36 |
PATH_SUFFIXES include) |
| 37 |
|
| 38 |
# Allow WebP_LIBRARY to be set manually, as the location of the webp library |
| 39 |
if(NOT WebP_LIBRARY) |
| 40 |
find_library(WebP_LIBRARY_RELEASE |
| 41 |
NAMES ${WebP_NAMES} |
| 42 |
PATH_SUFFIXES lib) |
| 43 |
find_library(WebP_LIBRARY_DEBUG |
| 44 |
NAMES ${WebP_NAMES_DEBUG} |
| 45 |
PATH_SUFFIXES lib) |
| 46 |
|
| 47 |
include(SelectLibraryConfigurations) |
| 48 |
select_library_configurations(WebP) |
| 49 |
endif() |
| 50 |
|
| 51 |
unset(WebP_NAMES) |
| 52 |
unset(WebP_NAMES_DEBUG) |
| 53 |
|
| 54 |
mark_as_advanced(WebP_INCLUDE_DIR) |
| 55 |
|
| 56 |
include(FindPackageHandleStandardArgs) |
| 57 |
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WebP |
| 58 |
REQUIRED_VARS WebP_LIBRARY WebP_INCLUDE_DIR) |
| 59 |
|
| 60 |
if(WebP_FOUND) |
| 61 |
set(WebP_INCLUDE_DIRS ${WebP_INCLUDE_DIR}) |
| 62 |
|
| 63 |
if(NOT WebP_LIBRARIES) |
| 64 |
set(WebP_LIBRARIES ${WebP_LIBRARY}) |
| 65 |
endif() |
| 66 |
|
| 67 |
if(NOT TARGET WebP::webp) |
| 68 |
add_library(WebP::webp UNKNOWN IMPORTED) |
| 69 |
set_target_properties(WebP::webp PROPERTIES |
| 70 |
INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIRS}") |
| 71 |
|
| 72 |
if(WebP_LIBRARY_RELEASE) |
| 73 |
set_property(TARGET WebP::webp APPEND PROPERTY |
| 74 |
IMPORTED_CONFIGURATIONS RELEASE) |
| 75 |
set_target_properties(WebP::webp PROPERTIES |
| 76 |
IMPORTED_LOCATION_RELEASE "${WebP_LIBRARY_RELEASE}") |
| 77 |
endif() |
| 78 |
|
| 79 |
if(WebP_LIBRARY_DEBUG) |
| 80 |
set_property(TARGET WebP::webp APPEND PROPERTY |
| 81 |
IMPORTED_CONFIGURATIONS DEBUG) |
| 82 |
set_target_properties(WebP::webp PROPERTIES |
| 83 |
IMPORTED_LOCATION_DEBUG "${WebP_LIBRARY_DEBUG}") |
| 84 |
endif() |
| 85 |
|
| 86 |
if(NOT WebP_LIBRARY_RELEASE AND NOT WebP_LIBRARY_DEBUG) |
| 87 |
set_target_properties(WebP::webp PROPERTIES |
| 88 |
IMPORTED_LOCATION "${WebP_LIBRARY}") |
| 89 |
endif() |
| 90 |
endif() |
| 91 |
endif() |