summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-06-05 22:45:38 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-06-06 13:45:05 +0000
commite970e4a394c4e2f9d9fc50a31657cbddcb64d501 (patch)
tree6071f942e411ce0df297b3ecc8151c4457e0415e /cmake
parent2a9ae46b62e90db58c2d81a70feb5b884c9994d0 (diff)
downloadqtimageformats-e970e4a394c4e2f9d9fc50a31657cbddcb64d501.tar.gz
Fix qtimageformats building
Some feature conditions were incorrect. Added forgotten FindWrapWebP.cmake file. Protect call to qt_find_package ZLIB. Change-Id: I033d38e4f69e94f7b72346b49bf6de4b2dbde8e0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindWrapWebP.cmake41
1 files changed, 41 insertions, 0 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()