1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
3 #***************** IMPORTANT ************* IMPORTANT **********************
4 # Look at http://www.vtk.org/Wiki/CMake_HowToDoPlatformChecks
5 # and the other wiki entries before you add anything. You might not need to.
6 #****************************************************************************
9 # Project name and version
13 SET(PODOFO_VERSION_MAJOR "0" CACHE STRING "Major part of PoDoFo version number")
14 SET(PODOFO_VERSION_MINOR "9" CACHE STRING "Minor part of PoDoFo version number")
15 SET(PODOFO_VERSION_PATCH "7" CACHE STRING "Patchlevel part of PoDoFo version number")
16 SET(PODOFO_SOVERSION "${PODOFO_VERSION_MAJOR}.${PODOFO_VERSION_MINOR}.${PODOFO_VERSION_PATCH}")
17 SET(PODOFO_LIBVERSION "${PODOFO_SOVERSION}")
23 INCLUDE(CheckCXXSourceCompiles)
24 INCLUDE(CheckIncludeFile)
25 INCLUDE(CheckLibraryExists)
26 INCLUDE(TestBigEndian)
27 INCLUDE(CheckTypeSize)
30 # Setup CMake Policies
33 # Prefer files in CMAKE_MODULE_PATH over shipped ones in module directory
34 CMAKE_POLICY(SET CMP0017 NEW) # https://cmake.org/cmake/help/v3.0/policy/CMP0017.html
35 # Do not use export_library_dependencies() anymore
37 CMAKE_POLICY(SET CMP0033 NEW) # https://cmake.org/cmake/help/v3.0/policy/CMP0033.html
40 # Load modules from our source tree too
41 SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
44 # Builds must use this CMakeLists.txt, not the one in src/ or somewhere else.
45 # If users try to use something else the results can be confusing. We set a
46 # variable here that we require to be set elsewhere, otherwise we'll complain.
47 SET(PODOFO_MAIN_CMAKELISTS_READ TRUE)
49 # If the user hasn't told use specifically what they want, build only
50 # a static library or only a shared library on Windows.
51 IF(NOT DEFINED PODOFO_BUILD_SHARED AND NOT DEFINED PODOFO_BUILD_STATIC)
53 SET(PODOFO_BUILD_STATIC FALSE)
54 SET(PODOFO_BUILD_SHARED TRUE)
56 SET(PODOFO_BUILD_STATIC TRUE)
57 SET(PODOFO_BUILD_SHARED FALSE)
59 ENDIF(NOT DEFINED PODOFO_BUILD_SHARED AND NOT DEFINED PODOFO_BUILD_STATIC)
60 IF(DEFINED PODOFO_BUILD_SHARED AND NOT DEFINED PODOFO_BUILD_STATIC)
61 IF(PODOFO_BUILD_SHARED)
62 SET(PODOFO_BUILD_STATIC FALSE)
63 ELSE(PODOFO_BUILD_SHARED)
64 SET(PODOFO_BUILD_STATIC TRUE)
65 ENDIF(PODOFO_BUILD_SHARED)
66 ENDIF(DEFINED PODOFO_BUILD_SHARED AND NOT DEFINED PODOFO_BUILD_STATIC)
67 IF(NOT DEFINED PODOFO_BUILD_SHARED AND DEFINED PODOFO_BUILD_STATIC)
68 IF(PODOFO_BUILD_STATIC)
69 SET(PODOFO_BUILD_SHARED FALSE)
70 ELSE(PODOFO_BUILD_STATIC)
71 SET(PODOFO_BUILD_SHARED TRUE)
72 ENDIF(PODOFO_BUILD_STATIC)
73 ENDIF(NOT DEFINED PODOFO_BUILD_SHARED AND DEFINED PODOFO_BUILD_STATIC)
75 IF(DEFINED LIB_SUFFIX)
76 SET(LIBDIRNAME "lib${LIB_SUFFIX}")
77 ELSE(DEFINED LIB_SUFFIX)
79 # Some 64 bit linux distros use /usr/lib64 for 64 bit libraries.
80 # on these platforms we must
81 IF(NOT DEFINED WANT_LIB64)
82 # TODO: detect 64-bit build and existance of /usr/lib64 and set to TRUE.
83 MESSAGE("WANT_LIB64 unset; assuming normal library directory names")
85 ENDIF(NOT DEFINED WANT_LIB64)
88 SET(LIBDIRNAME "lib64")
93 ENDIF(DEFINED LIB_SUFFIX)
94 MESSAGE("Will install libraries to ${CMAKE_INSTALL_PREFIX}/${LIBDIRNAME}")
96 CHECK_CXX_SOURCE_COMPILES("#include <memory>
102 int main(void) { std::unique_ptr<Cls> cls; return 0; }" PODOFO_HAVE_UNIQUE_PTR)
104 # Some headers that tend to vary a bit
105 CHECK_INCLUDE_FILE("strings.h" PODOFO_HAVE_STRINGS_H)
106 CHECK_INCLUDE_FILE("arpa/inet.h" PODOFO_HAVE_ARPA_INET_H)
107 CHECK_INCLUDE_FILE("winsock2.h" PODOFO_HAVE_WINSOCK2_H)
108 CHECK_INCLUDE_FILE("mem.h" PODOFO_HAVE_MEM_H)
109 CHECK_INCLUDE_FILE("ctype.h" PODOFO_HAVE_CTYPE_H)
111 # Do some type size detection and provide yet another set of typedefs for fixed
112 # font sizes. We can't use the c99 / c++0x uint32_t etc, because people use
113 # ancient compilers that don't and will never support the standard.
115 CHECK_INCLUDE_FILE("sys/types.h" PODOFO_HAVE_SYS_TYPES_H)
116 CHECK_INCLUDE_FILE("stdint.h" PODOFO_HAVE_STDINT_H)
117 # See: http://msdn.microsoft.com/en-us/library/aa384264(VS.85).aspx
118 CHECK_INCLUDE_FILE("BaseTsd.h" PODOFO_HAVE_BASETSD_H)
120 CHECK_TYPE_SIZE("long int" SZ_LONG)
122 # We cache integer type detection results, and don't repeat them
123 # (and overwrite the user's manual changes) if they've been done already.
124 IF(NOT PDF_INT64_TYPENAME)
125 # I hate old compilers.
126 IF(PODOFO_HAVE_STDINT_H)
127 SET(pdfint8 "int8_t")
128 SET(pdfint16 "int16_t")
129 SET(pdfint32 "int32_t")
130 SET(pdfint64 "int64_t")
131 SET(pdfuint8 "uint8_t")
132 SET(pdfuint16 "uint16_t")
133 SET(pdfuint32 "uint32_t")
134 SET(pdfuint64 "uint64_t")
135 CHECK_TYPE_SIZE("int64_t" SZ_INT64)
136 ELSE(PODOFO_HAVE_STDINT_H)
137 # No stdint.h . Try BaseTsd.h windows types.
138 IF(PODOFO_HAVE_BASETSD_H)
139 # We have BaseTsd.h, so use those types.
140 SET(pdfint8 "signed char")
141 SET(pdfint16 "short")
142 SET(pdfint32 "INT32")
143 SET(pdfint64 "INT64")
144 SET(pdfuint8 "unsigned char")
145 SET(pdfuint16 "unsigned short")
146 SET(pdfuint32 "UINT32")
147 SET(pdfuint64 "UINT64")
148 CHECK_TYPE_SIZE("INT64" SZ_INT64)
149 ELSE(PODOFO_HAVE_BASETSD_H)
150 # No BaseTsd.h either. Assume the standard types, and go poking
151 # for a sane 64-bit integer.
153 # First, though, make sure sizeof(int) = 4 and if not, scream, because
154 # hopefully this case will never be hit and we'll never have to write
155 # the horrible code check for
156 CHECK_TYPE_SIZE("signed char" SZ_TINY_INT)
157 CHECK_TYPE_SIZE("unsigned char" SZ_TINY_UINT)
158 CHECK_TYPE_SIZE("short int" SZ_SHORT_INT)
159 CHECK_TYPE_SIZE("int" SZ_INT)
160 CHECK_TYPE_SIZE("unsigned short int" SZ_UINT)
161 CHECK_TYPE_SIZE("unsigned int" SZ_SHORT_UINT)
162 SET(smallintsok SZ_INT == 4 AND SZ_UINT == 4 AND SZ_SHORT_INT == 2 AND SZ_SHORT_UINT == 2 AND SZ_TINY_INT == 1 AND SZ_TINY_UINT == 1)
164 MESSAGE(FATAL "sizeof(int) != 4 and/or sizeof(short) != 2 and no stdint.h or BaseTsd.h found. We don't know how to cope with this.")
165 ENDIF(NOT smallintsok)
166 SET(pdfint8 "signed char")
167 SET(pdfint16 "short")
169 SET(pdfuint8 "unsigned char")
170 SET(pdfuint16 "unsigned short")
171 SET(pdfuint32 "unsigned int")
172 # Now we just have to figure out what 64-bit integer type we can use.
174 # Do we have VC >= 6's __uint64 and __int64?
175 # See: http://icfun.blogspot.com/2008/04/use-of-int64-variable-in-c.html
176 CHECK_TYPE_SIZE("__int64" SZ___INT64)
177 CHECK_TYPE_SIZE("__uint64" SZ___UINT64)
178 IF(SZ___INT64 == 8 AND SZ___UINT64 == 8)
179 # MS compiler, VC6 or newer without BaseTsd.h in SDK
180 SET(pdfint64 "__int64")
181 SET(pdfuint64 "__uint64")
182 CHECK_TYPE_SIZE("__int64" SZ_INT64)
183 ELSE(SZ___INT64 AND SZ___UINT64)
184 # Still no luck. Old unix compiler, Borland, or some other monster?
185 # Are we lucky and sizeof(long) == 8?
186 CHECK_TYPE_SIZE("unsigned long int" SZ_ULONG)
187 IF(SZ_LONG == 8 AND SZ_ULONG == 8)
188 # Must be on a LP64 platform, sizeof(long) = 8
189 SET(pdfint64 "long int")
190 SET(pdfuint64 "unsigned long int")
191 CHECK_TYPE_SIZE("long int" SZ_INT64)
192 ELSE(SZ_LONG == 8 AND SZ_ULONG == 8)
193 # See if the compiler implements "long long int", int64_t, int64,
194 # or _int64 (in this order, __int64 check already done)
195 IF(PODOFO_HAVE_SYS_TYPES_H)
196 SET(CMAKE_EXTRA_INCLUDE_FILES "sys/types.h")
197 ENDIF(PODOFO_HAVE_SYS_TYPES_H)
198 CHECK_TYPE_SIZE("long long int" SZ_LONG_LONG)
199 CHECK_TYPE_SIZE("unsigned long long int" SZ_UNSIGNED_LONG_LONG)
200 IF(SZ_LONG_LONG == 8 AND SZ_UNSIGNED_LONG_LONG == 8)
201 SET(pdfint64 "long long int")
202 SET(pdfuint64 "unsigned long long int")
203 CHECK_TYPE_SIZE("long long int" SZ_INT64)
204 ELSE(SZ_LONG_LONG == 8 AND SZ_UNSIGNED_LONG_LONG == 8)
205 # The standard type int64_t is normally found in stdint.h,
206 # but use a type of this name anyway if present
207 CHECK_TYPE_SIZE("int64_t" SZ_INT64_T)
208 CHECK_TYPE_SIZE("uint64_t" SZ_UINT64_T)
209 IF(SZ_INT64_T AND SZ_UINT64_T)
210 SET(pdfint64 "int64_t")
211 SET(pdfuint64 "uint64_t")
212 CHECK_TYPE_SIZE("int64_t" SZ_INT64)
213 ELSE(SZ_INT64_T AND SZ_UINT64_T)
214 CHECK_TYPE_SIZE("int64" SZ_INT64)
215 CHECK_TYPE_SIZE("uint64" SZ_UINT64)
216 IF(SZ_INT64 AND SZ_UINT64)
217 SET(pdfint64 "int64")
218 SET(pdfuint64 "uint64")
219 CHECK_TYPE_SIZE("int64" SZ_INT64)
220 ELSE(SZ_INT64 AND SZ_UINT64)
221 CHECK_TYPE_SIZE("_int64" SZ__INT64)
222 CHECK_TYPE_SIZE("_uint64" SZ__UINT64)
223 IF(SZ__INT64 AND SZ__UINT64)
224 SET(pdfint64 "_int64")
225 SET(pdfuint64 "_uint64")
226 CHECK_TYPE_SIZE("_int64" SZ_INT64)
227 ELSE(SZ__INT64 AND SZ__UINT64)
228 MESSAGE("Oh my lord, your compiler doesn't seem to support any of the int64 type flavours we tried.")
229 MESSAGE(WARNING "You must set the PDF_INTxx_TYPENAME and PDF_UINTxx_TYPENAME variables manually")
230 ENDIF(SZ__INT64 AND SZ__UINT64)
231 ENDIF(SZ_INT64 AND SZ_UINT64)
232 ENDIF(SZ_INT64_T AND SZ_UINT64_T)
233 ENDIF(SZ_LONG_LONG == 8 AND SZ_UNSIGNED_LONG_LONG == 8)
234 ENDIF(SZ_LONG == 8 AND SZ_ULONG == 8)
235 ENDIF(SZ___INT64 AND SZ___UINT64)
236 ENDIF(PODOFO_HAVE_BASETSD_H)
237 ENDIF(PODOFO_HAVE_STDINT_H)
238 SET(CMAKE_EXTRA_INCLUDE_FILES)
239 ENDIF(NOT PDF_INT64_TYPENAME)
241 IF(NOT PDF_INT64_TYPENAME AND pdfint64)
242 SET(PDF_INT64_TYPENAME "${pdfint64}" CACHE STRING "Name of detected 64-bit signed integer type to use")
243 SET(PDF_INT32_TYPENAME "${pdfint32}" CACHE STRING "Name of detected 32-bit signed integer type to use")
244 SET(PDF_INT16_TYPENAME "${pdfint16}" CACHE STRING "Name of detected 16-bit signed integer type to use")
245 SET(PDF_INT8_TYPENAME "${pdfint8}" CACHE STRING "Name of detected 8-bit signed integer type to use")
246 SET(PDF_UINT64_TYPENAME "${pdfuint64}" CACHE STRING "Name of detected 64-bit unsigned integer type to use")
247 SET(PDF_UINT32_TYPENAME "${pdfuint32}" CACHE STRING "Name of detected 32-bit unsigned integer type to use")
248 SET(PDF_UINT16_TYPENAME "${pdfuint16}" CACHE STRING "Name of detected 16-bit unsigned integer type to use")
249 SET(PDF_UINT8_TYPENAME "${pdfuint8}" CACHE STRING "Name of detected 8-bit unsigned integer type to use")
250 ENDIF(NOT PDF_INT64_TYPENAME AND pdfint64)
252 # Linux packagers want an uninstall target.
254 "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
255 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
257 ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}"
258 -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
260 # Check if we are big endian
261 TEST_BIG_ENDIAN(TEST_BIG)
264 # We must explicitly link to the core win32 libraries, and we need winsock2
265 # to get some byte-order conversion routines too.
266 SET(PLATFORM_SYSTEM_LIBRARIES kernel32 user32 gdi32 winspool comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32)
267 # Microsoft deprecate certain POSIX functions that we use.
268 # for now, turn off these warnings.
269 ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
270 # We need a fake unistd.h for some libraries to build. They try to include <unistd.h>
271 # which is not available under win32 with MSVC++, but everything in unistd.h is defined,
272 # so an empty file solves the issue.
273 SET(EXTRA_INCLUDES ${PoDoFo_SOURCE_DIR}/vcincludes)
275 SET(PLATFORM_SYSTEM_LIBRARIES)
279 IF(UNIX AND NOT PODOFO_NO_FONTMANAGER)
280 SET(WANT_FONTCONFIG TRUE CACHE INTERNAL
281 "True if PoDoFo should be built with fontconfig support")
282 ELSE(UNIX AND NOT PODOFO_NO_FONTMANAGER)
283 SET(WANT_FONTCONFIG FALSE CACHE INTERNAL
284 "True if PoDoFo should be built with fontconfig support")
285 ENDIF(UNIX AND NOT PODOFO_NO_FONTMANAGER)
288 IF(CMAKE_COMPILER_IS_GNUCXX)
289 MESSAGE("Using gcc specific compiler options")
290 # We can be more specific about what we want out of g++
291 # than with most other compilers.
293 # If the user hasn't specifically said whether they want
294 # -fvisibility=hidden or not, turn it on if it's said to
295 # be supported, off for other gcc versions.
296 IF(NOT DEFINED PODOFO_USE_VISIBILITY)
297 SET(PODOFO_USE_VISIBILITY ${PODOFO_HAVE_GCC_SYMBOL_VISIBILITY})
298 ENDIF(NOT DEFINED PODOFO_USE_VISIBILITY)
300 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
302 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Woverloaded-virtual -Wswitch -Wcast-qual -Wwrite-strings -Wredundant-decls -Wreorder -Wno-deprecated-declarations")
305 # Note that we do not need debug definitions here. Set
306 # -DCMAKE_BUILD_TYPE=debug or (if you want an optimised
307 # release build with debug info) -DCMAKE_CXX_FLAGS="-g3"
309 # We add -W unless we're using gcc on win32, where it produces
310 # spurious warnings about dllimport of inlines because of a dllimport
311 # declaration on the whole class.
315 # If they've enabled the use of gcc4 symbol visibility, use it.
316 IF(PODOFO_USE_VISIBILITY)
318 -DPODOFO_HAVE_GCC_SYMBOL_VISIBILITY
321 ENDIF(PODOFO_USE_VISIBILITY)
322 ENDIF(CMAKE_COMPILER_IS_GNUCXX)
324 FIND_PACKAGE(ZLIB REQUIRED)
325 MESSAGE("Found zlib headers in ${ZLIB_INCLUDE_DIR}, library at ${ZLIB_LIBRARIES}")
327 FIND_PACKAGE(LIBCRYPTO)
330 SET(PODOFO_HAVE_OPENSSL TRUE)
331 INCLUDE_DIRECTORIES(${LIBCRYPTO_INCLUDE_DIR})
332 MESSAGE("Found OpenSSL's libCrypto headers in ${LIBCRYPTO_INCLUDE_DIR}, library at ${LIBCRYPTO_LIBRARIES}")
333 ELSE(LIBCRYPTO_FOUND)
334 MESSAGE("OpenSSL's libCrypto not found. Encryption support will be disabled")
335 ENDIF(LIBCRYPTO_FOUND)
340 MESSAGE("Found libidn headers in ${LIBIDN_INCLUDE_DIR}, library at ${LIBIDN_LIBRARIES}")
344 SET(PODOFO_HAVE_LIBIDN TRUE)
345 INCLUDE_DIRECTORIES(${LIBIDN_INCLUDE_DIR})
346 MESSAGE("Libidn found. AES-256 Encryption support will be enabled")
348 MESSAGE("Libidn not found. AES-256 Encryption support will be disabled")
351 FIND_PACKAGE(LIBJPEG)
354 MESSAGE("Found libjpeg headers in ${LIBJPEG_INCLUDE_DIR}, library at ${LIBJPEG_LIBRARIES}")
355 SET(PODOFO_HAVE_JPEG_LIB TRUE)
356 INCLUDE_DIRECTORIES(${LIBJPEG_INCLUDE_DIR})
358 MESSAGE("Libjpeg not found. JPEG support will be disabled")
364 MESSAGE("Found libtiff headers in ${TIFF_INCLUDE_DIR}, library at ${TIFF_LIBRARIES}")
365 SET(PODOFO_HAVE_TIFF_LIB TRUE)
366 INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIR})
368 MESSAGE("Libtiff not found. TIFF support will be disabled")
374 MESSAGE("Found LibPng headers in ${PNG_INCLUDE_DIR}, library at ${PNG_LIBRARIES}")
375 SET(PODOFO_HAVE_PNG_LIB TRUE)
376 INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIR})
378 MESSAGE("LibPng not found. PNG support will be disabled")
379 SET(PNG_LIBRARIES "")
382 FIND_PACKAGE(UNISTRING)
385 MESSAGE("Found LibUnistring headers in ${UNISTRING_INCLUDE_DIR}, library at ${UNISTRING_LIBRARY}")
386 SET(PODOFO_HAVE_UNISTRING_LIB TRUE)
387 INCLUDE_DIRECTORIES(${UNISTRING_INCLUDE_DIR})
388 ELSE(UNISTRING_FOUND)
389 MESSAGE("LibUnistring not found. Unistring support will be disabled")
390 SET(UNISTRING_LIBRARY "")
391 ENDIF(UNISTRING_FOUND)
394 IF(NOT PODOFO_BUILD_LIB_ONLY)
396 FIND_PACKAGE(CppUnit)
399 MESSAGE("Found cppunit. Unit tests will be built.")
400 SET(PODOFO_HAVE_CPPUNIT CppUnit_FOUND)
401 INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})
403 MESSAGE("Cppunit not found. No unit tests will be built.")
406 ENDIF(NOT PODOFO_BUILD_LIB_ONLY)
408 FIND_PACKAGE(OpenSSL)
410 FIND_PACKAGE(FREETYPE REQUIRED)
411 MESSAGE("Found freetype library at ${FREETYPE_LIBRARIES}, headers ${FREETYPE_INCLUDE_DIR}")
413 FIND_PACKAGE(LIBSTLPORT)
414 SET(stlport_libraries_if_use_stlport)
417 MESSAGE("Using STLPort")
418 INCLUDE_DIRECTORIES(${LIBSTLPORT_HEADERS})
419 LINK_DIRECTORIES(${LIBSTLPORT_LIB})
420 SET(stlport_libraries_if_use_stlport stlport)
421 # Use the threaded STLPort
422 ADD_DEFINITIONS(-D_PTHREADS)
423 ELSE(LIBSTLPORT_FOUND)
424 MESSAGE(FATAL_ERROR "STLPort use requested, but STLPort not found.")
425 ENDIF(LIBSTLPORT_FOUND)
429 FIND_PACKAGE(FONTCONFIG REQUIRED)
430 SET(PODOFO_HAVE_FONTCONFIG TRUE)
431 SET(PODOFO_LIB_FONTCONFIG:STRING fontconfig)
433 MESSAGE("Found fontconfig headers in ${FONTCONFIG_INCLUDE_DIR}, library at ${FONTCONFIG_LIBRARIES}")
434 ELSE(FONTCONFIG_FOUND)
435 MESSAGE("Could not find fontconfig.")
436 ENDIF(FONTCONFIG_FOUND)
437 ELSE(WANT_FONTCONFIG)
438 # Might as well look for it anyway. This also sets the appropriate
439 # variables to empty values.
440 FIND_PACKAGE(FONTCONFIG)
441 SET(PODOFO_LIB_FONTCONFIG:STRING)
442 ENDIF(WANT_FONTCONFIG)
444 IF(NOT PODOFO_BUILD_LIB_ONLY)
447 # If we have lua, we can build podofoimpose.
448 MESSAGE("Lua found - PoDoFoImpose and PoDoFoColor will be built with Lua support")
449 MESSAGE(" * Lua include directory: ${LUA_INCLUDE_DIR}")
450 MESSAGE(" * Lua libraries: ${LUA_LIBRARIES}")
451 INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR})
452 SET(PODOFO_HAVE_LUA TRUE)
454 MESSAGE("Lua not found - PoDoFoImpose and PoDoFoColor will be built without Lua support")
456 ENDIF(NOT PODOFO_BUILD_LIB_ONLY)
459 # Check if we should build a multithreaded version of PoDoFo
460 IF(DEFINED PODOFO_NO_MULTITHREAD)
461 MESSAGE("Building non multithreaded version of PoDoFo.")
462 SET(PODOFO_MULTI_THREAD FALSE)
463 ELSE(DEFINED PODOFO_NO_MULTITHREAD)
464 MESSAGE("Building multithreaded version of PoDoFo.")
465 SET(PODOFO_MULTI_THREAD TRUE)
466 FIND_PACKAGE(Threads)
467 SET(PLATFORM_SYSTEM_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${PLATFORM_SYSTEM_LIBRARIES})
468 ENDIF(DEFINED PODOFO_NO_MULTITHREAD)
471 MESSAGE("Looking optional for Boost.")
472 MESSAGE("Boost is optional, so don't worry if it is not found.")
473 MESSAGE("Set the BOOST_ROOT env var if you have problems.")
476 SET(PODOFO_HAVE_BOOST TRUE)
477 INCLUDE_DIRECTORIES(${BOOST_INCLUDE_DIR})
479 MESSAGE("If you don't need graph support you can ignore the above error.")
483 INCLUDE_DIRECTORIES(BEFORE # before toolchain include dir (to ignore installed)
484 ${PoDoFo_SOURCE_DIR}/src # order will be reversed, so this is the second dir
485 ${PoDoFo_BINARY_DIR} # because of BEFORE, this is the first include dir
489 ${PoDoFo_SOURCE_DIR}/src/podofo
490 ${FREETYPE_INCLUDE_DIR}
495 ${PoDoFo_BINARY_DIR}/src/podofo
499 # The PoDoFo library needs to be linked to these libraries,
500 # as do any apps or libraries linking to PoDoFo. PODOFO_LIB
501 # will include these and the correct podofo target, so clients
502 # should specify only PODOFO_LIB .
504 # The LIBCRYPTO_LDFLAGS is defined only if the libcrypto was found
505 # by pkg-config, otherwise it will be empty. It can contain proper
506 # path for the libcrypto too, thus it's added here.
508 SET(PODOFO_LIB_DEPENDS
512 ${LIBCRYPTO_LIBRARIES}
515 ${PLATFORM_SYSTEM_LIBRARIES}
516 ${stlport_libraries_if_use_stlport}
517 ${FREETYPE_LIBRARIES}
523 IF(FONTCONFIG_FOUND AND WANT_FONTCONFIG)
524 SET(PODOFO_LIB_DEPENDS ${FONTCONFIG_LIBRARIES} ${PODOFO_LIB_DEPENDS})
525 INCLUDE_DIRECTORIES(${FONTCONFIG_INCLUDE_DIR})
526 ENDIF(FONTCONFIG_FOUND AND WANT_FONTCONFIG)
528 IF(WIN32 OR PODOFO_BUILD_STATIC)
531 ${PODOFO_LIB_DEPENDS}
533 ELSE(WIN32 OR PODOFO_BUILD_STATIC)
534 SET(PODOFO_LIB podofo
535 ${stlport_libraries_if_use_stlport}
537 ENDIF(WIN32 OR PODOFO_BUILD_STATIC)
540 # Setup directories we will need
542 SET(MANDIR "share/man/")
544 # Create the config file. It'll be appended to as the subdirs run though
545 # then dependency information will be written to it at the end of the
548 "${PoDoFo_BINARY_DIR}/PoDoFoConfig.cmake"
549 "# CMake module for PoDoFo\n"
552 "${PoDoFo_BINARY_DIR}/PoDoFoConfig.cmake"
553 "SET(PODOFO_INCLUDES ${PoDoFo_SOURCE_DIR}/src)\n"
556 ADD_SUBDIRECTORY(src/podofo)
557 IF(NOT PODOFO_BUILD_LIB_ONLY)
558 ADD_SUBDIRECTORY(test)
559 ADD_SUBDIRECTORY(tools)
560 ADD_SUBDIRECTORY(examples)
561 ADD_SUBDIRECTORY(man)
562 ENDIF(NOT PODOFO_BUILD_LIB_ONLY)
564 # Generate our configure file
565 CONFIGURE_FILE(${PoDoFo_SOURCE_DIR}/podofo_config.h.in ${PoDoFo_BINARY_DIR}/podofo_config.h)
567 # Export some variables into the config file so it's easier for others
568 # to build and link against PoDoFo
570 # To use these dependencies set PODOFO_DIR to the podofo BUILD directory in
571 # your build (eg -DPODOFO_DIR=/path/to/podofo when running cmake to configure
572 # the app that'll use podofo). See: FIND_PACKAGE(...) in the cmake docs.
573 IF(PODOFO_BUILD_SHARED)
574 EXPORT(TARGETS podofo_shared FILE "${CMAKE_CURRENT_BINARY_DIR}/PoDoFoConfig.cmake")
575 ENDIF(PODOFO_BUILD_SHARED)
576 IF(PODOFO_BUILD_STATIC)
577 EXPORT(TARGETS podofo_static FILE "${CMAKE_CURRENT_BINARY_DIR}/PoDoFoConfig.cmake")
578 ENDIF(PODOFO_BUILD_STATIC)