CMakeLists.txt 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. # CMakeLists.txt
  2. #
  3. # Copyright (C) 2008 Werner Smekal
  4. #
  5. # Process this file with cmake to produce Makefiles or project files
  6. # for your specific compiler tool set
  7. #
  8. # TODO:
  9. # - shared and static library
  10. # - packaging
  11. # - devpackage
  12. # =======================================================================
  13. # libharu project
  14. # =======================================================================
  15. project(libharu C)
  16. # determine compiler name
  17. set(COMPILER_LABEL "unknown")
  18. if(CMAKE_COMPILER_IS_GNUCC)
  19. set(COMPILER_LABEL "gcc")
  20. endif(CMAKE_COMPILER_IS_GNUCC)
  21. if(MSVC)
  22. set(COMPILER_LABEL "vc")
  23. endif(MSVC)
  24. # information about libharu
  25. set(LIBHARU_MAJOR 2)
  26. set(LIBHARU_MINOR 2)
  27. set(LIBHARU_PATCH 0)
  28. set(LIBHARU_VERSION ${LIBHARU_MAJOR}.${LIBHARU_MINOR}.${LIBHARU_PATCH})
  29. set(LIBHARU_DESCRIPTION "libHaru is a free, cross platform, open source library for generating PDF files.")
  30. set(LIBHARU_PACKAGE_NAME "libHaru-${LIBHARU_VERSION}-${COMPILER_LABEL}")
  31. # we want cmake version 2.4.8 at least
  32. cmake_minimum_required(VERSION 2.4.8 FATAL_ERROR)
  33. # Location where the haru cmake build system first looks for cmake modules
  34. set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
  35. # set library name, msvc does not append 'lib' automatically
  36. if(MSVC)
  37. set(LIBHARU_NAME lib)
  38. set(CMAKE_DEBUG_POSTFIX "d")
  39. endif(MSVC)
  40. set(LIBHARU_NAME ${LIBHARU_NAME}hpdf)
  41. set(LIBHARU_NAME_STATIC ${LIBHARU_NAME}s)
  42. # =======================================================================
  43. # command line options
  44. # =======================================================================
  45. option(LIBHARU_SHARED "Build shared lib" YES)
  46. option(LIBHARU_STATIC "Build static lib" YES)
  47. option(LIBHARU_EXAMPLES "Build libharu examples" NO)
  48. option(DEVPAK "Create DevPackage" NO)
  49. if(DEVPAK AND NOT WIN32)
  50. message( STATUS "DevPackage only available for Win32. Set DEVPAK to OFF." )
  51. set(DEVPAK OFF)
  52. endif(DEVPAK AND NOT WIN32)
  53. if(DEVPAK AND LIBHARU_EXAMPLES)
  54. message( STATUS "Examples are not build for DevPackage. Set LIBHARU_EXAMPLES to OFF." )
  55. set(LIBHARU_EXAMPLES OFF)
  56. endif(DEVPAK AND LIBHARU_EXAMPLES)
  57. if(BUILD_SHARED_LIBS)
  58. set(LIBHARU_SHARED ON)
  59. endif(BUILD_SHARED_LIBS)
  60. # =======================================================================
  61. # look for headers and libraries
  62. # =======================================================================
  63. include(haru)
  64. include(summary)
  65. # check zlib availibility
  66. find_package(ZLIB)
  67. if(ZLIB_FOUND)
  68. set(HAVE_LIBZ ON)
  69. include_directories(${ZLIB_INCLUDE_DIR})
  70. set(ADDITIONAL_LIBRARIES ${ZLIB_LIBRARIES})
  71. else(ZLIB_FOUND)
  72. set(HPDF_NOZLIB ON)
  73. endif(ZLIB_FOUND)
  74. # check png availibility
  75. find_package(PNG)
  76. if(PNG_FOUND)
  77. set(HAVE_LIBPNG ON)
  78. include_directories(${PNG_INCLUDE_DIR})
  79. add_definitions(${PNG_DEFINITIONS})
  80. set(ADDITIONAL_LIBRARIES ${ADDITIONAL_LIBRARIES} ${PNG_LIBRARIES})
  81. else(PNG_FOUND)
  82. set(HPDF_NOPNGLIB ON)
  83. endif(PNG_FOUND)
  84. # =======================================================================
  85. # configure header files, add compiler flags
  86. # =======================================================================
  87. # add definitions and directories to include
  88. #if(CMAKE_COMPILER_IS_GNUCC)
  89. # add_definitions("-Wall")
  90. #endif(CMAKE_COMPILER_IS_GNUCC)
  91. if(MSVC_VERSION GREATER 1399)
  92. add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)
  93. endif(MSVC_VERSION GREATER 1399)
  94. include_directories(${CMAKE_SOURCE_DIR}/include)
  95. # create hpdf_config.h
  96. configure_file(
  97. ${CMAKE_SOURCE_DIR}/include/hpdf_config.h.cmake
  98. ${CMAKE_BINARY_DIR}/include/hpdf_config.h
  99. )
  100. include_directories(${CMAKE_BINARY_DIR}/include)
  101. # create DevPackage file
  102. if(DEVPAK)
  103. configure_file(
  104. ${CMAKE_SOURCE_DIR}/libharu.DevPackage.cmake
  105. ${CMAKE_BINARY_DIR}/libharu.DevPackage
  106. )
  107. endif(DEVPAK)
  108. # =======================================================================
  109. # create library and demos
  110. # =======================================================================
  111. add_subdirectory(src)
  112. add_subdirectory(demo)
  113. # =======================================================================
  114. # installation configuration
  115. # =======================================================================
  116. set(
  117. haru_HDRS
  118. include/hpdf.h
  119. include/hpdf_types.h
  120. include/hpdf_consts.h
  121. include/hpdf_version.h
  122. include/hpdf_annotation.h
  123. include/hpdf_catalog.h
  124. include/hpdf_conf.h
  125. include/hpdf_destination.h
  126. include/hpdf_doc.h
  127. include/hpdf_encoder.h
  128. include/hpdf_encrypt.h
  129. include/hpdf_encryptdict.h
  130. include/hpdf_error.h
  131. include/hpdf_ext_gstate.h
  132. include/hpdf_font.h
  133. include/hpdf_fontdef.h
  134. include/hpdf_gstate.h
  135. include/hpdf_image.h
  136. include/hpdf_info.h
  137. include/hpdf_list.h
  138. include/hpdf_mmgr.h
  139. include/hpdf_objects.h
  140. include/hpdf_outline.h
  141. include/hpdf_pages.h
  142. include/hpdf_page_label.h
  143. include/hpdf_streams.h
  144. include/hpdf_u3d.h
  145. include/hpdf_utils.h
  146. include/hpdf_pdfa.h
  147. include/hpdf_3dmeasure.h
  148. include/hpdf_exdata.h
  149. ${CMAKE_BINARY_DIR}/include/hpdf_config.h
  150. )
  151. # install header files
  152. install(FILES ${haru_HDRS} DESTINATION include)
  153. # install various files
  154. install(FILES README CHANGES INSTALL DESTINATION .)
  155. install(DIRECTORY doc DESTINATION .)
  156. if(NOT DEVPAK)
  157. install(DIRECTORY if DESTINATION .)
  158. endif(NOT DEVPAK)
  159. if(DEVPAK)
  160. install(FILES ${CMAKE_BINARY_DIR}/libharu.DevPackage DESTINATION .)
  161. endif(DEVPAK)
  162. # =======================================================================
  163. # print out some information
  164. # =======================================================================
  165. summary()
  166. # =======================================================================
  167. # packing stuff
  168. # =======================================================================
  169. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${LIBHARU_DESCRIPTION})
  170. set(CPACK_PACKAGE_VENDOR "Werner Smekal")
  171. set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README)
  172. set(CPACK_PACKAGE_VERSION_MAJOR "${LIBHARU_MAJOR}")
  173. set(CPACK_PACKAGE_VERSION_MINOR "${LIBHARU_MINOR}")
  174. set(CPACK_PACKAGE_VERSION_PATCH "${LIBHARU_PATCH}")
  175. set(CPACK_PACKAGE_FILE_NAME "libHaru-${LIBHARU_VERSION}-${COMPILER_LABEL}")
  176. set(CPACK_STRIP_FILES ON)
  177. if(WIN32)
  178. set(CPACK_GENERATOR ZIP)
  179. else(WIN32)
  180. set(CPACK_GENERATOR TGZ)
  181. endif(WIN32)
  182. INCLUDE( CPack )