2021-07-23 13:48:17 +00:00
|
|
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
2021-07-21 16:16:48 +00:00
|
|
|
|
|
|
|
#[=======================================================================[.rst:
|
|
|
|
FindWebP
|
2021-07-23 13:48:17 +00:00
|
|
|
-------
|
2021-07-21 16:16:48 +00:00
|
|
|
|
2021-07-23 13:48:17 +00:00
|
|
|
Finds the WebP library.
|
2021-07-21 16:16:48 +00:00
|
|
|
|
|
|
|
Imported Targets
|
|
|
|
^^^^^^^^^^^^^^^^
|
|
|
|
|
2021-07-23 13:48:17 +00:00
|
|
|
This module provides the following imported targets, if found:
|
2021-07-21 16:16:48 +00:00
|
|
|
|
2021-07-23 13:48:17 +00:00
|
|
|
``WebP::WebP``
|
|
|
|
The WebP library
|
2021-07-21 16:16:48 +00:00
|
|
|
|
|
|
|
Result Variables
|
|
|
|
^^^^^^^^^^^^^^^^
|
|
|
|
|
2021-07-23 13:48:17 +00:00
|
|
|
This will define the following variables:
|
2021-07-21 16:16:48 +00:00
|
|
|
|
|
|
|
``WebP_FOUND``
|
2021-07-23 13:48:17 +00:00
|
|
|
True if the system has the WebP library.
|
2021-07-21 16:16:48 +00:00
|
|
|
``WebP_VERSION``
|
2021-07-23 13:48:17 +00:00
|
|
|
The version of the WebP library which was found.
|
2021-07-21 16:16:48 +00:00
|
|
|
``WebP_INCLUDE_DIRS``
|
2021-07-23 13:48:17 +00:00
|
|
|
Include directories needed to use WebP.
|
|
|
|
``WebP_LIBRARIES``
|
|
|
|
Libraries needed to link to WebP.
|
2021-07-21 16:16:48 +00:00
|
|
|
|
2021-07-23 13:48:17 +00:00
|
|
|
Cache Variables
|
|
|
|
^^^^^^^^^^^^^^^
|
2021-07-21 16:16:48 +00:00
|
|
|
|
2021-07-23 13:48:17 +00:00
|
|
|
The following cache variables may also be set:
|
2021-07-21 16:16:48 +00:00
|
|
|
|
2021-07-23 13:48:17 +00:00
|
|
|
``WebP_INCLUDE_DIR``
|
|
|
|
The directory containing ``decode.h``.
|
|
|
|
``WebP_LIBRARY``
|
|
|
|
The path to the Foo library.
|
2021-07-21 16:16:48 +00:00
|
|
|
|
2021-07-23 13:48:17 +00:00
|
|
|
#]=======================================================================]
|
2021-07-21 16:16:48 +00:00
|
|
|
|
2021-07-23 13:48:17 +00:00
|
|
|
if(NOT WebP_LIBRARY)
|
|
|
|
find_package(PkgConfig QUIET)
|
|
|
|
pkg_check_modules(PC_WebP QUIET libwebp)
|
2021-07-23 13:54:51 +00:00
|
|
|
set(WebP_VERSION ${PC_WebP_VERSION})
|
2021-07-23 13:48:17 +00:00
|
|
|
find_path(WebP_INCLUDE_DIR NAMES decode.h HINTS ${PC_WebP_INCLUDEDIR} ${PC_WebP_INCLUDE_DIR} PATH_SUFFIXES webp)
|
|
|
|
find_library(WebP_LIBRARY_RELEASE NAMES ${WebP_NAMES} webp HINTS ${PC_WebP_LIBDIR} ${PC_WebP_LIBRARY_DIRS})
|
|
|
|
find_library(WebP_LIBRARY_DEBUG NAMES ${WebP_NAMES} webpd HINTS ${PC_WebP_LIBDIR} ${PC_WebP_LIBRARY_DIRS})
|
|
|
|
include(SelectLibraryConfigurations)
|
|
|
|
select_library_configurations(WebP)
|
|
|
|
else()
|
|
|
|
file(TO_CMAKE_PATH "${WebP_LIBRARY}" WebP_LIBRARY)
|
|
|
|
endif()
|
2021-07-21 16:16:48 +00:00
|
|
|
|
2021-07-23 13:54:51 +00:00
|
|
|
if ("${WebP_FIND_VERSION}" VERSION_GREATER "${WebP_VERSION}")
|
|
|
|
if (WebP_VERSION)
|
|
|
|
message(FATAL_ERROR "Required version (" ${WebP_FIND_VERSION} ") is higher than found version (" ${PC_WebP_VERSION} ")")
|
|
|
|
else ()
|
|
|
|
message(WARNING "Cannot determine WebP version without pkg-config")
|
|
|
|
endif ()
|
|
|
|
endif ()
|
|
|
|
|
2021-07-21 16:16:48 +00:00
|
|
|
include(FindPackageHandleStandardArgs)
|
2021-07-23 16:41:07 +00:00
|
|
|
find_package_handle_standard_args(WebP
|
2021-07-23 13:48:17 +00:00
|
|
|
REQUIRED_VARS
|
2021-07-21 16:16:48 +00:00
|
|
|
WebP_LIBRARY
|
2021-07-23 13:48:17 +00:00
|
|
|
WebP_INCLUDE_DIR
|
2021-07-23 16:39:42 +00:00
|
|
|
VERSION_VAR WebP_VERSION
|
2021-07-21 16:16:48 +00:00
|
|
|
)
|
2021-07-23 13:48:17 +00:00
|
|
|
mark_as_advanced(WebP_INCLUDE_DIR WebP_LIBRARY)
|
2021-07-21 16:16:48 +00:00
|
|
|
|
|
|
|
if (WebP_FOUND)
|
2021-07-23 13:48:17 +00:00
|
|
|
set(WebP_LIBRARIES ${WebP_LIBRARY})
|
|
|
|
set(WebP_INCLUDE_DIRS ${WebP_INCLUDE_DIR})
|
|
|
|
if(NOT TARGET WebP::WebP)
|
|
|
|
add_library(WebP::WebP UNKNOWN IMPORTED)
|
|
|
|
set_target_properties(WebP::WebP PROPERTIES
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES ${WebP_INCLUDE_DIR}
|
|
|
|
IMPORTED_LINK_INTERFACE_LANGUAGES C)
|
|
|
|
|
|
|
|
if(WebP_LIBRARY_RELEASE)
|
|
|
|
set_property(TARGET WebP::WebP APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
|
|
|
set_target_properties(WebP::WebP PROPERTIES IMPORTED_LOCATION_RELEASE "${WebP_LIBRARY_RELEASE}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WebP_LIBRARY_DEBUG)
|
|
|
|
set_property(TARGET WebP::WebP APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
|
|
|
set_target_properties(WebP::WebP PROPERTIES IMPORTED_LOCATION_DEBUG "${WebP_LIBRARY_DEBUG}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT WebP_LIBRARY_RELEASE AND NOT WebP_LIBRARY_DEBUG)
|
|
|
|
set_target_properties(WebP::WebP PROPERTIES IMPORTED_LOCATION "${WebP_LIBRARY}")
|
|
|
|
endif()
|
|
|
|
endif()
|
2021-07-21 16:16:48 +00:00
|
|
|
endif ()
|