diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,11 +7,11 @@ set(CMAKE_MIN_VERSION "3.0.0") set(ECM_MIN_VERSION "1.1.0") set(REQUIRED_QT_VERSION "5.2.0") -set(EXIV2_MIN_VERSION "0.24") +set(EXIV2_MIN_VERSION "0.25") cmake_minimum_required(VERSION ${CMAKE_MIN_VERSION}) -project(libkexiv2) +project(libkexiv2 VERSION "5.0.0") message(STATUS "----------------------------------------------------------------------------------") message(STATUS "Starting CMake configuration for: ${PROJECT_NAME}") @@ -47,18 +47,12 @@ # 2.4.0 => 11.3.0 - Add new method to access on text edit widget from AltLangStrEdit # 5.0.0 => 15.0.0 (Released with KDE 5.x) -# Library API version -set(KEXIV2_LIB_MAJOR_VERSION "5") -set(KEXIV2_LIB_MINOR_VERSION "0") -set(KEXIV2_LIB_PATCH_VERSION "0") - # Library ABI version used by linker. # For details : http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info set(KEXIV2_LIB_SO_CUR_VERSION "15") set(KEXIV2_LIB_SO_REV_VERSION "0") set(KEXIV2_LIB_SO_AGE_VERSION "0") -set(LIBKEXIV2_LIB_VERSION "${KEXIV2_LIB_MAJOR_VERSION}.${KEXIV2_LIB_MINOR_VERSION}.${KEXIV2_LIB_PATCH_VERSION}") set(LIBKEXIV2_SO_VERSION "${KEXIV2_LIB_SO_CUR_VERSION}.${KEXIV2_LIB_SO_REV_VERSION}.${KEXIV2_LIB_SO_AGE_VERSION}") ############## ECM setup ###################### @@ -77,27 +71,21 @@ include(GenerateExportHeader) include(FeatureSummary) +ecm_setup_version(${libkexiv2_VERSION} + VARIABLE_PREFIX KEXIV2 + VERSION_HEADER "src/libkexiv2_version.h" + PACKAGE_VERSION_FILE "KF5KExiv2ConfigVersion.cmake" + SOVERSION ${LIBKEXIV2_SO_VERSION} +) + ############## Find Packages ################### find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE COMPONENTS Core Gui ) -find_package(Exiv2 ${EXIV2_MIN_VERSION} REQUIRED) -set_package_properties("Exiv2" PROPERTIES - DESCRIPTION "Required to build libkexiv2" - URL "http://www.exiv2.org" - TYPE RECOMMENDED - PURPOSE "Library to manage image metadata" -) - -ecm_setup_version(${LIBKEXIV2_LIB_VERSION} - VARIABLE_PREFIX KEXIV2 - VERSION_HEADER "src/libkexiv2_version.h" - PACKAGE_VERSION_FILE "KF5KExiv2ConfigVersion.cmake" - SOVERSION ${LIBKEXIV2_SO_VERSION} -) +find_package(LibExiv2 ${EXIV2_MIN_VERSION} REQUIRED) ############## Targets ######################### diff --git a/cmake/modules/FindExiv2.cmake b/cmake/modules/FindExiv2.cmake deleted file mode 100644 --- a/cmake/modules/FindExiv2.cmake +++ /dev/null @@ -1,80 +0,0 @@ -# - 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.12. -# -# Once done this will define -# -# EXIV2_FOUND - system has 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.17) -# -# 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.12. - -# Copyright (c) 2010, Alexander Neundorf, -# Copyright (c) 2008, Gilles Caulier, -# -# 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(NOT Exiv2_FIND_VERSION) - -# the minimum version of exiv2 we require -if(NOT Exiv2_FIND_VERSION) - set(Exiv2_FIND_VERSION "0.12") -endif(NOT Exiv2_FIND_VERSION) - - -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 (NOT WIN32) - - -find_path(EXIV2_INCLUDE_DIR NAMES exiv2/exif.hpp - HINTS - ${PC_EXIV2_INCLUDEDIR} - ${PC_EXIV2_INCLUDE_DIRS} - ) - -find_library(EXIV2_LIBRARY NAMES exiv2 libexiv2 - HINTS - ${PC_EXIV2_LIBDIR} - ${PC_EXIV2_LIBRARY_DIRS} - ) - - -# Get the version number from exiv2/version.hpp and store it in the cache: -if(EXIV2_INCLUDE_DIR AND NOT EXIV2_VERSION) - 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}") - - set(EXIV2_VERSION "${EXIV2_VERSION_MAJOR}.${EXIV2_VERSION_MINOR}.${EXIV2_VERSION_PATCH}" CACHE STRING "Version number of Exiv2" FORCE) -endif(EXIV2_INCLUDE_DIR AND NOT EXIV2_VERSION) - -set(EXIV2_LIBRARIES "${EXIV2_LIBRARY}") - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Exiv2 REQUIRED_VARS EXIV2_LIBRARY EXIV2_INCLUDE_DIR - VERSION_VAR EXIV2_VERSION) - -mark_as_advanced(EXIV2_INCLUDE_DIR EXIV2_LIBRARY) - diff --git a/cmake/modules/FindLibExiv2.cmake b/cmake/modules/FindLibExiv2.cmake new file mode 100644 --- /dev/null +++ b/cmake/modules/FindLibExiv2.cmake @@ -0,0 +1,115 @@ +#.rst: +# FindLibExiv2 +# ------------ +# +# Try to find the Exiv2 library. +# +# This will define the following variables: +# +# ``LibExiv2_FOUND`` +# System has LibExiv2. +# +# ``LibExiv2_VERSION`` +# The version of LibExiv2. +# +# ``LibExiv2_INCLUDE_DIRS`` +# This should be passed to target_include_directories() if +# the target is not used for linking. +# +# ``LibExiv2_LIBRARIES`` +# The LibExiv2 library. +# This can be passed to target_link_libraries() instead of +# the ``LibExiv2::LibExiv2`` target +# +# If ``LibExiv2_FOUND`` is TRUE, the following imported target +# will be available: +# +# ``LibExiv2::LibExiv2`` +# The Exiv2 library +# +# Since 5.53.0. +# +#============================================================================= +# Copyright (c) 2018, Christophe Giboudeaux, +# Copyright (c) 2010, Alexander Neundorf, +# Copyright (c) 2008, Gilles Caulier, +# +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#============================================================================= + +find_package(PkgConfig QUIET) +pkg_check_modules(PC_EXIV2 QUIET exiv2) + +find_path(LibExiv2_INCLUDE_DIRS NAMES exiv2/exif.hpp + HINTS ${PC_EXIV2_INCLUDEDIR} +) + +find_library(LibExiv2_LIBRARIES NAMES exiv2 libexiv2 + HINTS ${PC_EXIV2_LIBRARY_DIRS} +) + +set(LibExiv2_VERSION ${PC_EXIV2_VERSION}) + +if(NOT LibExiv2_VERSION AND DEFINED LibExiv2_INCLUDE_DIRS) + # With exiv >= 0.27, the version #defines are in exv_conf.h instead of version.hpp + foreach(_exiv2_version_file "version.hpp" "exv_conf.h") + if(EXISTS "${LibExiv2_INCLUDE_DIRS}/exiv2/${_exiv2_version_file}") + file(READ "${LibExiv2_INCLUDE_DIRS}/exiv2/${_exiv2_version_file}" _exiv_version_file_content) + string(REGEX MATCH "#define EXIV2_MAJOR_VERSION[ ]+\\([0-9]+\\)" EXIV2_MAJOR_VERSION_MATCH ${_exiv_version_file_content}) + string(REGEX MATCH "#define EXIV2_MINOR_VERSION[ ]+\\([0-9]+\\)" EXIV2_MINOR_VERSION_MATCH ${_exiv_version_file_content}) + string(REGEX MATCH "#define EXIV2_PATCH_VERSION[ ]+\\([0-9]+\\)" EXIV2_PATCH_VERSION_MATCH ${_exiv_version_file_content}) + if(EXIV2_MAJOR_VERSION_MATCH) + string(REGEX REPLACE ".*_MAJOR_VERSION[ ]+\\((.*)\\)" "\\1" EXIV2_MAJOR_VERSION ${EXIV2_MAJOR_VERSION_MATCH}) + string(REGEX REPLACE ".*_MINOR_VERSION[ ]+\\((.*)\\)" "\\1" EXIV2_MINOR_VERSION ${EXIV2_MINOR_VERSION_MATCH}) + string(REGEX REPLACE ".*_PATCH_VERSION[ ]+\\((.*)\\)" "\\1" EXIV2_PATCH_VERSION ${EXIV2_PATCH_VERSION_MATCH}) + endif() + endif() + endforeach() + + set(LibExiv2_VERSION "${EXIV2_MAJOR_VERSION}.${EXIV2_MINOR_VERSION}.${EXIV2_PATCH_VERSION}") +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LibExiv2 + FOUND_VAR LibExiv2_FOUND + REQUIRED_VARS LibExiv2_LIBRARIES LibExiv2_INCLUDE_DIRS + VERSION_VAR LibExiv2_VERSION +) + +mark_as_advanced(LibExiv2_INCLUDE_DIRS LibExiv2_LIBRARIES) + +if(LibExiv2_FOUND AND NOT TARGET LibExiv2::LibExiv2) + add_library(LibExiv2::LibExiv2 UNKNOWN IMPORTED) + set_target_properties(LibExiv2::LibExiv2 PROPERTIES + IMPORTED_LOCATION "${LibExiv2_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${LibExiv2_INCLUDE_DIRS}" + ) +endif() + +include(FeatureSummary) +set_package_properties(LibExiv2 PROPERTIES + URL "http://www.exiv2.org" + DESCRIPTION "Image metadata support" +) diff --git a/cmake/templates/libkexiv2.pc.cmake.in b/cmake/templates/libkexiv2.pc.cmake.in --- a/cmake/templates/libkexiv2.pc.cmake.in +++ b/cmake/templates/libkexiv2.pc.cmake.in @@ -7,6 +7,6 @@ Description: A C++ library to manipulate EXIF/IPTC/XMP metadata using Exiv2 library. URL: https://cgit.kde.org/libkexiv2.git/ Requires: -Version: ${KEXIV2_LIB_VERSION_STRING} +Version: ${libkexiv2_VERSION} Libs: -L${LIB_INSTALL_DIR} -lkexiv2 Cflags: -I${INCLUDE_INSTALL_DIR} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,7 +6,6 @@ kde_enable_exceptions() -include_directories(${EXIV2_INCLUDE_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR}/..) add_definitions(${EXIV2_DEFINITIONS}) @@ -55,7 +54,7 @@ target_link_libraries(KF5KExiv2 PRIVATE - ${EXIV2_LIBRARIES} + LibExiv2::LibExiv2 PUBLIC Qt5::Core Qt5::Gui diff --git a/src/kexiv2.cpp b/src/kexiv2.cpp --- a/src/kexiv2.cpp +++ b/src/kexiv2.cpp @@ -153,7 +153,7 @@ // Since 0.14.0 release, we can extract run-time version of Exiv2. // else we return make version. - return QString::fromLatin1(Exiv2::version()); + return QString::fromStdString(Exiv2::versionString()); } QString KExiv2::version() diff --git a/src/kexiv2_p.h b/src/kexiv2_p.h --- a/src/kexiv2_p.h +++ b/src/kexiv2_p.h @@ -61,35 +61,14 @@ #pragma GCC visibility push(default) #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include // Check if Exiv2 support XMP #ifdef EXV_HAVE_XMP_TOOLKIT # define _XMP_SUPPORT_ 1 #endif -// Make sure an EXIV2_TEST_VERSION macro exists: - -#ifdef EXIV2_VERSION -# ifndef EXIV2_TEST_VERSION -# define EXIV2_TEST_VERSION(major,minor,patch) \ - ( EXIV2_VERSION >= EXIV2_MAKE_VERSION(major,minor,patch) ) -# endif -#else -# define EXIV2_TEST_VERSION(major,minor,patch) (false) -#endif - // With exiv2 > 0.20.0, all makernote header files have been removed to increase binary compatibility. // See Exiv2 bugzilla entry http://dev.exiv2.org/issues/719 // and wiki topic http://dev.exiv2.org/boards/3/topics/583 diff --git a/src/kexiv2_p.cpp b/src/kexiv2_p.cpp --- a/src/kexiv2_p.cpp +++ b/src/kexiv2_p.cpp @@ -124,19 +124,15 @@ QStringList rawTiffBasedSupported, rawTiffBasedNotSupported; - // Raw files supported by Exiv2 0.21 + // Raw files supported by Exiv2 0.23 rawTiffBasedSupported << QString::fromLatin1("dng") << QString::fromLatin1("nef") << QString::fromLatin1("pef") << QString::fromLatin1("orf") - << QString::fromLatin1("srw"); + << QString::fromLatin1("srw") + << QString::fromLatin1("cr2"); - if (Exiv2::testVersion(0,23,0)) - { - rawTiffBasedSupported << QString::fromLatin1("cr2"); - } - - // Raw files not supported by Exiv2 0.21 + // Raw files not supported by Exiv2 0.23 rawTiffBasedNotSupported << QString::fromLatin1("3fr") << QString::fromLatin1("arw") << QString::fromLatin1("dcr") @@ -149,11 +145,6 @@ << QString::fromLatin1("srf") << QString::fromLatin1("rw2"); - if (!Exiv2::testVersion(0,23,0)) - { - rawTiffBasedNotSupported << QString::fromLatin1("cr2"); - } - QString ext = finfo.suffix().toLower(); if (!writeRawFiles && (rawTiffBasedSupported.contains(ext) || rawTiffBasedNotSupported.contains(ext)) ) diff --git a/src/kexiv2exif.cpp b/src/kexiv2exif.cpp --- a/src/kexiv2exif.cpp +++ b/src/kexiv2exif.cpp @@ -987,7 +987,11 @@ if (pos == d->exifMetadata().end() || pos->count() != 1 || pos->toLong() != 0) { +#if EXIV2_TEST_VERSION(0,27,0) + throw Exiv2::Error(Exiv2::kerErrorMessage, "Exif.Image.NewSubfileType missing or not set as main image"); +#else throw Exiv2::Error(1, "Exif.Image.NewSubfileType missing or not set as main image"); +#endif } // Remove sub-IFD tags