Warning, /graphics/krita/cmake/modules/FindWebP.cmake is written in an unsupported language. File is not indexed.

0001 # Copyright (C) 2020 Sony Interactive Entertainment Inc.
0002 # Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
0003 # Copyright (C) 2013 Igalia S.L.
0004 # Copyright (C) 2021 L. E. Segovia <amy@amyspark.me>
0005 #
0006 # Redistribution and use in source and binary forms, with or without
0007 # modification, are permitted provided that the following conditions
0008 # are met:
0009 # 1.  Redistributions of source code must retain the above copyright
0010 #     notice, this list of conditions and the following disclaimer.
0011 # 2.  Redistributions in binary form must reproduce the above copyright
0012 #     notice, this list of conditions and the following disclaimer in the
0013 #     documentation and/or other materials provided with the distribution.
0014 #
0015 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
0016 # IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
0017 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
0018 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
0019 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
0020 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
0021 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
0022 # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
0023 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
0024 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
0025 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0026 
0027 #[=======================================================================[.rst:
0028 FindWebP
0029 --------------
0030 
0031 Find WebP headers and libraries.
0032 
0033 Imported Targets
0034 ^^^^^^^^^^^^^^^^
0035 
0036 ``WebP::webp``
0037   The WebP library, if found.
0038 
0039 ``WebP::webpdemux``
0040   The WebP demux library, if found.
0041 
0042 ``WebP::libwebpmux``
0043   The WebP mux library, if found.
0044 
0045 ``WebP::decoder``
0046   The WebP decoder library, if found.
0047 
0048 ``WebP::sharpyuv``
0049   The WebP Sharp RGB to YUV420 conversion library, if found.
0050 
0051 Result Variables
0052 ^^^^^^^^^^^^^^^^
0053 
0054 This will define the following variables in your project:
0055 
0056 ``WebP_FOUND``
0057   true if (the requested version of) WebP is available.
0058 ``WebP_VERSION``
0059   the version of WebP.
0060 ``WebP_LIBRARIES``
0061   the libraries to link against to use WebP.
0062 ``WebP_INCLUDE_DIRS``
0063   where to find the WebP headers.
0064 ``WebP_COMPILE_OPTIONS``
0065   this should be passed to target_compile_options(), if the
0066   target is not used for linking
0067 
0068 #]=======================================================================]
0069 
0070 include(FindPackageHandleStandardArgs)
0071 
0072 set(PC_WEBP_CONFIG_DIR CACHE STRING "PkgConfig path for locating the package modules")
0073 foreach(_dir ${CMAKE_PREFIX_PATH})
0074     list(APPEND PC_WEBP_CONFIG_DIR ${_dir}/share/WebP/cmake)
0075 endforeach()
0076 mark_as_advanced(PC_WEBP_CONFIG_DIR)
0077 
0078 find_package(WebP QUIET NO_MODULE
0079     HINTS ${PC_WEBP_CONFIG_DIR} /usr/share/WebP/cmake /usr/local/share/WebP/cmake
0080 )
0081 mark_as_advanced(WebP_DIR)
0082 
0083 # if we found the WebP CMake package then we are done, and
0084 # can print what we found and return.
0085 if(WebP_FOUND)
0086     if (TARGET WebP::webp)
0087         set(WebP_webp_FOUND ON)
0088     else ()
0089         set(WebP_webp_FOUND OFF)
0090     endif ()
0091 
0092     if (TARGET WebP::webpdemux)
0093         set(WebP_demux_FOUND ON)
0094     else ()
0095         set(WebP_demux_FOUND OFF)
0096     endif ()
0097 
0098     if (TARGET WebP::libwebpmux)
0099         set(WebP_mux_FOUND ON)
0100     else ()
0101         set(WebP_mux_FOUND OFF)
0102     endif ()
0103 
0104     if (TARGET WebP::decoder)
0105         set(WebP_decoder_FOUND ON)
0106     else ()
0107         set(WebP_decoder_FOUND OFF)
0108     endif ()
0109 
0110     if (TARGET WebP::sharpyuv)
0111         set(WebP_sharpyuv_FOUND ON)
0112     else ()
0113         set(WebP_sharpyuv_FOUND OFF)
0114     endif ()
0115 
0116     find_package_handle_standard_args(WebP 
0117         FOUND_VAR WebP_FOUND
0118         HANDLE_COMPONENTS
0119         CONFIG_MODE
0120     )
0121     return()
0122 endif()
0123 
0124 find_package(PkgConfig QUIET)
0125 
0126 if (PkgConfig_FOUND)
0127     pkg_check_modules(PC_WEBP QUIET libwebp)
0128     set(WebP_VERSION ${PC_WEBP_VERSION})
0129     set(WebP_COMPILE_OPTIONS "${PC_WEBP_CFLAGS};${PC_WEBP_CFLAGS_OTHER}")
0130 
0131     pkg_check_modules(PC_WEBP_DECODER QUIET libwebpdecoder)
0132 
0133     pkg_check_modules(PC_WEBP_DEMUX QUIET libwebpdemux)
0134 
0135     pkg_check_modules(PC_WEBP_DECODER QUIET libwebpmux)
0136 
0137     pkg_check_modules(PC_WEBP_SHARPYUV QUIET libsharpyuv)
0138 endif ()
0139 
0140 find_path(WebP_INCLUDE_DIR
0141     NAMES webp/decode.h
0142     HINTS ${PC_WEBP_INCLUDEDIR} ${PC_WEBP_INCLUDE_DIRS}
0143 )
0144 
0145 find_library(WebP_LIBRARY
0146     NAMES ${WebP_NAMES} webp libwebp
0147     HINTS ${PC_WEBP_LIBDIR} ${PC_WEBP_LIBRARY_DIRS}
0148 )
0149 
0150 # There's nothing in the WebP headers that could be used to detect the exact
0151 # WebP version being used so don't attempt to do so. A version can only be found
0152 # through pkg-config
0153 if (NOT WebP_VERSION)
0154     message(WARNING "Cannot determine WebP version without pkg-config")
0155 endif ()
0156 
0157 if (WebP_INCLUDE_DIR AND WebP_LIBRARY)
0158     set(WebP_webp_FOUND ON)
0159 else()
0160     set(WebP_webp_FOUND OFF)
0161 endif()
0162 
0163 # Find components
0164 if ("demux" IN_LIST WebP_FIND_COMPONENTS)
0165     find_library(WebP_DEMUX_LIBRARY
0166         NAMES ${WebP_DEMUX_NAMES} webpdemux libwebpdemux
0167         HINTS ${PC_WEBP_LIBDIR} ${PC_WEBP_LIBRARY_DIRS}
0168     )
0169 
0170     if (WebP_DEMUX_LIBRARY)
0171         set(WebP_demux_FOUND ON)
0172     else ()
0173         set(WebP_demux_FOUND OFF)
0174     endif ()
0175 endif ()
0176 
0177 if ("mux" IN_LIST WebP_FIND_COMPONENTS)
0178     find_library(WebP_MUX_LIBRARY
0179         NAMES ${WebP_MUX_NAMES} webpmux libwebpmux
0180         HINTS ${PC_WEBP_LIBDIR} ${PC_WEBP_LIBRARY_DIRS}
0181     )
0182 
0183     if (WebP_MUX_LIBRARY)
0184         set(WebP_mux_FOUND ON)
0185     else ()
0186         set(WebP_mux_FOUND OFF)
0187     endif ()
0188 endif ()
0189 
0190 if ("decoder" IN_LIST WebP_FIND_COMPONENTS)
0191     find_library(WebP_DECODER_LIBRARY
0192         NAMES ${WebP_DECODER_NAMES} webpdecoder libwebpdecoder
0193         HINTS ${PC_WEBP_LIBDIR} ${PC_WEBP_LIBRARY_DIRS}
0194     )
0195 
0196     if (WebP_DECODER_LIBRARY)
0197         set(WebP_decoder_FOUND ON)
0198     else ()
0199         set(WebP_decoder_FOUND OFF)
0200     endif ()
0201 endif ()
0202 
0203 # SharpYUV is a dependency of WebP, should be looked up
0204 # if neither the CMake module nor pkgconf are available
0205 # (this could only happen, in theory, in Windows MSVC)
0206 if ("sharpyuv" IN_LIST WebP_FIND_COMPONENTS OR WebP_webp_FOUND)
0207     find_library(WebP_SHARPYUV_LIBRARY
0208         NAMES ${WebP_DECODER_NAMES} sharpyuv libsharpyuv
0209         HINTS ${PC_WEBP_LIBDIR} ${PC_WEBP_LIBRARY_DIRS}
0210     )
0211 
0212     if (WebP_SHARPYUV_LIBRARY)
0213         set(WebP_sharpyuv_FOUND ON)
0214     else ()
0215         set(WebP_sharpyuv_FOUND OFF)
0216     endif ()
0217 endif ()
0218 
0219 find_package_handle_standard_args(WebP
0220     FOUND_VAR WebP_FOUND
0221     REQUIRED_VARS WebP_INCLUDE_DIR WebP_LIBRARY
0222     HANDLE_COMPONENTS
0223     VERSION_VAR WebP_VERSION
0224 )
0225 
0226 if (WebP_FOUND)
0227 if (WebP_LIBRARY AND NOT TARGET WebP::webp)
0228     add_library(WebP::webp UNKNOWN IMPORTED GLOBAL)
0229     set_target_properties(WebP::webp PROPERTIES
0230         IMPORTED_LOCATION "${WebP_LIBRARY}"
0231         INTERFACE_COMPILE_OPTIONS "${PC_WEBP_CFLAGS};${PC_WEBP_CFLAGS_OTHER}"
0232         INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIR};${PC_WEBP_INCLUDE_DIRS}"
0233         INTERFACE_LINK_LIBRARIES "${PC_WEBP_LINK_LIBRARIES}"
0234     )
0235 endif ()
0236 
0237 if (WebP_DEMUX_LIBRARY AND NOT TARGET WebP::webpdemux)
0238     add_library(WebP::webpdemux UNKNOWN IMPORTED GLOBAL)
0239     set_target_properties(WebP::webpdemux PROPERTIES
0240         IMPORTED_LOCATION "${WebP_DEMUX_LIBRARY}"
0241         INTERFACE_COMPILE_OPTIONS "${PC_WEBP_DEMUX_CFLAGS};${PC_WEBP_DEMUX_CFLAGS_OTHER}"
0242         INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIR};${PC_WEBP_DEMUX_INCLUDE_DIRS}"
0243         INTERFACE_LINK_LIBRARIES "${PC_WEBP_DEMUX_LINK_LIBRARIES}"
0244     )
0245 endif ()
0246 
0247 if (WebP_MUX_LIBRARY AND NOT TARGET WebP::libwebpmux)
0248     add_library(WebP::libwebpmux UNKNOWN IMPORTED GLOBAL)
0249     set_target_properties(WebP::libwebpmux PROPERTIES
0250         IMPORTED_LOCATION "${WebP_MUX_LIBRARY}"
0251         INTERFACE_COMPILE_OPTIONS "${PC_WEBP_MUX_CFLAGS};${PC_WEBP_MUX_CFLAGS_OTHER}"
0252         INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIR};${PC_WEBP_MUX_INCLUDE_DIRS}"
0253         INTERFACE_LINK_LIBRARIES "${PC_WEBP_MUX_LINK_LIBRARIES}"
0254     )
0255 endif ()
0256 
0257 if (WebP_DECODER_LIBRARY AND NOT TARGET WebP::webpdecoder)
0258     add_library(WebP::webpdecoder UNKNOWN IMPORTED GLOBAL)
0259     set_target_properties(WebP::webpdecoder PROPERTIES
0260         IMPORTED_LOCATION "${WebP_DECODER_LIBRARY}"
0261         INTERFACE_COMPILE_OPTIONS "${PC_WEBP_DECODER_CFLAGS};${PC_WEBP_DECODER_CFLAGS_OTHER}"
0262         INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIR};${PC_WEBP_DECODER_INCLUDE_DIRS}"
0263         INTERFACE_LINK_LIBRARIES "${PC_WEBP_DECODER_LINK_LIBRARIES}"
0264     )
0265 endif ()
0266 
0267 if (WebP_SHARPYUV_LIBRARY AND NOT TARGET WebP::sharpyuv)
0268     add_library(WebP::sharpyuv UNKNOWN IMPORTED GLOBAL)
0269     set_target_properties(WebP::sharpyuv PROPERTIES
0270         IMPORTED_LOCATION "${WebP_SHARPYUV_LIBRARY}"
0271         INTERFACE_COMPILE_OPTIONS "${PC_WEBP_SHARPYUV_CFLAGS};${PC_WEBP_SHARPYUV_CFLAGS_OTHER}"
0272         INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIR};${PC_WEBP_SHARPYUV_INCLUDE_DIRS}"
0273         INTERFACE_LINK_LIBRARIES "${PC_WEBP_SHARPYUV_LINK_LIBRARIES}"
0274     )
0275 endif ()
0276 
0277 mark_as_advanced(
0278     WebP_INCLUDE_DIR
0279     WebP_LIBRARY
0280     WebP_DEMUX_LIBRARY
0281     WebP_MUX_LIBRARY
0282     WebP_DECODER_LIBRARY
0283     WebP_SHARPYUV_LIBRARY
0284 )
0285 
0286 set(WebP_LIBRARIES ${WebP_LIBRARY} ${WebP_DEMUX_LIBRARY} ${WebP_MUX_LIBRARY} ${WebP_DECODER_LIBRARY} ${WebP_SHARPYUV_LIBRARY})
0287 set(WebP_INCLUDE_DIRS ${WebP_INCLUDE_DIR})
0288 
0289 endif()