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

0001 # - Try to find the PoDoFo library
0002 #
0003 # Windows users MUST set when building:
0004 #
0005 # PoDoFo_USE_SHARED - whether use PoDoFo as shared library
0006 #
0007 # Once done this will define:
0008 #
0009 # PoDoFo_FOUND - system has the PoDoFo library
0010 # PoDoFo_INCLUDE_DIRS - the PoDoFo include directory
0011 # PoDoFo_LIBRARIES - the libraries needed to use PoDoFo
0012 # PoDoFo_DEFINITIONS - the definitions needed to use PoDoFo
0013 #
0014 # Copyright 2016 Pino Toscano <pino@kde.org>
0015 #
0016 # Redistribution and use in source and binary forms, with or without
0017 # modification, are permitted provided that the following conditions
0018 # are met:
0019 #
0020 # 1. Redistributions of source code must retain the copyright
0021 #    notice, this list of conditions and the following disclaimer.
0022 # 2. Redistributions in binary form must reproduce the copyright
0023 #    notice, this list of conditions and the following disclaimer in the
0024 #    documentation and/or other materials provided with the distribution.
0025 # 3. The name of the author may not be used to endorse or promote products
0026 #    derived from this software without specific prior written permission.
0027 #
0028 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
0029 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0030 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
0031 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
0032 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
0033 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0034 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0035 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0036 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
0037 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0038 
0039 find_path(PoDoFo_INCLUDE_DIRS
0040   NAMES podofo/podofo.h
0041 )
0042 find_library(PoDoFo_LIBRARIES
0043   NAMES libpodofo podofo
0044 )
0045 
0046 include(FindPackageHandleStandardArgs)
0047 find_package_handle_standard_args(PoDoFo DEFAULT_MSG PoDoFo_LIBRARIES PoDoFo_INCLUDE_DIRS)
0048 
0049 set(PoDoFo_DEFINITIONS)
0050 if(PoDoFo_FOUND)
0051   if(WIN32)
0052     if(NOT DEFINED PoDoFo_USE_SHARED)
0053       message(SEND_ERROR "Win32 users MUST set PoDoFo_USE_SHARED")
0054       message(SEND_ERROR "Set -DPoDoFo_USE_SHARED=0 if linking to a static library PoDoFo")
0055       message(SEND_ERROR "or -DPoDoFo_USE_SHARED=1 if linking to a DLL build of PoDoFo")
0056       message(FATAL_ERROR "PoDoFo_USE_SHARED unset on win32 build")
0057     else()
0058       if(PoDoFo_USE_SHARED)
0059         set(PoDoFo_DEFINITIONS "${PoDoFo_DEFINITIONS} -DUSING_SHARED_PODOFO")
0060       endif(PoDoFo_USE_SHARED)
0061     endif()
0062   endif()
0063 
0064   # PoDoFo-0.9.5 unconditionally includes openssl/opensslconf.h in a public
0065   # header. The fix is in https://sourceforge.net/p/podofo/code/1830/ and will
0066   # hopefully be released soon with 0.9.6. Note that krename doesn't use
0067   # OpenSSL in any way.
0068   file(STRINGS "${PoDoFo_INCLUDE_DIRS}/podofo/base/podofo_config.h" PoDoFo_MAJOR_VER_LINE REGEX "^#define[ \t]+PODOFO_VERSION_MAJOR[ \t]+[0-9]+$")
0069   file(STRINGS "${PoDoFo_INCLUDE_DIRS}/podofo/base/podofo_config.h" PoDoFo_MINOR_VER_LINE REGEX "^#define[ \t]+PODOFO_VERSION_MINOR[ \t]+[0-9]+$")
0070   file(STRINGS "${PoDoFo_INCLUDE_DIRS}/podofo/base/podofo_config.h" PoDoFo_PATCH_VER_LINE REGEX "^#define[ \t]+PODOFO_VERSION_PATCH[ \t]+[0-9]+$")
0071   string(REGEX REPLACE "^#define[ \t]+PODOFO_VERSION_MAJOR[ \t]+([0-9]+)$" "\\1" PoDoFo_MAJOR_VER "${PoDoFo_MAJOR_VER_LINE}")
0072   string(REGEX REPLACE "^#define[ \t]+PODOFO_VERSION_MINOR[ \t]+([0-9]+)$" "\\1" PoDoFo_MINOR_VER "${PoDoFo_MINOR_VER_LINE}")
0073   string(REGEX REPLACE "^#define[ \t]+PODOFO_VERSION_PATCH[ \t]+([0-9]+)$" "\\1" PoDoFo_PATCH_VER "${PoDoFo_PATCH_VER_LINE}")
0074   set(PoDoFo_VERSION "${PoDoFo_MAJOR_VER}.${PoDoFo_MINOR_VER}.${PoDoFo_PATCH_VER}")
0075   if(PoDoFo_VERSION VERSION_EQUAL "0.9.5")
0076     find_package(OpenSSL)
0077     if (OpenSSL_FOUND)
0078       message("OpenSSL found, which is required for this version of PoDofo (0.9.5)")
0079       set(PoDoFo_INCLUDE_DIRS ${PoDoFo_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR})
0080     else()
0081       unset(PoDoFo_FOUND)
0082       message("OpenSSL NOT found, which is required for this version of PoDofo (0.9.5)")
0083     endif()
0084   endif()
0085 endif()
0086 
0087 mark_as_advanced(PoDoFo_INCLUDE_DIRS PoDoFo_LIBRARIES PoDoFo_DEFINITIONS)