Warning, /utilities/krename/cmake/modules/FindLibExiv2.cmake is written in an unsupported language. File is not indexed.

0001 #.rst:
0002 # FindLibExiv2
0003 # ------------
0004 #
0005 # Try to find the Exiv2 library.
0006 #
0007 # This will define the following variables:
0008 #
0009 # ``LibExiv2_FOUND``
0010 #     System has LibExiv2.
0011 #
0012 # ``LibExiv2_VERSION``
0013 #     The version of LibExiv2.
0014 #
0015 # ``LibExiv2_INCLUDE_DIRS``
0016 #     This should be passed to target_include_directories() if
0017 #     the target is not used for linking.
0018 #
0019 # ``LibExiv2_LIBRARIES``
0020 #     The LibExiv2 library.
0021 #     This can be passed to target_link_libraries() instead of
0022 #     the ``LibExiv2::LibExiv2`` target
0023 #
0024 # If ``LibExiv2_FOUND`` is TRUE, the following imported target
0025 # will be available:
0026 #
0027 # ``LibExiv2::LibExiv2``
0028 #     The Exiv2 library
0029 #
0030 # Since 5.53.0.
0031 #
0032 #=============================================================================
0033 # Copyright (c) 2018, Christophe Giboudeaux, <christophe@krop.fr>
0034 # Copyright (c) 2010, Alexander Neundorf, <neundorf@kde.org>
0035 # Copyright (c) 2008, Gilles Caulier, <caulier.gilles@gmail.com>
0036 #
0037 #
0038 # Redistribution and use in source and binary forms, with or without
0039 # modification, are permitted provided that the following conditions
0040 # are met:
0041 #
0042 # 1. Redistributions of source code must retain the copyright
0043 #    notice, this list of conditions and the following disclaimer.
0044 # 2. Redistributions in binary form must reproduce the copyright
0045 #    notice, this list of conditions and the following disclaimer in the
0046 #    documentation and/or other materials provided with the distribution.
0047 # 3. The name of the author may not be used to endorse or promote products
0048 #    derived from this software without specific prior written permission.
0049 #
0050 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
0051 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0052 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
0053 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
0054 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
0055 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0056 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0057 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0058 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
0059 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0060 #=============================================================================
0061 
0062 find_package(PkgConfig QUIET)
0063 pkg_check_modules(PC_EXIV2 QUIET exiv2)
0064 
0065 find_path(LibExiv2_INCLUDE_DIRS NAMES exiv2/exif.hpp
0066     HINTS ${PC_EXIV2_INCLUDEDIR}
0067 )
0068 
0069 find_library(LibExiv2_LIBRARIES NAMES exiv2 libexiv2
0070     HINTS ${PC_EXIV2_LIBRARY_DIRS}
0071 )
0072 
0073 set(LibExiv2_VERSION ${PC_EXIV2_VERSION})
0074 
0075 if(NOT LibExiv2_VERSION AND DEFINED LibExiv2_INCLUDE_DIRS)
0076     # With exiv >= 0.27, the version #defines are in exv_conf.h instead of version.hpp
0077     foreach(_exiv2_version_file "version.hpp" "exv_conf.h")
0078         if(EXISTS "${LibExiv2_INCLUDE_DIRS}/exiv2/${_exiv2_version_file}")
0079             file(READ "${LibExiv2_INCLUDE_DIRS}/exiv2/${_exiv2_version_file}" _exiv_version_file_content)
0080             string(REGEX MATCH "#define EXIV2_MAJOR_VERSION[ ]+\\([0-9]+\\)" EXIV2_MAJOR_VERSION_MATCH ${_exiv_version_file_content})
0081             string(REGEX MATCH "#define EXIV2_MINOR_VERSION[ ]+\\([0-9]+\\)" EXIV2_MINOR_VERSION_MATCH ${_exiv_version_file_content})
0082             string(REGEX MATCH "#define EXIV2_PATCH_VERSION[ ]+\\([0-9]+\\)" EXIV2_PATCH_VERSION_MATCH ${_exiv_version_file_content})
0083             if(EXIV2_MAJOR_VERSION_MATCH)
0084                 string(REGEX REPLACE ".*_MAJOR_VERSION[ ]+\\((.*)\\)" "\\1" EXIV2_MAJOR_VERSION ${EXIV2_MAJOR_VERSION_MATCH})
0085                 string(REGEX REPLACE ".*_MINOR_VERSION[ ]+\\((.*)\\)" "\\1" EXIV2_MINOR_VERSION ${EXIV2_MINOR_VERSION_MATCH})
0086                 string(REGEX REPLACE ".*_PATCH_VERSION[ ]+\\((.*)\\)" "\\1"  EXIV2_PATCH_VERSION  ${EXIV2_PATCH_VERSION_MATCH})
0087             endif()
0088         endif()
0089     endforeach()
0090 
0091     set(LibExiv2_VERSION "${EXIV2_MAJOR_VERSION}.${EXIV2_MINOR_VERSION}.${EXIV2_PATCH_VERSION}")
0092 endif()
0093 
0094 include(FindPackageHandleStandardArgs)
0095 find_package_handle_standard_args(LibExiv2
0096     FOUND_VAR LibExiv2_FOUND
0097     REQUIRED_VARS  LibExiv2_LIBRARIES LibExiv2_INCLUDE_DIRS
0098     VERSION_VAR  LibExiv2_VERSION
0099 )
0100 
0101 mark_as_advanced(LibExiv2_INCLUDE_DIRS LibExiv2_LIBRARIES)
0102 
0103 if(LibExiv2_FOUND AND NOT TARGET LibExiv2::LibExiv2)
0104     add_library(LibExiv2::LibExiv2 UNKNOWN IMPORTED)
0105     set_target_properties(LibExiv2::LibExiv2 PROPERTIES
0106         IMPORTED_LOCATION "${LibExiv2_LIBRARIES}"
0107         INTERFACE_INCLUDE_DIRECTORIES "${LibExiv2_INCLUDE_DIRS}"
0108     )
0109 endif()
0110 
0111 include(FeatureSummary)
0112 set_package_properties(LibExiv2 PROPERTIES
0113     URL "http://www.exiv2.org"
0114     DESCRIPTION "Image metadata support"
0115 )