Debian Codegraph @

build_files/Modules/FindExiv2.cmake

raw
1 # - Try to find the Exiv2 library
2 #
3 # EXIV2_MIN_VERSION - You can set this variable to the minimum version you need
4 # before doing FIND_PACKAGE(Exiv2). The default is 0.12.
5 #
6 # Once done this will define
7 #
8 # EXIV2_FOUND - system has libexiv2
9 # EXIV2_INCLUDE_DIR - the libexiv2 include directory
10 # EXIV2_LIBRARIES - Link these to use libexiv2
11 # EXIV2_DEFINITIONS - Compiler switches required for using libexiv2
12 #
13 # The minimum required version of Exiv2 can be specified using the
14 # standard syntax, e.g. find_package(Exiv2 0.17)
15 #
16 # For compatiblity, also the variable EXIV2_MIN_VERSION can be set to the minimum version
17 # you need before doing FIND_PACKAGE(Exiv2). The default is 0.12.
18
19 # Copyright (c) 2010, Alexander Neundorf, <[email protected]>
20 # Copyright (c) 2008, Gilles Caulier, <[email protected]>
21 #
22 # Redistribution and use is allowed according to the terms of the BSD license.
23 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
24
25 # Support EXIV2_MIN_VERSION for compatibility:
26 if(NOT Exiv2_FIND_VERSION)
27 set(Exiv2_FIND_VERSION "${EXIV2_MIN_VERSION}")
28 endif(NOT Exiv2_FIND_VERSION)
29
30 # the minimum version of exiv2 we require
31 if(NOT Exiv2_FIND_VERSION)
32 set(Exiv2_FIND_VERSION "0.21")
33 endif(NOT Exiv2_FIND_VERSION)
34
35
36 if (NOT WIN32)
37 # use pkg-config to get the directories and then use these values
38 # in the FIND_PATH() and FIND_LIBRARY() calls
39 find_package(PkgConfig)
40 pkg_check_modules(PC_EXIV2 exiv2)
41 set(EXIV2_DEFINITIONS ${PC_EXIV2_CFLAGS_OTHER})
42 endif (NOT WIN32)
43
44
45 find_path(EXIV2_INCLUDE_DIR NAMES exiv2/exif.hpp
46 HINTS
47 ${PC_EXIV2_INCLUDEDIR}
48 ${PC_EXIV2_INCLUDE_DIRS}
49 )
50
51 find_library(EXIV2_LIBRARY NAMES exiv2 libexiv2
52 HINTS
53 ${PC_EXIV2_LIBDIR}
54 ${PC_EXIV2_LIBRARY_DIRS}
55 )
56
57
58 # Get the version number from exiv2/version.hpp and store it in the cache:
59 if(EXIV2_INCLUDE_DIR AND NOT EXIV2_VERSION)
60 file(READ ${EXIV2_INCLUDE_DIR}/exiv2/version.hpp EXIV2_VERSION_CONTENT)
61 string(REGEX MATCH "#define EXIV2_MAJOR_VERSION +\\( *([0-9]+) *\\)" _dummy "${EXIV2_VERSION_CONTENT}")
62 set(EXIV2_VERSION_MAJOR "${CMAKE_MATCH_1}")
63
64 string(REGEX MATCH "#define EXIV2_MINOR_VERSION +\\( *([0-9]+) *\\)" _dummy "${EXIV2_VERSION_CONTENT}")
65 set(EXIV2_VERSION_MINOR "${CMAKE_MATCH_1}")
66
67 string(REGEX MATCH "#define EXIV2_PATCH_VERSION +\\( *([0-9]+) *\\)" _dummy "${EXIV2_VERSION_CONTENT}")
68 set(EXIV2_VERSION_PATCH "${CMAKE_MATCH_1}")
69
70 set(EXIV2_VERSION "${EXIV2_VERSION_MAJOR}.${EXIV2_VERSION_MINOR}.${EXIV2_VERSION_PATCH}" CACHE STRING "Version number of Exiv2" FORCE)
71 endif(EXIV2_INCLUDE_DIR AND NOT EXIV2_VERSION)
72
73 set(EXIV2_LIBRARIES "${EXIV2_LIBRARY}")
74
75 include(FindPackageHandleStandardArgs)
76 #find_package_handle_standard_args(Exiv2 REQUIRED_VARS EXIV2_LIBRARY EXIV2_INCLUDE_DIR
77 # VERSION_VAR EXIV2_VERSION)
78
79 find_package_handle_standard_args(Exiv2 REQUIRED_VARS EXIV2_LIBRARY EXIV2_INCLUDE_DIR
80 EXIV2_VERSION)
81 mark_as_advanced(EXIV2_INCLUDE_DIR EXIV2_LIBRARY)
82