/CMakeLists.txt

https://github.com/yencarnacion/pdf2htmlEX · CMake · 198 lines · 166 code · 22 blank · 10 comment · 16 complexity · 3c1a372f61292b57a9e9732a969fef9a MD5 · raw file

  1. # leave this above project(pdf2htmlEX)
  2. # set default build type to Release
  3. set(CMAKE_BUILD_TYPE Release CACHE STRING "Build configuration (Debug, Release, RelWithDebInfo, MinSizeRel)")
  4. project(pdf2htmlEX)
  5. cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)
  6. include_directories(${CMAKE_SOURCE_DIR}/src)
  7. set(PDF2HTMLEX_VERSION "0.6")
  8. set(ARCHIVE_NAME pdf2htmlex-${PDF2HTMLEX_VERSION})
  9. add_custom_target(dist
  10. COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
  11. | bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
  12. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
  13. find_package(PkgConfig)
  14. pkg_check_modules(POPPLER REQUIRED poppler>=0.20.0)
  15. include_directories(${POPPLER_INCLUDE_DIRS})
  16. link_directories(${POPPLER_LIBRARY_DIRS})
  17. set(PDF2HTMLEX_LIBS ${PDF2HTMLEX_LIBS} ${POPPLER_LIBRARIES})
  18. # disable CAIRO for now
  19. if(0)
  20. pkg_check_modules(POPPLER_CAIRO poppler-cairo>=0.20.0)
  21. if(POPPLER_CAIRO_FOUND)
  22. set(HAVE_CAIRO 1)
  23. include_directories(${POPPLER_CAIRO_INCLUDE_DIRS})
  24. link_directories(${POPPLER_CAIRO_LIBRARY_DIRS})
  25. set(PDF2HTMLEX_LIBS ${PDF2HTMLEX_LIBS} ${POPPLER_CAIRO_LIBRARIES})
  26. else()
  27. set(HAVE_CAIRO 0)
  28. endif()
  29. else()
  30. set(HAVE_CAIRO 0)
  31. endif()
  32. # fontforge starts using pkg-config 'correctly' since 2.0.0
  33. pkg_check_modules(FONTFORGE libfontforge>=2.0.0)
  34. if(FONTFORGE_FOUND)
  35. include_directories(${FONTFORGE_INCLUDE_DIRS})
  36. link_directories(${FONTFORGE_LIBRARY_DIRS})
  37. set(PDF2HTMLEX_LIBS ${PDF2HTMLEX_LIBS} ${FONTFORGE_LIBRARIES})
  38. else()
  39. message("Trying to locate fontforge...")
  40. find_path(FF_INCLUDE_PATH fontforge/fontforge.h)
  41. if(FF_INCLUDE_PATH)
  42. message("Found fontforge.h: ${FF_INCLUDE_PATH}/fontforge/fontforge.h")
  43. set(FONTFORGE_INCLUDE_DIRS ${FF_INCLUDE_PATH}/fontforge)
  44. include_directories(${FONTFORGE_INCLUDE_DIRS})
  45. # MacOSX gettext is in /opt/local/include - strange
  46. if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  47. find_path(GETTEXT_INCLUDE_PATH libintl.h)
  48. if(GETTEXT_INCLUDE_PATH)
  49. include_directories(${GETTEXT_INCLUDE_PATH})
  50. else()
  51. message("Cannot found libintl.h, if you see errors about libintl.h, add the path to gettext header files into your include paths")
  52. endif()
  53. endif()
  54. else()
  55. message(FATAL_ERROR "Error: cannot locate fontforge.h")
  56. endif()
  57. macro(wl_find_library LIB_NAME RESULT)
  58. unset(${RESULT})
  59. unset(${RESULT} CACHE)
  60. foreach(FULL_LIB_NAME
  61. ${CMAKE_IMPORT_LIBRARY_PREFIX}${LIB_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX}
  62. ${CMAKE_SHARED_LIBRARY_PREFIX}${LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
  63. ${CMAKE_STATIC_LIBRARY_PREFIX}${LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}
  64. )
  65. find_library(FULL_LIB ${FULL_LIB_NAME})
  66. if(FULL_LIB)
  67. message("Found ${LIB_NAME}: ${FULL_LIB}")
  68. set(${RESULT} ${FULL_LIB})
  69. break()
  70. endif()
  71. endforeach()
  72. unset(FULL_LIB_NAME)
  73. unset(FULL_LIB_NAME CACHE)
  74. unset(FULL_LIB)
  75. unset(FULL_LIB CACHE)
  76. endmacro()
  77. wl_find_library(fontforge FONTFORGE_LIBRARIES)
  78. if(NOT DEFINED FONTFORGE_LIBRARIES)
  79. set(FONTFORGE_LIBRARIES fontforge)
  80. message("Error: cannot locate fontforge")
  81. endif()
  82. set(PDF2HTMLEX_LIBS ${PDF2HTMLEX_LIBS} ${FONTFORGE_LIBRARIES})
  83. wl_find_library(gunicode GUNICODE_LIBRARIES)
  84. set(PDF2HTMLEX_LIBS ${PDF2HTMLEX_LIBS} ${GUNICODE_LIBRARIES})
  85. message("Looking for libraries of python, which is required by fontforge, if you can link fontforge without python, you may disable this")
  86. pkg_search_module(PYTHON python python-2.7)
  87. set(PDF2HTMLEX_LIBS ${PDF2HTMLEX_LIBS} ${PYTHON_LIBRARIES})
  88. endif()
  89. find_path(FF_CONFIG_INCLUDE_PATH config.h PATHS
  90. ${FONTFORGE_INCLUDE_DIRS} NO_DEFAULT_PATH)
  91. if(FF_CONFIG_INCLUDE_PATH)
  92. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -include ${FF_CONFIG_INCLUDE_PATH}/config.h")
  93. message("Found config.h: ${FF_CONFIG_INCLUDE_PATH}/config.h")
  94. else()
  95. message("Cannot locate config.h for fontforge")
  96. endif()
  97. # debug build flags (overwrite default cmake debug flags)
  98. set(CMAKE_C_FLAGS_DEBUG "-ggdb")
  99. set(CMAKE_CXX_FLAGS_DEBUG "-ggdb")
  100. # release build flags (overwrite default cmake release flags)
  101. set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
  102. set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
  103. # generic flags
  104. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
  105. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
  106. # clang compiler need c++11 flag
  107. if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  108. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
  109. endif()
  110. # CYGWIN or GCC 4.5.x bug
  111. if(CYGWIN)
  112. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=gnu++0x")
  113. else()
  114. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++0x")
  115. endif()
  116. include(CheckCXXCompilerFlag)
  117. check_cxx_compiler_flag("${CMAKE_CXX_FLAGS}" CXX0X_SUPPORT)
  118. if(NOT CXX0X_SUPPORT)
  119. message(FATAL_ERROR "Error: you compiler does not support C++0x, please update it.")
  120. endif()
  121. configure_file (${CMAKE_SOURCE_DIR}/src/pdf2htmlEX-config.h.in ${CMAKE_SOURCE_DIR}/src/pdf2htmlEX-config.h)
  122. configure_file (${CMAKE_SOURCE_DIR}/pdf2htmlEX.1.in ${CMAKE_SOURCE_DIR}/pdf2htmlEX.1)
  123. add_executable(pdf2htmlEX
  124. src/Param.h
  125. src/pdf2htmlEX-config.h
  126. src/pdf2htmlEX.cc
  127. src/HTMLRenderer/HTMLRenderer.h
  128. src/HTMLRenderer/draw.cc
  129. src/HTMLRenderer/export.cc
  130. src/HTMLRenderer/general.cc
  131. src/HTMLRenderer/image.cc
  132. src/HTMLRenderer/install.cc
  133. src/HTMLRenderer/TextLineBuffer.h
  134. src/HTMLRenderer/TextLineBuffer.cc
  135. src/HTMLRenderer/link.cc
  136. src/HTMLRenderer/state.cc
  137. src/HTMLRenderer/text.cc
  138. src/BackgroundRenderer/BackgroundRenderer.h
  139. src/BackgroundRenderer/SplashBackgroundRenderer.h
  140. src/BackgroundRenderer/SplashBackgroundRenderer.cc
  141. src/BackgroundRenderer/CairoBackgroundRenderer.h
  142. src/BackgroundRenderer/CairoBackgroundRenderer.cc
  143. src/util/ArgParser.h
  144. src/util/ArgParser.cc
  145. src/util/base64stream.h
  146. src/util/base64stream.cc
  147. src/util/const.h
  148. src/util/const.cc
  149. src/util/ffw.h
  150. src/util/ffw.c
  151. src/util/math.h
  152. src/util/math.cc
  153. src/util/misc.h
  154. src/util/misc.cc
  155. src/util/namespace.h
  156. src/util/path.h
  157. src/util/path.cc
  158. src/util/Preprocessor.h
  159. src/util/Preprocessor.cc
  160. src/util/StringFormatter.h
  161. src/util/StringFormatter.cc
  162. src/util/TmpFiles.h
  163. src/util/TmpFiles.cc
  164. src/util/unicode.h
  165. src/util/unicode.cc
  166. )
  167. target_link_libraries(pdf2htmlEX ${PDF2HTMLEX_LIBS})
  168. install (TARGETS pdf2htmlEX DESTINATION bin)
  169. file (GLOB datafiles
  170. share/base.css
  171. share/jquery.js
  172. share/pdf2htmlEX.js
  173. share/manifest
  174. )
  175. install (FILES ${datafiles} DESTINATION share/pdf2htmlEX)
  176. install (FILES pdf2htmlEX.1 DESTINATION share/man/man1)