Commit b2011bbc for libheif
commit b2011bbc721304d3cf4cb74259340b9484dacb08
Author: Dirk Farin <dirk.farin@gmail.com>
Date: Mon Jun 22 13:15:32 2026 +0200
only compile TIFF decoder test when libtiff was found (#1842)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 5a31d9ae..940acfd9 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -114,7 +114,15 @@ else()
message(WARNING "Tests of the 'uncompressed codec' are not compiled because the uncompressed codec is not enabled (WITH_UNCOMPRESSED_CODEC==OFF)")
endif ()
-add_heifio_test(tiffdecode)
+# find_package(TIFF) is called in the heifio subdirectory, but its result
+# variables do not propagate to this sibling directory scope. Query again
+# (the result is cached) so we only build the TIFF test when libtiff is present.
+find_package(TIFF)
+if (TIFF_FOUND)
+ add_heifio_test(tiffdecode)
+else()
+ message(INFO " Disabling the TIFF decoder test because libtiff was not found")
+endif ()
if (ENABLE_PLUGIN_LOADING)
get_directory_property(ALL_TESTS TESTS)
diff --git a/tests/tiffdecode.cc b/tests/tiffdecode.cc
index d8f77672..aab575c1 100644
--- a/tests/tiffdecode.cc
+++ b/tests/tiffdecode.cc
@@ -33,7 +33,6 @@
#include "libheif/heif.h"
#include "libheif/api_structs.h"
-#if HAVE_LIBTIFF
void checkMono(InputImage input_image) {
REQUIRE(input_image.orientation == heif_orientation_normal);
REQUIRE(input_image.image != nullptr);
@@ -138,9 +137,4 @@ TEST_CASE("rgba_planar") {
heif_error err = loadTIFF(path.c_str(), 10, &input_image);
REQUIRE(err.code == heif_error_Ok);
checkRGBA(input_image);
-}
-#else
-TEST_CASE("no_tiff dummy") {
- // Dummy test if we don't have the TIFF library, so that testing does not fail with "No test ran".
-}
-#endif // HAVE_LIBTIFF
\ No newline at end of file
+}
\ No newline at end of file