Files
Ray molenkamp 3735a4d104 deps_builder: Fix missing Webp support in OIIO build on windows
webp 1.3 changed the filenames on windows to include a `lib` prefix
(ie libwebp.lib rather than webp.lib) now this is a common thing
on linux and cmake has a `CMAKE_FIND_LIBRARY_PREFIXES` variable that
has a list of prefixes to look for during a `find_library` call.

`CMAKE_FIND_LIBRARY_PREFIXES` gets set during the call to the
`project` method in the main CMakeLists of a project. Now for windows
`lib` is *not* a common prefix by CMake, and it doesn't add "lib" to
CMAKE_FIND_LIBRARY_PREFIXES during that call.

so find library doesn't look for it, the libs are not found and an
unhappy time is had by all. Now the most obvious solution would be to
pass `-DCMAKE_FIND_LIBRARY_PREFIXES=lib` to CMake to sidestep this
however, the `project` call will set the variable overwriting
anything you passed through the CLI.

So the fix here is to have `find_library` counter-intuitively look
for both `libwebp` and `webp`
2023-09-22 08:47:23 -06:00

79 lines
2.7 KiB
Diff

diff -Naur oiio-2.4.15.0/src/cmake/modules/FindWebP.cmake external_openimageio/src/cmake/modules/FindWebP.cmake
--- oiio-2.4.15.0/src/cmake/modules/FindWebP.cmake 2023-09-01 10:48:29.000000000 -0600
+++ external_openimageio/src/cmake/modules/FindWebP.cmake 2023-09-21 14:47:19.366083900 -0600
@@ -25,15 +25,30 @@
ENV WEBP_INCLUDE_PATH
DOC "The directory where Webp headers reside")
-find_library (WEBP_LIBRARY webp
+find_library (WEBP_LIBRARY
+ NAMES
+ webp
+ libwebp
HINTS
${WEBP_LIBRARY_PATH}
ENV WEBP_LIBRARY_PATH)
-find_library (WEBPDEMUX_LIBRARY webpdemux
+find_library (WEBPDEMUX_LIBRARY
+ NAMES
+ webpdemux
+ libwebpdemux
+ HINTS
+ ${WEBP_LIBRARY_PATH}
+ ENV WEBP_LIBRARY_PATH)
+# New in WebP 1.3
+find_library (WEBP_SHARPYUV_LIBRARY
+ NAMES
+ sharpyuv
+ libsharpyuv
HINTS
${WEBP_LIBRARY_PATH}
ENV WEBP_LIBRARY_PATH)
+
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (WebP
REQUIRED_VARS WEBP_INCLUDE_DIR
@@ -42,7 +57,7 @@
if (WebP_FOUND)
set (WEBP_INCLUDES "${WEBP_INCLUDE_DIR}")
- set (WEBP_LIBRARIES ${WEBP_LIBRARY} ${WEBPDEMUX_LIBRARY})
+ set (WEBP_LIBRARIES ${WEBP_LIBRARY} ${WEBPDEMUX_LIBRARY} ${WEBP_SHARPYUV_LIBRARY})
if (NOT TARGET WebP::webp)
add_library(WebP::webp UNKNOWN IMPORTED)
@@ -58,10 +73,18 @@
set_property(TARGET WebP::webpdemux APPEND PROPERTY
IMPORTED_LOCATION ${WEBPDEMUX_LIBRARY})
endif ()
+ if (WEBP_SHARPYUV_LIBRARY AND NOT TARGET WebP::sharpyuv)
+ add_library(WebP::sharpyuv UNKNOWN IMPORTED)
+ set_target_properties(WebP::sharpyuv PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES ${WEBP_INCLUDES})
+ set_property(TARGET WebP::sharpyuv APPEND PROPERTY
+ IMPORTED_LOCATION ${WEBP_SHARPYUV_LIBRARY})
+ endif ()
endif ()
mark_as_advanced (
WEBP_INCLUDE_DIR
WEBP_LIBRARY
WEBPDEMUX_LIBRARY
+ WEBP_SHARPYUV_LIBRARY
)
diff --git a/src/webp.imageio/CMakeLists.txt b/src/webp.imageio/CMakeLists.txt
index ccf1146..c646e99 100644
--- a/src/webp.imageio/CMakeLists.txt
+++ b/src/webp.imageio/CMakeLists.txt
@@ -4,7 +4,7 @@
if (WebP_FOUND)
add_oiio_plugin (webpinput.cpp webpoutput.cpp
- LINK_LIBRARIES WebP::webp WebP::webpdemux
+ LINK_LIBRARIES WebP::webp WebP::webpdemux WebP::sharpyuv
DEFINITIONS "-DUSE_WEBP=1")
else ()
message (STATUS "WebP plugin will not be built")