From 5ea27f08b4d9b389249b0c28352c8b07ab172c7d Mon Sep 17 00:00:00 2001
From: Michele Calgaro <michele.calgaro@yahoo.it>
Date: Sat, 7 Nov 2026 11:39:45 +0900
Subject: Simplify detection of libwebp.

libwebp has had a .pc file since version 0.1.2 (about 15
years old), so there is no need to do an alternate check if pkg-config
detection fails. Also ensure that kimg_webp is always built when webp support is requested.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
---
 CMakeLists.txt        | 20 ++------------------
 kimgio/CMakeLists.txt |  4 ++--
 2 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 34be54c62..158382750 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -919,25 +919,9 @@ endif( WITH_JASPER )
 
 if( WITH_WEBP )
   pkg_search_module( WEBP libwebp )
-  if( WEBP_FOUND )
-    set( HAVE_WEBP 1 )
-  else ( NOT WEBP_FOUND )
-    check_include_file( "webp/decode.h" HAVE_WEBP_DECODE_H)
-    if ( HAVE_WEBP_DECODE_H )
-      check_library_exists( webp WebPGetInfo        "" HAVE_WEBP__WEBPGETINFO )
-      check_library_exists( webp WebPDecodeARGBInto "" HAVE_WEBP__WEBPDECODEARGBINTO )
-      check_library_exists( webp WebPDecodeBGRAInto "" HAVE_WEBP__WEBPDECODEBGRAINTO )
-      if( HAVE_WEBP__WEBPGETINFO AND HAVE_WEBP__WEBPDECODEARGBINTO AND HAVE_WEBP__WEBPDECODEBGRAINTO )
-        set( HAVE_WEBP 1 )
-      endif( )
-    endif( HAVE_WEBP_DECODE_H )
+  if( NOT WEBP_FOUND )
+    tde_message_fatal( "webp support was requested, but not found on your system" )
   endif( WEBP_FOUND )
-  if ( HAVE_WEBP )
-    set( WEBP_LIBRARIES webp )
-    message( STATUS "WebP support enabled" )
-  else ( NOT HAVE_WEBP )
-    tde_message_fatal( "WebP support requested, but not found on your system" )
-  endif( HAVE_WEBP)
 endif( WITH_WEBP )
 
 
diff --git a/kimgio/CMakeLists.txt b/kimgio/CMakeLists.txt
index 0e588bcce..1ed5840d8 100644
--- a/kimgio/CMakeLists.txt
+++ b/kimgio/CMakeLists.txt
@@ -182,7 +182,7 @@ tde_add_kpart( ${target}
 
 ##### kimg_webp #################################
 
-if( HAVE_WEBP )
+if( WITH_WEBP )
   set( target kimg_webp )
   tde_add_kpart( ${target}
     SOURCES webp.cpp
@@ -194,7 +194,7 @@ if( HAVE_WEBP )
     DESTINATION ${SERVICES_INSTALL_DIR}
     PO_DIR mimetypes
   )
-endif( HAVE_WEBP )
+endif( WITH_WEBP )
 
 
 ##### other data ################################
-- 
cgit v1.2.3

