Warning, /frameworks/extra-cmake-modules/find-modules/FindLibExiv2.cmake is written in an unsupported language. File is not indexed.

0001 # SPDX-FileCopyrightText: 2018 Christophe Giboudeaux <christophe@krop.fr>
0002 # SPDX-FileCopyrightText: 2010 Alexander Neundorf <neundorf@kde.org>
0003 # SPDX-FileCopyrightText: 2008 Gilles Caulier <caulier.gilles@gmail.com>
0004 #
0005 # SPDX-License-Identifier: BSD-3-Clause
0006 
0007 #[=======================================================================[.rst:
0008 FindLibExiv2
0009 ------------
0010 
0011 Try to find the Exiv2 library.
0012 
0013 This will define the following variables:
0014 
0015 ``LibExiv2_FOUND``
0016     True if (the requested version of) Exiv2 is available
0017 
0018 ``LibExiv2_VERSION``
0019     The version of Exiv2
0020 
0021 ``LibExiv2_INCLUDE_DIRS``
0022     The include dirs of Exiv2 for use with target_include_directories()
0023 
0024 ``LibExiv2_LIBRARIES``
0025     The Exiv2 library for use with target_link_libraries().
0026     This can be passed to target_link_libraries() instead of
0027     the ``LibExiv2::LibExiv2`` target
0028 
0029 If ``LibExiv2_FOUND`` is TRUE, it will also define the following imported
0030 target:
0031 
0032 ``LibExiv2::LibExiv2``
0033     The Exiv2 library
0034 
0035 In general we recommend using the imported target, as it is easier to use.
0036 Bear in mind, however, that if the target is in the link interface of an
0037 exported library, it must be made available by the package config file.
0038 
0039 Since 5.53.0.
0040 #]=======================================================================]
0041 
0042 find_package(PkgConfig QUIET)
0043 pkg_check_modules(PC_EXIV2 QUIET exiv2)
0044 
0045 find_path(LibExiv2_INCLUDE_DIRS NAMES exiv2/exif.hpp
0046     HINTS ${PC_EXIV2_INCLUDEDIR}
0047 )
0048 
0049 find_library(LibExiv2_LIBRARIES NAMES exiv2 libexiv2
0050     HINTS ${PC_EXIV2_LIBRARY_DIRS}
0051 )
0052 
0053 set(LibExiv2_VERSION ${PC_EXIV2_VERSION})
0054 
0055 if(NOT LibExiv2_VERSION AND DEFINED LibExiv2_INCLUDE_DIRS)
0056     # With exiv >= 0.27, the version #defines are in exv_conf.h instead of version.hpp
0057     foreach(_exiv2_version_file "version.hpp" "exv_conf.h")
0058         if(EXISTS "${LibExiv2_INCLUDE_DIRS}/exiv2/${_exiv2_version_file}")
0059             file(READ "${LibExiv2_INCLUDE_DIRS}/exiv2/${_exiv2_version_file}" _exiv_version_file_content)
0060             string(REGEX MATCH "#define EXIV2_MAJOR_VERSION[ ]+\\([0-9]+\\)" EXIV2_MAJOR_VERSION_MATCH ${_exiv_version_file_content})
0061             string(REGEX MATCH "#define EXIV2_MINOR_VERSION[ ]+\\([0-9]+\\)" EXIV2_MINOR_VERSION_MATCH ${_exiv_version_file_content})
0062             string(REGEX MATCH "#define EXIV2_PATCH_VERSION[ ]+\\([0-9]+\\)" EXIV2_PATCH_VERSION_MATCH ${_exiv_version_file_content})
0063             if(EXIV2_MAJOR_VERSION_MATCH)
0064                 string(REGEX REPLACE ".*_MAJOR_VERSION[ ]+\\((.*)\\)" "\\1" EXIV2_MAJOR_VERSION ${EXIV2_MAJOR_VERSION_MATCH})
0065                 string(REGEX REPLACE ".*_MINOR_VERSION[ ]+\\((.*)\\)" "\\1" EXIV2_MINOR_VERSION ${EXIV2_MINOR_VERSION_MATCH})
0066                 string(REGEX REPLACE ".*_PATCH_VERSION[ ]+\\((.*)\\)" "\\1"  EXIV2_PATCH_VERSION  ${EXIV2_PATCH_VERSION_MATCH})
0067             endif()
0068         endif()
0069     endforeach()
0070 
0071     set(LibExiv2_VERSION "${EXIV2_MAJOR_VERSION}.${EXIV2_MINOR_VERSION}.${EXIV2_PATCH_VERSION}")
0072 endif()
0073 
0074 include(FindPackageHandleStandardArgs)
0075 find_package_handle_standard_args(LibExiv2
0076     FOUND_VAR LibExiv2_FOUND
0077     REQUIRED_VARS  LibExiv2_LIBRARIES LibExiv2_INCLUDE_DIRS
0078     VERSION_VAR  LibExiv2_VERSION
0079 )
0080 
0081 mark_as_advanced(LibExiv2_INCLUDE_DIRS LibExiv2_LIBRARIES)
0082 
0083 if(LibExiv2_FOUND AND NOT TARGET LibExiv2::LibExiv2)
0084     add_library(LibExiv2::LibExiv2 UNKNOWN IMPORTED)
0085     set_target_properties(LibExiv2::LibExiv2 PROPERTIES
0086         IMPORTED_LOCATION "${LibExiv2_LIBRARIES}"
0087         INTERFACE_INCLUDE_DIRECTORIES "${LibExiv2_INCLUDE_DIRS}"
0088     )
0089     if (LibExiv2_VERSION VERSION_LESS 0.28.0)
0090         # exiv2 0.27 or older still uses std::auto_ptr, which is no longer available
0091         # by default when using newer C++ versions
0092         set_target_properties(LibExiv2::LibExiv2 PROPERTIES
0093             INTERFACE_COMPILE_DEFINITIONS "_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR=1;_HAS_AUTO_PTR_ETC=1"
0094         )
0095     endif()
0096 endif()
0097 
0098 include(FeatureSummary)
0099 set_package_properties(LibExiv2 PROPERTIES
0100     URL "https://www.exiv2.org"
0101     DESCRIPTION "Image metadata support"
0102 )