From cb808f574248a0c96894338fdcf03b12fbbc080d Mon Sep 17 00:00:00 2001 From: Gilles Caulier Date: Sun, 7 Oct 2018 10:17:30 +0200 Subject: add support of Exiv2 0.27 --- core/cmake/modules/FindExiv2.cmake | 75 +++++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 22 deletions(-) diff --git a/core/cmake/modules/FindExiv2.cmake b/core/cmake/modules/FindExiv2.cmake index 1e971a3..02d2943 100644 --- a/core/cmake/modules/FindExiv2.cmake +++ b/core/cmake/modules/FindExiv2.cmake @@ -1,7 +1,7 @@ # - 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.15. +# before doing FIND_PACKAGE(Exiv2). The default is 0.26. # # Once done this will define # @@ -11,34 +11,41 @@ # 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) +# 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.15. +# you need before doing FIND_PACKAGE(Exiv2). The default is 0.26. # # Copyright (c) 2010, Alexander Neundorf, -# Copyright (c) 2008-2017, Gilles Caulier, +# Copyright (c) 2008-2018, 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 + 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.15") -endif(NOT Exiv2_FIND_VERSION) -if (NOT WIN32) + 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 (NOT WIN32) + +endif() find_path(EXIV2_INCLUDE_DIR NAMES exiv2/exif.hpp HINTS @@ -52,20 +59,44 @@ find_library(EXIV2_LIBRARY NAMES exiv2 libexiv2 ${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}") +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(EXIV2_VERSION_MAJOR AND EXIV2_VERSION_MINOR AND EXIV2_VERSION_PATCH) + + 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}") - string(REGEX MATCH "#define EXIV2_MINOR_VERSION +\\( *([0-9]+) *\\)" _dummy "${EXIV2_VERSION_CONTENT}") - set(EXIV2_VERSION_MINOR "${CMAKE_MATCH_1}") + set(EXIV2_VERSION "${EXIV2_VERSION_MAJOR}.${EXIV2_VERSION_MINOR}.${EXIV2_VERSION_PATCH}" + CACHE STRING "Version number of Exiv2" FORCE) - string(REGEX MATCH "#define EXIV2_PATCH_VERSION +\\( *([0-9]+) *\\)" _dummy "${EXIV2_VERSION_CONTENT}") - set(EXIV2_VERSION_PATCH "${CMAKE_MATCH_1}") + endif() - 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) +endif() set(EXIV2_LIBRARIES "${EXIV2_LIBRARY}") -- cgit v1.1