diff options
Diffstat (limited to 'build_files')
-rw-r--r-- | build_files/cmake/Modules/FindWebP.cmake | 77 | ||||
-rw-r--r-- | build_files/cmake/platform/platform_apple.cmake | 9 | ||||
-rw-r--r-- | build_files/cmake/platform/platform_unix.cmake | 8 | ||||
-rw-r--r-- | build_files/cmake/platform/platform_win32.cmake | 8 |
4 files changed, 102 insertions, 0 deletions
diff --git a/build_files/cmake/Modules/FindWebP.cmake b/build_files/cmake/Modules/FindWebP.cmake new file mode 100644 index 00000000000..240dbad2b4e --- /dev/null +++ b/build_files/cmake/Modules/FindWebP.cmake @@ -0,0 +1,77 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2022 Blender Foundation. + +# - Find WebP library +# Find the native WebP includes and library +# This module defines +# WEBP_INCLUDE_DIRS, where to find WebP headers, Set when WebP is found. +# WEBP_LIBRARIES, libraries to link against to use WebP. +# WEBP_ROOT_DIR, The base directory to search for WebP. +# This can also be an environment variable. +# WEBP_FOUND, If false, do not try to use WebP. +# +# also defined, but not for general use are +# WEBP_LIBRARY, where to find the WEBP library. + +# If WEBP_ROOT_DIR was defined in the environment, use it. +IF(NOT WEBP_ROOT_DIR AND NOT $ENV{WEBP_ROOT_DIR} STREQUAL "") + SET(WEBP_ROOT_DIR $ENV{WEBP_ROOT_DIR}) +ENDIF() + +SET(_webp_SEARCH_DIRS + ${WEBP_ROOT_DIR} + /opt/lib/webp +) + +FIND_PATH(WEBP_INCLUDE_DIR + NAMES + webp/types.h + HINTS + ${_webp_SEARCH_DIRS} + PATH_SUFFIXES + include +) + +SET(_webp_FIND_COMPONENTS + webp + webpmux + webpdemux + ) + +SET(_webp_LIBRARIES) +FOREACH(COMPONENT ${_webp_FIND_COMPONENTS}) + STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT) + + FIND_LIBRARY(WEBP_${UPPERCOMPONENT}_LIBRARY + NAMES + ${COMPONENT} + NAMES_PER_DIR + HINTS + ${_webp_SEARCH_DIRS} + PATH_SUFFIXES + lib64 lib lib/static + ) + LIST(APPEND _webp_LIBRARIES "${WEBP_${UPPERCOMPONENT}_LIBRARY}") +ENDFOREACH() + +IF(${WEBP_WEBP_LIBRARY_NOTFOUND}) + set(WEBP_FOUND FALSE) +ELSE() + # handle the QUIETLY and REQUIRED arguments and set WEBP_FOUND to TRUE if + # all listed variables are TRUE + INCLUDE(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(WebP DEFAULT_MSG _webp_LIBRARIES WEBP_INCLUDE_DIR) + + IF(WEBP_FOUND) + get_filename_component(WEBP_LIBRARY_DIR ${WEBP_WEBP_LIBRARY} DIRECTORY) + SET(WEBP_INCLUDE_DIRS ${WEBP_INCLUDE_DIR}) + SET(WEBP_LIBRARIES ${_webp_LIBRARIES}) + ELSE() + SET(WEBPL_PUGIXML_FOUND FALSE) + ENDIF() +ENDIF() + +MARK_AS_ADVANCED( + WEBP_INCLUDE_DIR + WEBP_LIBRARY_DIR +) diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index b09f2f8917b..43ce23081af 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -232,6 +232,15 @@ if(WITH_IMAGE_TIFF) endif() endif() +if(WITH_IMAGE_WEBP) + set(WEBP_ROOT_DIR ${LIBDIR}/webp) + find_package(WebP) + if(NOT WEBP_FOUND) + message(WARNING "WebP not found, disabling WITH_IMAGE_WEBP") + set(WITH_IMAGE_WEBP OFF) + endif() +endif() + if(WITH_BOOST) set(Boost_NO_BOOST_CMAKE ON) set(BOOST_ROOT ${LIBDIR}/boost) diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index 0a7119802c8..cc168476d5d 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -368,6 +368,14 @@ if(WITH_PUGIXML) endif() endif() +if(WITH_IMAGE_WEBP) + set(WEBP_ROOT_DIR ${LIBDIR}/webp) + find_package_wrapper(WebP) + if(NOT WEBP_FOUND) + set(WITH_IMAGE_WEBP OFF) + endif() +endif() + if(WITH_OPENIMAGEIO) find_package_wrapper(OpenImageIO) set(OPENIMAGEIO_LIBRARIES diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index ca4af2274e6..9418f74994b 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -343,6 +343,14 @@ if(WITH_FFTW3) set(FFTW3_LIBPATH ${FFTW3}/lib) endif() +windows_find_package(WebP) +if(NOT WEBP_FOUND) + set(WEBP_INCLUDE_DIRS ${LIBDIR}/webp/include) + set(WEBP_ROOT_DIR ${LIBDIR}/webp) + set(WEBP_LIBRARIES ${LIBDIR}/webp/lib/webp.lib ${LIBDIR}/webp/lib/webpdemux.lib ${LIBDIR}/webp/lib/webpmux.lib) + set(WEBP_FOUND ON) +endif() + if(WITH_OPENCOLLADA) set(OPENCOLLADA ${LIBDIR}/opencollada) |