diff options
-rw-r--r-- | cmake/FindWrapWebP.cmake | 41 | ||||
-rw-r--r-- | src/imageformats/configure.cmake | 4 | ||||
-rw-r--r-- | src/plugins/imageformats/tiff/CMakeLists.txt | 11 |
3 files changed, 53 insertions, 3 deletions
diff --git a/cmake/FindWrapWebP.cmake b/cmake/FindWrapWebP.cmake new file mode 100644 index 0000000..e4d0b33 --- /dev/null +++ b/cmake/FindWrapWebP.cmake @@ -0,0 +1,41 @@ +# Latest upstream package provides both CMake and autotools building. +# Unfortunately Linux distros and homebrew build the package with autotools, +# so they do not ship the CMake Config file, but only the pkg-config files. +# vcpkg and Conan do ship Config files. +# So try config files first, and then use the regular find_library / find_path dance with pkg-config +# paths as hints. + +find_package(WebP QUIET) +if(TARGET WebP::webp AND TARGET WebP::webpdemux) + set(WrapWebP_FOUND ON) + add_library(WrapWebP::WrapWebP INTERFACE IMPORTED) + target_link_libraries(WrapWebP::WrapWebP INTERFACE WebP::webp WebP::webpdemux) + return() +endif() + +find_package(PkgConfig) +pkg_check_modules(PC_WebP libwebp) +pkg_check_modules(PC_WebPDemux libwebpdemux) + +find_library(WebP_LIBRARY NAMES "webp" + HINTS ${PC_WebP_LIBDIR}) +find_library(WebP_demux_LIBRARY NAMES "webpdemux" + HINTS ${PC_WebPDemux_LIBDIR}) + +find_path(WebP_INCLUDE_DIR NAMES "webp/decode.h" + HINTS ${PC_WebP_INCLUDEDIR}) +find_path(WebP_demux_INCLUDE_DIR NAMES "webp/demux.h" + HINTS ${PC_WebPDemux_INCLUDEDIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(WebP DEFAULT_MSG WebP_INCLUDE_DIR WebP_LIBRARY + WebP_demux_INCLUDE_DIR WebP_demux_LIBRARY) + +mark_as_advanced(WebP_INCLUDE_DIR WebP_LIBRARY WebP_INCLUDE_DIR WebP_demux_LIBRARY) +if(WebP_FOUND) + set(WrapWebP_FOUND ON) + add_library(WrapWebP::WrapWebP INTERFACE IMPORTED) + target_link_libraries(WrapWebP::WrapWebP INTERFACE ${WebP_LIBRARY} ${WebP_demux_LIBRARY}) + target_include_directories(WrapWebP::WrapWebP + INTERFACE ${WebP_INCLUDE_DIR} ${WebP_demux_INCLUDE_DIR}) +endif() diff --git a/src/imageformats/configure.cmake b/src/imageformats/configure.cmake index ca7e753..3100bf6 100644 --- a/src/imageformats/configure.cmake +++ b/src/imageformats/configure.cmake @@ -38,7 +38,7 @@ qt_feature("mng" PRIVATE ) qt_feature("tiff" PRIVATE LABEL "TIFF" - CONDITION QT_FEATURE_imageformatplugin + CONDITION QT_FEATURE_imageformatplugin AND TIFF_FOUND DISABLE INPUT_tiff STREQUAL 'no' ) qt_feature("system_tiff" PRIVATE @@ -49,7 +49,7 @@ qt_feature("system_tiff" PRIVATE ) qt_feature("webp" PRIVATE LABEL "WEBP" - CONDITION QT_FEATURE_imageformatplugin + CONDITION QT_FEATURE_imageformatplugin AND WrapWebP_FOUND DISABLE INPUT_webp STREQUAL 'no' ) qt_feature("system_webp" PRIVATE diff --git a/src/plugins/imageformats/tiff/CMakeLists.txt b/src/plugins/imageformats/tiff/CMakeLists.txt index 1e5b555..d831693 100644 --- a/src/plugins/imageformats/tiff/CMakeLists.txt +++ b/src/plugins/imageformats/tiff/CMakeLists.txt @@ -4,7 +4,16 @@ ## qtiff Plugin: ##################################################################### -qt_find_package(ZLIB PROVIDED_TARGETS ZLIB::ZLIB) # special case +# special case begin +# Protect against case when ZLIB is found via QtGui in a static build, +# which means that we can't do a qt_find_package() here due to CMake +# complaining about not being able to make the ZLIB target global, +# because ZLIB was found in the QtGui directory scope (root level) and +# not in this directory scope. +if(BUILD_SHARED_LIBS) + qt_find_package(ZLIB PROVIDED_TARGETS ZLIB::ZLIB) +endif() +# special case end add_qt_plugin(qtiff TYPE imageformats |