libtiff: CI: add testing of find_package(Tiff CONFIG)

From 97785f8527535b837cd29a547101a96073ef5d4e Mon Sep 17 00:00:00 2001
From: Even Rouault <[EMAIL REDACTED]>
Date: Mon, 5 Jun 2023 16:50:59 +0200
Subject: [PATCH] CI: add testing of find_package(Tiff CONFIG)

---
 build/gitlab-ci                 | 6 ++++++
 build/test_cmake/CMakeLists.txt | 7 +++++++
 build/test_cmake/test.c         | 7 +++++++
 3 files changed, 20 insertions(+)
 create mode 100644 build/test_cmake/CMakeLists.txt
 create mode 100644 build/test_cmake/test.c

diff --git a/build/gitlab-ci b/build/gitlab-ci
index 7058eeed..c8331423 100644
--- a/build/gitlab-ci
+++ b/build/gitlab-ci
@@ -51,6 +51,12 @@ cmake_build()
     $COVERITY_BUILD cmake --build .
     cmake --build . --target install
     ctest -V
+    cd ..
+    # Build test project using find_package(Tiff CONFIG)
+    mkdir cmake-test-build
+    cd cmake-test-build
+    cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" "-DTiff_DIR=$PWD/../cmake-install/lib/cmake/tiff" -S ../build/test_cmake -B .
+    cmake --build .
 }
 
 # Static-analysis with coverity
diff --git a/build/test_cmake/CMakeLists.txt b/build/test_cmake/CMakeLists.txt
new file mode 100644
index 00000000..8221220b
--- /dev/null
+++ b/build/test_cmake/CMakeLists.txt
@@ -0,0 +1,7 @@
+cmake_minimum_required(VERSION 3.9.0)
+project(test)
+
+find_package(Tiff CONFIG REQUIRED)
+
+add_executable(test test.c)
+target_link_libraries(test PRIVATE TIFF::tiff)
diff --git a/build/test_cmake/test.c b/build/test_cmake/test.c
new file mode 100644
index 00000000..011b53e1
--- /dev/null
+++ b/build/test_cmake/test.c
@@ -0,0 +1,7 @@
+#include "tiffio.h"
+
+int main()
+{
+    TIFFGetVersion();
+    return 0;
+}