]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - cmake/FindWebP.cmake
fix include
[xonotic/netradiant.git] / cmake / FindWebP.cmake
1 # - Find WebP library
2 # Find the native WebP headers and libraries.
3 #
4 #  WEBP_INCLUDE_DIRS - where to find webp/decode.h, etc.
5 #  WEBP_LIBRARIES    - List of libraries when using webp.
6 #  WEBP_FOUND        - True if webp is found.
7
8 #=============================================================================
9 #Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
10 #All rights reserved.
11 #
12 #Redistribution and use in source and binary forms, with or without
13 # modification, are permitted provided that the following conditions are met:
14 #
15 #* Redistributions of source code must retain the above copyright notice,
16 #this list of conditions and the following disclaimer.
17 #
18 #* Redistributions in binary form must reproduce the above copyright notice,
19 #this list of conditions and the following disclaimer in the documentation
20 #and/or other materials provided with the distribution.
21 #
22 #* Neither the names of Kitware, Inc., the Insight Software Consortium, nor
23 #the names of their contributors may be used to endorse or promote products
24 #derived from this software without specific prior written  permission.
25 #
26 #THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 #AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 #IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 #ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
30 #LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 #CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 #SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 #INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 #CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 #ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 #POSSIBILITY OF SUCH DAMAGE.
37 #=============================================================================
38
39 # Look for the header file.
40 FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h)
41 MARK_AS_ADVANCED(WEBP_INCLUDE_DIR)
42
43 # Look for the library.
44 FIND_LIBRARY(WEBP_LIBRARY NAMES webp)
45 MARK_AS_ADVANCED(WEBP_LIBRARY)
46
47 # handle the QUIETLY and REQUIRED arguments and set WEBFOUND_FOUND to TRUE if
48 # all listed variables are TRUE
49 INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
50 FIND_PACKAGE_HANDLE_STANDARD_ARGS(WebP DEFAULT_MSG WEBP_LIBRARY WEBP_INCLUDE_DIR)
51
52 SET(WEBP_LIBRARIES ${WEBP_LIBRARY})
53 SET(WEBP_INCLUDE_DIRS ${WEBP_INCLUDE_DIR})
54
55 SET(_WEBP_RQ_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
56
57 if(NOT DEFINED _WEBP_COMPILATION_TEST)
58   INCLUDE (CheckCSourceCompiles)
59   SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${WEBP_INCLUDE_DIRS})
60   CHECK_C_SOURCE_COMPILES("#include <webp/decode.h>
61   int main(void) {
62   #if WEBP_DECODER_ABI_VERSION < 0x0200
63   error; // Deliberate compile-time error
64   #endif
65   return 0;
66   }"
67    _WEBP_COMPILATION_TEST)
68   SET(CMAKE_REQUIRED_INCLUDES ${_WEBP_RQ_INCLUDES})
69 endif()
70
71 if(NOT _WEBP_COMPILATION_TEST)
72   set( USE_INTERNAL_WEBP 1 )
73 endif()