File 0001-Revert-Exiv2-is-now-released-with-exported-targets-u.patch of Package digikam

From 64454b942be9c61f3c981f7a18a77b332944d58a Mon Sep 17 00:00:00 2001
From: Wolfgang Bauer <wbauer@tmo.at>
Date: Tue, 12 Nov 2019 11:15:21 +0100
Subject: [PATCH] Revert "Exiv2 is now released with exported targets using
 cmake rules. No need to have a dedicated find exiv2 cmake script. Bump
 minimal version to 0.27.1"

This reverts commit 06e77271d72fe5e4abeb38641f3addc2cfbff126.

Fixes build on Leap 15.x which only have exiv2 0.26.
As there haven't been any changes other than to rely on the new cmake
files in exiv2 0.27, there should be no problems with the older version.
---
 core/CMakeLists.txt                     |  14 +--
 core/app/DigikamCoreTarget.cmake        |   2 +-
 core/cmake/modules/FindExiv2.cmake      | 116 ++++++++++++++++++++++++++++++++
 core/libs/metadataengine/CMakeLists.txt |  10 ++-
 4 files changed, 126 insertions(+), 16 deletions(-)
 create mode 100644 core/cmake/modules/FindExiv2.cmake

diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index e31e267772..d14364dc1e 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -16,7 +16,7 @@ message(STATUS "")
 
 set(KF5_MIN_VERSION       "5.5.0")
 set(QT_MIN_VERSION        "5.9.0")
-set(EXIV2_MIN_VERSION     "0.27.0")
+set(EXIV2_MIN_VERSION     "0.26")
 set(OPENCV_MIN_VERSION    "3.3.0")
 set(LENSFUN_MIN_VERSION   "0.2.6.0")      # For Lens auto-correction plugin
 set(QTAV_MIN_VERSION      "1.12.0")       # For video support.
@@ -178,9 +178,9 @@ if(NOT X265_FOUND)
     set(X265_LIBRARIES "")
 endif()
 
-find_package(exiv2 REQUIRED)
+find_package(Exiv2 ${EXIV2_MIN_VERSION} REQUIRED)
 
-set_package_properties("exiv2"     PROPERTIES
+set_package_properties("Exiv2"     PROPERTIES
                        DESCRIPTION "Required to build digiKam"
                        URL         "https://www.exiv2.org"
                        TYPE        RECOMMENDED
@@ -187,10 +187,6 @@ set_package_properties("Exiv2"     PROPERTIES
                        PURPOSE     "Library to manage image metadata"
 )
 
-if("${exiv2_VERSION}" VERSION_LESS ${EXIV2_MIN_VERSION})
-    message(FATAL_ERROR "Exiv2 version is too old (${exiv2_VERSION})! Minimal version required:${EXIV2_MIN_VERSION}.")
-endif()
-
 # -- check Media player --------------------------------------------------------
 
 find_package(FFmpeg COMPONENTS AVCODEC AVDEVICE AVFILTER AVFORMAT AVUTIL SWSCALE)
@@ -535,7 +531,7 @@ PRINT_COMPONENT_COMPILE_STATUS("QWebEngine Support"      ENABLE_QWEBENGINE)
 # ==============================================================================
 
 PRINT_LIBRARY_STATUS("libboostgraph" "https://www.boost.org/doc/libs"                    "(version >= 1.43.0)"                Boost_FOUND)
-PRINT_LIBRARY_STATUS("libexiv2"      "https://www.exiv2.org"                             "(version >= ${EXIV2_MIN_VERSION}"   exiv2_FOUND)
+PRINT_LIBRARY_STATUS("libexiv2"      "https://www.exiv2.org"                             "(version >= ${EXIV2_MIN_VERSION}"   Exiv2_FOUND)
 PRINT_LIBRARY_STATUS("libexpat"      "https://libexpat.github.io"                        "(version >= 2.0.0)"                 EXPAT_FOUND)
 PRINT_LIBRARY_STATUS("libjpeg"       "https://github.com/libjpeg-turbo/libjpeg-turbo"    "(version >= 6b)"                    JPEG_FOUND)
 PRINT_LIBRARY_STATUS("libkde"        "https://www.kde.org"                               "(version >= ${KF5_MIN_VERSION})"    KF5_FOUND)
@@ -576,7 +572,7 @@ PRINT_OPTIONAL_LIBRARY_STATUS("OpenGL"            "https://www.mesa3d.org"
 # ==============================================================================
 
 if(Boost_FOUND                          AND
-   exiv2_FOUND                          AND
+   Exiv2_FOUND                          AND
    EXPAT_FOUND                          AND
    JPEG_FOUND                           AND
    KF5_FOUND                            AND
diff --git a/core/app/DigikamCoreTarget.cmake b/core/app/DigikamCoreTarget.cmake
index 72b424cb36..7aa6dc5a1e 100644
--- a/core/app/DigikamCoreTarget.cmake
+++ b/core/app/DigikamCoreTarget.cmake
@@ -143,7 +143,7 @@ target_link_libraries(digikamcore
                       ${TIFF_LIBRARIES}
                       PNG::PNG
                       ${JPEG_LIBRARIES}
-                      exiv2lib
+                      ${EXIV2_LIBRARIES}
 
                       ${FFMPEG_LIBRARIES}
 
diff --git a/core/cmake/modules/FindExiv2.cmake b/core/cmake/modules/FindExiv2.cmake
new file mode 100644
index 0000000000..912ffaee0c
--- /dev/null
+++ b/core/cmake/modules/FindExiv2.cmake
@@ -0,0 +1,116 @@
+# - Try to find the Exiv2 library
+#
+#  EXIV2_MIN_VERSION - You can set this variable to the minimum version you need
+#                      before doing FIND_PACKAGE(Exiv2). The default is 0.26.
+#
+# Once done this will define
+#
+#  EXIV2_FOUND       - system has libexiv2
+#  EXIV2_VERSION     - the version of libexiv2
+#  EXIV2_INCLUDE_DIR - the libexiv2 include directory
+#  EXIV2_LIBRARIES   - Link these to use libexiv2
+#  EXIV2_DEFINITIONS - Compiler switches required for using libexiv2
+#
+# The minimum required version of Exiv2 can be specified using the
+# standard syntax, e.g. find_package(Exiv2 0.26)
+#
+# For compatibility, also the variable EXIV2_MIN_VERSION can be set to the minimum version
+# you need before doing FIND_PACKAGE(Exiv2). The default is 0.26.
+#
+# Copyright (c) 2010,      Alexander Neundorf, <neundorf at kde dot org>
+# Copyright (c) 2008-2019, Gilles Caulier, <caulier dot gilles at gmail dot com>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+# Support EXIV2_MIN_VERSION for compatibility:
+
+if(NOT Exiv2_FIND_VERSION)
+
+    set(Exiv2_FIND_VERSION "${EXIV2_MIN_VERSION}")
+
+endif()
+
+# The minimum version of exiv2 we require
+if(NOT Exiv2_FIND_VERSION)
+
+    set(Exiv2_FIND_VERSION "0.26")
+
+endif()
+
+if(NOT WIN32)
+
+   # use pkg-config to get the directories and then use these values
+   # in the FIND_PATH() and FIND_LIBRARY() calls
+   find_package(PkgConfig)
+   pkg_check_modules(PC_EXIV2 QUIET exiv2)
+   set(EXIV2_DEFINITIONS ${PC_EXIV2_CFLAGS_OTHER})
+
+endif()
+
+find_path(EXIV2_INCLUDE_DIR NAMES exiv2/exif.hpp
+          HINTS
+          ${PC_EXIV2_INCLUDEDIR}
+          ${PC_EXIV2_INCLUDE_DIRS}
+        )
+
+find_library(EXIV2_LIBRARY NAMES exiv2 libexiv2 exiv2lib
+             HINTS
+             ${PC_EXIV2_LIBDIR}
+             ${PC_EXIV2_LIBRARY_DIRS}
+            )
+
+if (EXIV2_INCLUDE_DIR  AND NOT  EXIV2_VERSION)
+
+    # For Exiv2 <= 0.26, get the version number from exiv2/version.hpp and store it in the cache:
+
+    file(READ ${EXIV2_INCLUDE_DIR}/exiv2/version.hpp EXIV2_VERSION_CONTENT)
+    string(REGEX MATCH "#define EXIV2_MAJOR_VERSION +\\( *([0-9]+) *\\)"  _dummy "${EXIV2_VERSION_CONTENT}")
+    set(EXIV2_VERSION_MAJOR "${CMAKE_MATCH_1}")
+
+    string(REGEX MATCH "#define EXIV2_MINOR_VERSION +\\( *([0-9]+) *\\)"  _dummy "${EXIV2_VERSION_CONTENT}")
+    set(EXIV2_VERSION_MINOR "${CMAKE_MATCH_1}")
+
+    string(REGEX MATCH "#define EXIV2_PATCH_VERSION +\\( *([0-9]+) *\\)"  _dummy "${EXIV2_VERSION_CONTENT}")
+    set(EXIV2_VERSION_PATCH "${CMAKE_MATCH_1}")
+
+    if(NOT "${EXIV2_VERSION_MAJOR}" STREQUAL "" AND
+       NOT "${EXIV2_VERSION_MINOR}" STREQUAL "" AND
+       NOT "${EXIV2_VERSION_PATCH}" STREQUAL "")
+
+        set(EXIV2_VERSION "${EXIV2_VERSION_MAJOR}.${EXIV2_VERSION_MINOR}.${EXIV2_VERSION_PATCH}"
+            CACHE STRING "Version number of Exiv2" FORCE)
+    else()
+
+        # For Exiv2 >= 0.27, get the version number from exiv2/exv_conf.h and store it in the cache:
+
+        file(READ ${EXIV2_INCLUDE_DIR}/exiv2/exv_conf.h EXIV2_VERSION_CONTENT)
+        string(REGEX MATCH "#define EXIV2_MAJOR_VERSION +\\( *([0-9]+) *\\)"  _dummy "${EXIV2_VERSION_CONTENT}")
+        set(EXIV2_VERSION_MAJOR "${CMAKE_MATCH_1}")
+
+        string(REGEX MATCH "#define EXIV2_MINOR_VERSION +\\( *([0-9]+) *\\)"  _dummy "${EXIV2_VERSION_CONTENT}")
+        set(EXIV2_VERSION_MINOR "${CMAKE_MATCH_1}")
+
+        string(REGEX MATCH "#define EXIV2_PATCH_VERSION +\\( *([0-9]+) *\\)"  _dummy "${EXIV2_VERSION_CONTENT}")
+        set(EXIV2_VERSION_PATCH "${CMAKE_MATCH_1}")
+
+        set(EXIV2_VERSION "${EXIV2_VERSION_MAJOR}.${EXIV2_VERSION_MINOR}.${EXIV2_VERSION_PATCH}"
+            CACHE STRING "Version number of Exiv2" FORCE)
+
+    endif()
+
+endif()
+
+set(EXIV2_LIBRARIES "${EXIV2_LIBRARY}")
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Exiv2 REQUIRED_VARS EXIV2_LIBRARY EXIV2_INCLUDE_DIR
+                                        VERSION_VAR   EXIV2_VERSION)
+
+MESSAGE(STATUS "EXIV2_FOUND       = ${EXIV2_FOUND}")
+MESSAGE(STATUS "EXIV2_VERSION     = ${EXIV2_VERSION}")
+MESSAGE(STATUS "EXIV2_INCLUDE_DIR = ${EXIV2_INCLUDE_DIR}")
+MESSAGE(STATUS "EXIV2_LIBRARY     = ${EXIV2_LIBRARY}")
+MESSAGE(STATUS "EXIV2_DEFINITIONS = ${EXIV2_DEFINITIONS}")
+
+mark_as_advanced(EXIV2_INCLUDE_DIR EXIV2_LIBRARY)
diff --git a/core/libs/metadataengine/CMakeLists.txt b/core/libs/metadataengine/CMakeLists.txt
index 64754c882c..da6fac050a 100644
--- a/core/libs/metadataengine/CMakeLists.txt
+++ b/core/libs/metadataengine/CMakeLists.txt
@@ -9,16 +9,15 @@
 
 kde_enable_exceptions()
 
-# TODO: How to extract exiv2lib definitions properties with cmake import interface?
-#add_definitions($<TARGET_PROPERTY:exiv2lib,INTERFACE_COMPILE_DEFINITIONS>)
+add_definitions(${EXIV2_DEFINITIONS})
 
 if(WIN32)
-    add_definitions(-DEXV_HAVE_DLL)
+    add_definitions( -DEXV_HAVE_DLL )
 endif()
 
 # Exiv2 version < 0.28 use auto_ptr instead unique_ptr which is deprecated.
 
-if("${exiv2_VERSION}" VERSION_LESS "0.27.99")
+if("${EXIV2_VERSION}" VERSION_LESS "0.27.99")
 
     DISABLE_GCC_COMPILER_WARNINGS("5.99.99" "-Wno-deprecated")
 
@@ -72,13 +71,12 @@ set(libdmetadata_SRCS
 )
 
 include_directories(
+    ${EXIV2_INCLUDE_DIR}
     $<TARGET_PROPERTY:Qt5::Gui,INTERFACE_INCLUDE_DIRECTORIES>
     $<TARGET_PROPERTY:Qt5::Core,INTERFACE_INCLUDE_DIRECTORIES>
 
     $<TARGET_PROPERTY:KF5::ConfigCore,INTERFACE_INCLUDE_DIRECTORIES>
     $<TARGET_PROPERTY:KF5::I18n,INTERFACE_INCLUDE_DIRECTORIES>
-
-    $<TARGET_PROPERTY:exiv2lib,INTERFACE_INCLUDE_DIRECTORIES>
 )
 
 # Used by digikamcore
-- 
2.16.4
openSUSE Build Service is sponsored by