[32234] | 1 | #========================================================================
|
---|
| 2 | #
|
---|
| 3 | # xpdf/cmake-xpdf.txt
|
---|
| 4 | #
|
---|
| 5 | # CMake script for the Xpdf tools.
|
---|
| 6 | #
|
---|
| 7 | # Copyright 2015 Glyph & Cog, LLC
|
---|
| 8 | #
|
---|
| 9 | #========================================================================
|
---|
| 10 |
|
---|
| 11 | #========================================================================
|
---|
| 12 | # This is a customised version of Xpdf Tools' CMake file.
|
---|
| 13 | # Customised for Greenstone.
|
---|
| 14 | #========================================================================
|
---|
| 15 |
|
---|
| 16 | include_directories("${PROJECT_SOURCE_DIR}")
|
---|
| 17 | include_directories("${PROJECT_BINARY_DIR}")
|
---|
| 18 | include_directories("${PROJECT_SOURCE_DIR}/goo")
|
---|
| 19 | include_directories("${PROJECT_SOURCE_DIR}/fofi")
|
---|
| 20 | include_directories("${PROJECT_SOURCE_DIR}/splash")
|
---|
| 21 | if (PNG_FOUND)
|
---|
| 22 | include_directories("${PNG_INCLUDE_DIRS}")
|
---|
| 23 | add_definitions("${PNG_DEFINITIONS}")
|
---|
| 24 | else ()
|
---|
| 25 | message(STATUS "@@@@@@@@@@@@@@@ NO PNG_FOUND")
|
---|
| 26 | endif ()
|
---|
| 27 | # https://stackoverflow.com/questions/36126333/mingw-cmake-undefined-reference-to-zlib
|
---|
| 28 | if (ZLIB_FOUND)
|
---|
| 29 | include_directories("${ZLIB_INCLUDE_DIRS}")
|
---|
| 30 | add_definitions("${ZLIB_DEFINITIONS}")
|
---|
| 31 | else ()
|
---|
| 32 | message(STATUS "@@@@@@@@@@@@@@@ NO ZLIB_FOUND")
|
---|
| 33 | endif ()
|
---|
| 34 | if (HAVE_LCMS)
|
---|
| 35 | include_directories("${LCMS_INCLUDE_DIR}")
|
---|
| 36 | set(COLOR_MANAGER_SOURCE "ColorManager.cc")
|
---|
| 37 | else ()
|
---|
| 38 | set(COLOR_MANAGER_SOURCE "")
|
---|
| 39 | endif ()
|
---|
| 40 |
|
---|
| 41 | add_library(xpdf_objs OBJECT
|
---|
| 42 | AcroForm.cc
|
---|
| 43 | Annot.cc
|
---|
| 44 | Array.cc
|
---|
| 45 | BuiltinFont.cc
|
---|
| 46 | BuiltinFontTables.cc
|
---|
| 47 | Catalog.cc
|
---|
| 48 | CharCodeToUnicode.cc
|
---|
| 49 | CMap.cc
|
---|
| 50 | ${COLOR_MANAGER_SOURCE}
|
---|
| 51 | Decrypt.cc
|
---|
| 52 | Dict.cc
|
---|
| 53 | Error.cc
|
---|
| 54 | FontEncodingTables.cc
|
---|
| 55 | Form.cc
|
---|
| 56 | Function.cc
|
---|
| 57 | Gfx.cc
|
---|
| 58 | GfxFont.cc
|
---|
| 59 | GfxState.cc
|
---|
| 60 | GlobalParams.cc
|
---|
| 61 | JArithmeticDecoder.cc
|
---|
| 62 | JBIG2Stream.cc
|
---|
| 63 | JPXStream.cc
|
---|
| 64 | Lexer.cc
|
---|
| 65 | Link.cc
|
---|
| 66 | NameToCharCode.cc
|
---|
| 67 | Object.cc
|
---|
| 68 | OptionalContent.cc
|
---|
| 69 | Outline.cc
|
---|
| 70 | OutputDev.cc
|
---|
| 71 | Page.cc
|
---|
| 72 | Parser.cc
|
---|
| 73 | PDFDoc.cc
|
---|
| 74 | PDFDocEncoding.cc
|
---|
| 75 | PSTokenizer.cc
|
---|
| 76 | SecurityHandler.cc
|
---|
| 77 | Stream.cc
|
---|
| 78 | TextString.cc
|
---|
| 79 | UnicodeMap.cc
|
---|
| 80 | UnicodeTypeTable.cc
|
---|
| 81 | UTF8.cc
|
---|
| 82 | XFAForm.cc
|
---|
| 83 | XRef.cc
|
---|
| 84 | Zoox.cc
|
---|
| 85 | )
|
---|
| 86 |
|
---|
| 87 | #--- object files needed by XpdfWidget
|
---|
| 88 |
|
---|
| 89 | if ((QT4_FOUND OR Qt5Widgets_FOUND)
|
---|
| 90 | AND HAVE_SPLASH AND MULTITHREADED AND USE_EXCEPTIONS)
|
---|
| 91 |
|
---|
| 92 | if (HIGHLIGHTED_REGIONS)
|
---|
| 93 | set(HIGHLIGHT_SRC "HighlightFile.cc")
|
---|
| 94 | else ()
|
---|
| 95 | set(HIGHLIGHT_SRC "")
|
---|
| 96 | endif ()
|
---|
| 97 |
|
---|
| 98 | add_library(xpdf_widget_objs OBJECT
|
---|
| 99 | DisplayState.cc
|
---|
| 100 | PDFCore.cc
|
---|
| 101 | PreScanOutputDev.cc
|
---|
| 102 | PSOutputDev.cc
|
---|
| 103 | SplashOutputDev.cc
|
---|
| 104 | TextOutputDev.cc
|
---|
| 105 | TileCache.cc
|
---|
| 106 | TileCompositor.cc
|
---|
| 107 | TileMap.cc
|
---|
| 108 | ${HIGHLIGHT_SRC}
|
---|
| 109 | )
|
---|
| 110 | endif ()
|
---|
| 111 |
|
---|
| 112 | # We want to build static xpdf-tools binaries. See
|
---|
| 113 | # https://stackoverflow.com/questions/24648357/compiling-a-static-executable-with-cmake
|
---|
| 114 | # Want to make the min number of changes for building statically, so using the way
|
---|
| 115 | # below. Beware, must *append* "-static" to existing CMAKE_EXE_LINKER_FLAGS=LD_FLAGS
|
---|
| 116 | SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
---|
| 117 | SET(BUILD_SHARED_LIBS OFF)
|
---|
| 118 | SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
---|
| 119 |
|
---|
| 120 | # The original, unmodified CMakeLists.txt was not set up sufficiently
|
---|
| 121 | # for static compilation of xpdf-tools. As a result, compile would first fail
|
---|
| 122 | # with errors about undefined refs to mutex / lpthread.
|
---|
| 123 | # When building xpdf-tools statically, need to add the following 2 lines as well
|
---|
| 124 | # as append "Threads::Threads" to the end of each "target_link_libraries(<list>)"
|
---|
| 125 | # See https://stackoverflow.com/questions/1620918/cmake-and-libpthread
|
---|
| 126 | # found googling cmake and "-lpthread" (pthread) after ERRORS to do with this, like:
|
---|
| 127 | # undefined reference to `pthread_mutex_unlock'
|
---|
| 128 | set(THREADS_PREFER_PTHREAD_FLAG ON)
|
---|
| 129 | find_package(Threads REQUIRED)
|
---|
| 130 |
|
---|
| 131 | #--- pdftops
|
---|
| 132 |
|
---|
| 133 | if (HAVE_SPLASH)
|
---|
| 134 | add_executable(pdftops
|
---|
| 135 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 136 | PreScanOutputDev.cc
|
---|
| 137 | PSOutputDev.cc
|
---|
| 138 | SplashOutputDev.cc
|
---|
| 139 | pdftops.cc
|
---|
| 140 | )
|
---|
| 141 | target_link_libraries(pdftops goo fofi splash
|
---|
| 142 | ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
|
---|
| 143 | ${ZLIB_LIBRARIES}
|
---|
| 144 | ${DTYPE_LIBRARY}
|
---|
| 145 | ${LCMS_LIBRARY}
|
---|
| 146 | Threads::Threads)
|
---|
| 147 | else ()
|
---|
| 148 | add_executable(pdftops
|
---|
| 149 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 150 | PreScanOutputDev.cc
|
---|
| 151 | PSOutputDev.cc
|
---|
| 152 | pdftops.cc
|
---|
| 153 | )
|
---|
| 154 | target_link_libraries(pdftops goo fofi ${LCMS_LIBRARY} Threads::Threads)
|
---|
| 155 | endif ()
|
---|
| 156 | install(TARGETS pdftops RUNTIME DESTINATION bin)
|
---|
| 157 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftops.1 DESTINATION man/man1)
|
---|
| 158 |
|
---|
| 159 | #--- pdftotext
|
---|
| 160 |
|
---|
| 161 | add_executable(pdftotext
|
---|
| 162 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 163 | TextOutputDev.cc
|
---|
| 164 | pdftotext.cc
|
---|
| 165 | )
|
---|
| 166 | target_link_libraries(pdftotext goo fofi ${LCMS_LIBRARY} Threads::Threads)
|
---|
| 167 | install(TARGETS pdftotext RUNTIME DESTINATION bin)
|
---|
| 168 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftotext.1 DESTINATION man/man1)
|
---|
| 169 |
|
---|
| 170 | #--- pdftohtml
|
---|
| 171 |
|
---|
| 172 | if (HAVE_SPLASH AND PNG_FOUND)
|
---|
| 173 | add_executable(pdftohtml
|
---|
| 174 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 175 | HTMLGen.cc
|
---|
| 176 | SplashOutputDev.cc
|
---|
| 177 | TextOutputDev.cc
|
---|
| 178 | pdftohtml.cc
|
---|
| 179 | )
|
---|
| 180 | target_link_libraries(pdftohtml goo fofi splash
|
---|
| 181 | ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
|
---|
| 182 | ${DTYPE_LIBRARY}
|
---|
| 183 | ${LCMS_LIBRARY} ${PNG_LIBRARIES}
|
---|
| 184 | Threads::Threads)
|
---|
| 185 | install(TARGETS pdftohtml RUNTIME DESTINATION bin)
|
---|
| 186 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftohtml.1 DESTINATION man/man1)
|
---|
| 187 | endif ()
|
---|
| 188 |
|
---|
| 189 | #--- pdfinfo
|
---|
| 190 |
|
---|
| 191 | add_executable(pdfinfo
|
---|
| 192 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 193 | pdfinfo.cc
|
---|
| 194 | )
|
---|
| 195 | target_link_libraries(pdfinfo goo fofi ${LCMS_LIBRARY} Threads::Threads)
|
---|
| 196 | install(TARGETS pdfinfo RUNTIME DESTINATION bin)
|
---|
| 197 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfinfo.1 DESTINATION man/man1)
|
---|
| 198 |
|
---|
| 199 | #--- pdffonts
|
---|
| 200 |
|
---|
| 201 | add_executable(pdffonts
|
---|
| 202 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 203 | pdffonts.cc
|
---|
| 204 | )
|
---|
| 205 | target_link_libraries(pdffonts goo fofi ${LCMS_LIBRARY} Threads::Threads)
|
---|
| 206 | install(TARGETS pdffonts RUNTIME DESTINATION bin)
|
---|
| 207 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdffonts.1 DESTINATION man/man1)
|
---|
| 208 |
|
---|
| 209 | #--- pdfdetach
|
---|
| 210 |
|
---|
| 211 | add_executable(pdfdetach
|
---|
| 212 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 213 | pdfdetach.cc
|
---|
| 214 | )
|
---|
| 215 | target_link_libraries(pdfdetach goo fofi ${LCMS_LIBRARY} Threads::Threads)
|
---|
| 216 | install(TARGETS pdfdetach RUNTIME DESTINATION bin)
|
---|
| 217 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfdetach.1 DESTINATION man/man1)
|
---|
| 218 |
|
---|
| 219 | #--- pdftoppm
|
---|
| 220 |
|
---|
| 221 | if (HAVE_SPLASH)
|
---|
| 222 | add_executable(pdftoppm
|
---|
| 223 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 224 | SplashOutputDev.cc
|
---|
| 225 | pdftoppm.cc
|
---|
| 226 | )
|
---|
| 227 | target_link_libraries(pdftoppm goo fofi splash
|
---|
| 228 | ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
|
---|
| 229 | ${ZLIB_LIBRARIES}
|
---|
| 230 | ${DTYPE_LIBRARY}
|
---|
| 231 | ${LCMS_LIBRARY}
|
---|
| 232 | Threads::Threads)
|
---|
| 233 | install(TARGETS pdftoppm RUNTIME DESTINATION bin)
|
---|
| 234 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftoppm.1 DESTINATION man/man1)
|
---|
| 235 | endif ()
|
---|
| 236 |
|
---|
| 237 | #--- pdftopng
|
---|
| 238 |
|
---|
| 239 | if (HAVE_SPLASH AND PNG_FOUND)
|
---|
| 240 | add_executable(pdftopng
|
---|
| 241 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 242 | SplashOutputDev.cc
|
---|
| 243 | pdftopng.cc
|
---|
| 244 | )
|
---|
| 245 | target_link_libraries(pdftopng goo fofi splash
|
---|
| 246 | ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
|
---|
| 247 | ${DTYPE_LIBRARY}
|
---|
| 248 | ${LCMS_LIBRARY} ${PNG_LIBRARIES}
|
---|
| 249 | Threads::Threads)
|
---|
| 250 | install(TARGETS pdftopng RUNTIME DESTINATION bin)
|
---|
| 251 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftopng.1 DESTINATION man/man1)
|
---|
| 252 | endif ()
|
---|
| 253 |
|
---|
| 254 | #--- pdfimages
|
---|
| 255 |
|
---|
| 256 | add_executable(pdfimages
|
---|
| 257 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 258 | ImageOutputDev.cc
|
---|
| 259 | pdfimages.cc
|
---|
| 260 | )
|
---|
| 261 | target_link_libraries(pdfimages goo fofi ${LCMS_LIBRARY} Threads::Threads)
|
---|
| 262 | install(TARGETS pdfimages RUNTIME DESTINATION bin)
|
---|
| 263 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfimages.1 DESTINATION man/man1)
|
---|
| 264 |
|
---|
| 265 | #--- xpdfrc man page
|
---|
| 266 |
|
---|
| 267 | install(FILES ${PROJECT_SOURCE_DIR}/doc/xpdfrc.5 DESTINATION man/man5)
|
---|