1# - Find the native webp library and includes
2#
3# This module defines
4#  WebP_INCLUDE_DIR, where to libwebp headers.
5#  WebP_LIBRARIES, the libraries to link against to support webp.
6#  WebP_FOUND, If false, do not enable webp export support.
7# also defined, but not for general use are
8#  WebP_LIBRARY, where to find the webp library.
9
10#=============================================================================
11# Copyright 2013 Google Inc.
12#=============================================================================
13
14include(LibFindMacros)
15
16# Use pkg-config to get hints about paths
17libfind_pkg_check_modules(WebP_PKGCONF libwebp)
18
19
20find_path(WebP_INCLUDE_DIR NAMES webp/encode.h HINTS ${WebP_PKGCONF_INCLUDE_DIRS})
21mark_as_advanced(WebP_INCLUDE_DIR)
22
23set(WebP_NAMES ${WebP_NAMES} webp libwebp)
24find_library(WebP_LIBRARY NAMES ${WebP_NAMES} HINTS ${WebP_PKGCONF_LIBRARY_DIRS})
25mark_as_advanced(WebP_LIBRARY)
26
27include(FindPackageHandleStandardArgs)
28find_package_handle_standard_args(WebP DEFAULT_MSG WebP_LIBRARY WebP_INCLUDE_DIR)
29
30
31if(WebP_FIND_VERSION)
32  cmake_minimum_required(VERSION 3.10.0)
33  set(WebP_FAILED_VERSION_CHECK true)
34
35  if(WebP_FIND_VERSION_EXACT)
36    if(WebP_PKGCONF_VERSION VERSION_EQUAL WebP_FIND_VERSION)
37      set(WebP_FAILED_VERSION_CHECK false)
38    endif()
39  else()
40    if(WebP_PKGCONF_VERSION VERSION_EQUAL WebP_FIND_VERSION OR
41       WebP_PKGCONF_VERSION VERSION_GREATER WebP_FIND_VERSION)
42      set(WebP_FAILED_VERSION_CHECK false)
43    endif()
44  endif()
45
46  if(WebP_FAILED_VERSION_CHECK)
47    if(WebP_FIND_REQUIRED AND NOT WebP_FIND_QUIETLY)
48        if(WebP_FIND_VERSION_EXACT)
49            message(FATAL_ERROR "WebP version check failed.  Version ${WebP_PKGCONF_VERSION} was found, version ${WebP_FIND_VERSION} is needed exactly.")
50        else(WebP_FIND_VERSION_EXACT)
51            message(FATAL_ERROR "WebP version check failed.  Version ${WebP_PKGCONF_VERSION} was found, at least version ${WebP_FIND_VERSION} is required")
52        endif(WebP_FIND_VERSION_EXACT)
53    endif(WebP_FIND_REQUIRED AND NOT WebP_FIND_QUIETLY)
54
55    set(WebP_FOUND false)
56  endif(WebP_FAILED_VERSION_CHECK)
57
58endif(WebP_FIND_VERSION)
59
60
61IF(WebP_FOUND)
62  SET(WebP_LIBRARIES ${WebP_LIBRARY})
63  SET(WebP_INCLUDE_DIRS ${WebP_INCLUDE_DIR})
64ENDIF(WebP_FOUND)
65