File 0001-Fix-build-with-CharLS-2.1.0.patch of Package gdcm

From a979663a2cece68f5e42e5271a4bd9966cfe502a Mon Sep 17 00:00:00 2001
From: Christophe Giboudeaux <christophe@krop.fr>
Date: Tue, 3 Nov 2020 16:03:42 +0100
Subject: [PATCH] Fix build with CharLS 2.1.0

The gdcm build system has multiple issues that prevented finding
charls 2.1.0 but also didn't report failures correctly.

It then also failed to build due to an #include statement
wrongly assuming the charls directory casing.
---
 CMake/FindCharLS.cmake   | 42 ++++++++++++++++++----------------------
 Utilities/gdcm_charls.h  |  2 +-
 3 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/CMake/FindCharLS.cmake b/CMake/FindCharLS.cmake
index 8f6bf19..a0ea08b 100644
--- a/CMake/FindCharLS.cmake
+++ b/CMake/FindCharLS.cmake
@@ -6,35 +6,31 @@
 #  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 #
 
-find_path(CHARLS_INCLUDE_DIR CharLS/charls.h
-/usr/local/include
-/usr/include
+find_path(CHARLS_INCLUDE_DIR charls.h
+  PATH_SUFFIXES
+    CharLS
+    charls
 )
 
 find_library(CHARLS_LIBRARY
-  NAMES CharLS
-  PATHS /usr/lib /usr/local/lib
-  )
+  NAMES CharLS charls
+)
+
+include(FindPackageHandleStandardArgs)
 
-if (CHARLS_LIBRARY AND CHARLS_INCLUDE_DIR)
-    set(CHARLS_LIBRARIES    ${CHARLS_LIBRARY})
-    set(CHARLS_INCLUDE_DIRS ${CHARLS_INCLUDE_DIR})
-    set(CHARLS_FOUND "YES")
-else ()
-  set(CHARLS_FOUND "NO")
-endif ()
+find_package_handle_standard_args(CharLS
+  FOUND_VAR CharLS_FOUND
+  REQUIRED_VARS CHARLS_INCLUDE_DIR CHARLS_LIBRARY
+)
 
-if (CHARLS_FOUND)
-   if (NOT CHARLS_FIND_QUIETLY)
-      message(STATUS "Found CHARLS: ${CHARLS_LIBRARIES}")
-   endif ()
-else ()
-   if (CHARLS_FIND_REQUIRED)
-      message(FATAL_ERROR "Could not find CHARLS library")
-   endif ()
-endif ()
+# Legacy compatibility variables
+set(CHARLS_FOUND ${CharLS_FOUND})
+set(CHARLS_LIBRARIES ${CHARLS_LIBRARY})
+set(CHARLS_INCLUDE_DIRS ${CHARLS_INCLUDE_DIR})
 
 mark_as_advanced(
   CHARLS_LIBRARY
   CHARLS_INCLUDE_DIR
-  )
+  CHARLS_LIBRARIES
+  CHARLS_INCLUDE_DIRS
+)
diff --git a/Utilities/gdcm_charls.h b/Utilities/gdcm_charls.h
index b80451c..bdb108f 100644
--- a/Utilities/gdcm_charls.h
+++ b/Utilities/gdcm_charls.h
@@ -18,7 +18,7 @@
 #include "gdcmTypes.h"
 #ifdef GDCM_USE_SYSTEM_CHARLS
 // It is expected that version 2.0.0 is used
-# include <CharLS/charls.h>
+# include <charls.h>
 #else
 #include "gdcmcharls/charls.h"
 #endif
-- 
2.29.1

openSUSE Build Service is sponsored by