Warning, /utilities/krename/cmake/modules/FindPoDoFo.cmake is written in an unsupported language. File is not indexed.
0001 # SPDX-FileCopyrightText: 2016 Pino Toscano <pino@kde.org>
0002 # SPDX-FileCopyrightText: 2023 Heiko Becker <heiko.becker@kde.org>
0003 #
0004 # SPDX-License-Identifier: BSD-3-Clause
0005
0006
0007 #[=======================================================================[.rst:
0008 FindPoDoFo
0009 ------------
0010
0011 Try to find PoDoFo, a C++ library to work with the PDF file format
0012
0013 This will define the following variables:
0014
0015 ``PoDoFo_FOUND``
0016 True if PoDoFo is available
0017 ``PoDoFo_VERSION``
0018 The version of PoDoFo
0019 ``PoDoFo_LIBRARIES``
0020 The libraries of PoDoFofor use with target_link_libraries()
0021 ``PoDoFo_INCLUDE_DIRS``
0022 The include dirs of PoDoFo for use with target_include_directories()
0023
0024 If ``PoDoFo_FOUND`` is TRUE, it will also define the following imported
0025 target:
0026
0027 ``PoDoFo::PoDoFo``
0028 The PoDoFo library
0029
0030 In general we recommend using the imported target, as it is easier to use.
0031 Bear in mind, however, that if the target is in the link interface of an
0032 exported library, it must be made available by the package config file.
0033
0034 #]=======================================================================]
0035
0036 find_package(PkgConfig QUIET)
0037 pkg_search_module(PC_PoDoFo QUIET libpodofo libpodofo-0)
0038
0039 find_library(PoDoFo_LIBRARIES
0040 NAMES podofo
0041 HINTS ${PC_PoDoFo_LIBRARY_DIRS}
0042 )
0043
0044 find_path(PoDoFo_INCLUDE_DIRS
0045 NAMES podofo.h
0046 HINTS ${PC_PoDoFo_INCLUDE_DIRS}
0047 )
0048
0049 if(PoDoFo_INCLUDE_DIRS)
0050 # NOTE: I have no idea if that's still needed and no possibility to test on
0051 # Windows.
0052 #if(WIN32)
0053 # if(NOT DEFINED PoDoFo_USE_SHARED)
0054 # message(SEND_ERROR "Win32 users MUST set PoDoFo_USE_SHARED")
0055 # message(SEND_ERROR "Set -DPoDoFo_USE_SHARED=0 if linking to a static library PoDoFo")
0056 # message(SEND_ERROR "or -DPoDoFo_USE_SHARED=1 if linking to a DLL build of PoDoFo")
0057 # message(FATAL_ERROR "PoDoFo_USE_SHARED unset on win32 build")
0058 # else()
0059 # if(PoDoFo_USE_SHARED)
0060 # set(PoDoFo_DEFINITIONS "${PoDoFo_DEFINITIONS} -DUSING_SHARED_PODOFO")
0061 # endif(PoDoFo_USE_SHARED)
0062 # endif()
0063 #endif()
0064
0065 find_file(PoDoFo_CONFIG podofo_config.h PATHS ${PoDoFo_INCLUDE_DIRS} PATH_SUFFIXES auxiliary base)
0066 file(STRINGS "${PoDoFo_CONFIG}" PoDoFo_MAJOR_VER_LINE REGEX "^#define[ \t]+PODOFO_VERSION_MAJOR[ \t]+[0-9]+$")
0067 file(STRINGS "${PoDoFo_CONFIG}" PoDoFo_MINOR_VER_LINE REGEX "^#define[ \t]+PODOFO_VERSION_MINOR[ \t]+[0-9]+$")
0068 file(STRINGS "${PoDoFo_CONFIG}" PoDoFo_PATCH_VER_LINE REGEX "^#define[ \t]+PODOFO_VERSION_PATCH[ \t]+[0-9]+$")
0069 string(REGEX REPLACE "^#define[ \t]+PODOFO_VERSION_MAJOR[ \t]+([0-9]+)$" "\\1" PoDoFo_MAJOR_VER "${PoDoFo_MAJOR_VER_LINE}")
0070 string(REGEX REPLACE "^#define[ \t]+PODOFO_VERSION_MINOR[ \t]+([0-9]+)$" "\\1" PoDoFo_MINOR_VER "${PoDoFo_MINOR_VER_LINE}")
0071 string(REGEX REPLACE "^#define[ \t]+PODOFO_VERSION_PATCH[ \t]+([0-9]+)$" "\\1" PoDoFo_PATCH_VER "${PoDoFo_PATCH_VER_LINE}")
0072 set(PoDoFo_VERSION "${PoDoFo_MAJOR_VER}.${PoDoFo_MINOR_VER}.${PoDoFo_PATCH_VER}")
0073
0074 # PoDoFo-0.9.5 unconditionally includes openssl/opensslconf.h in a public
0075 # header. The fix is in https://sourceforge.net/p/podofo/code/1830/ and will
0076 # hopefully be released soon with 0.9.6. Note that krename doesn't use
0077 # OpenSSL in any way.
0078 if(PoDoFo_VERSION VERSION_EQUAL "0.9.5")
0079 find_package(OpenSSL)
0080 if(OpenSSL_FOUND)
0081 message("OpenSSL found, which is required for this version of PoDofo (0.9.5)")
0082 set(PoDoFo_INCLUDE_DIRS ${PoDoFo_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR})
0083 else()
0084 unset(PoDoFo_FOUND)
0085 message("OpenSSL NOT found, which is required for this version of PoDofo (0.9.5)")
0086 endif()
0087 endif()
0088 endif()
0089
0090 if(PoDoFo_VERSION VERSION_GREATER_EQUAL 0.10.0)
0091 set(CMAKE_CXX_STANDARD 17)
0092 endif()
0093
0094 include(FindPackageHandleStandardArgs)
0095 find_package_handle_standard_args(PoDoFo
0096 FOUND_VAR
0097 PoDoFo_FOUND
0098 REQUIRED_VARS
0099 PoDoFo_LIBRARIES
0100 PoDoFo_INCLUDE_DIRS
0101 VERSION_VAR
0102 PoDoFo_VERSION
0103 )
0104
0105 if(PoDoFo_FOUND AND NOT TARGET PoDoFo::PoDoFo)
0106 add_library(PoDoFo::PoDoFo UNKNOWN IMPORTED)
0107 set_target_properties(PoDoFo::PoDoFo PROPERTIES
0108 IMPORTED_LOCATION "${PoDoFo_LIBRARIES}"
0109 INTERFACE_COMPILE_OPTIONS "${PC_PoDoFo_CFLAGS}"
0110 INTERFACE_INCLUDE_DIRECTORIES "${PoDoFo_INCLUDE_DIRS}"
0111 )
0112 if(TARGET PkgConfig::PC_PoDoFo)
0113 target_link_libraries(PoDoFo::PoDoFo INTERFACE PkgConfig::PC_PoDoFo)
0114 endif()
0115 endif()
0116
0117 mark_as_advanced(PoDoFo_LIBRARIES PoDoFo_INCLUDE_DIRS PoDoFo_VERSION)
0118
0119 include(FeatureSummary)
0120 set_package_properties(PoDoFo PROPERTIES
0121 DESCRIPTION "A C++ libary to work with the PDF file format"
0122 URL "https://github.com/podofo/podofo"
0123 )
0124