[32236] | 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 | message(STATUS "@@@@@@@@@@@@@@@ lib: ${PNG_LIBRARY}")
|
---|
| 23 | message(STATUS "@@@@@@@@@@@@@@@ libs: ${PNG_LIBRARIES}")
|
---|
| 24 | message(STATUS "@@@@@@@@@@@@@@@ freetype: ${FREETYPE_LIBRARY} - ${FREETYPE_OTHER_LIBS}")
|
---|
| 25 | include_directories("${PNG_INCLUDE_DIRS}")
|
---|
| 26 | add_definitions("${PNG_DEFINITIONS}")
|
---|
| 27 | else ()
|
---|
| 28 | message(STATUS "@@@@@@@@@@@@@@@ NO PNG_FOUND")
|
---|
| 29 | endif ()
|
---|
| 30 | # https://stackoverflow.com/questions/36126333/mingw-cmake-undefined-reference-to-zlib
|
---|
| 31 | if (ZLIB_FOUND)
|
---|
| 32 | message(STATUS "@@@@@@@@@@@@@@@ lib: ${ZLIB_LIBRARY} - ${ZLIB_LIBRARIES}")
|
---|
| 33 | include_directories("${ZLIB_INCLUDE_DIRS}")
|
---|
| 34 | add_definitions("${ZLIB_DEFINITIONS}")
|
---|
| 35 | else ()
|
---|
| 36 | message(STATUS "@@@@@@@@@@@@@@@ NO ZLIB_FOUND")
|
---|
| 37 | endif ()
|
---|
| 38 | if (HAVE_LCMS)
|
---|
| 39 | include_directories("${LCMS_INCLUDE_DIR}")
|
---|
| 40 | set(COLOR_MANAGER_SOURCE "ColorManager.cc")
|
---|
| 41 | set(PDFTO_PS_PPM_LINK_FLAGS -static -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -lz -lm -lc -lpthread)
|
---|
| 42 | set(PDFTO_HTML_PNG_LINK_FLAGS -static -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -lpng -lz -lm -lc -lpthread)
|
---|
| 43 | else ()
|
---|
| 44 | set(COLOR_MANAGER_SOURCE "")
|
---|
| 45 | set(PDFTO_PS_PPM_LINK_FLAGS -static -lfreetype ${DTYPE_LIBRARY} -lz -lm -lc -lpthread)
|
---|
| 46 | set(PDFTO_HTML_PNG_LINK_FLAGS -static -lfreetype ${DTYPE_LIBRARY} -lpng -lz -lm -lc -lpthread)
|
---|
| 47 | endif ()
|
---|
| 48 |
|
---|
| 49 | add_library(xpdf_objs OBJECT
|
---|
| 50 | AcroForm.cc
|
---|
| 51 | Annot.cc
|
---|
| 52 | Array.cc
|
---|
| 53 | BuiltinFont.cc
|
---|
| 54 | BuiltinFontTables.cc
|
---|
| 55 | Catalog.cc
|
---|
| 56 | CharCodeToUnicode.cc
|
---|
| 57 | CMap.cc
|
---|
| 58 | ${COLOR_MANAGER_SOURCE}
|
---|
| 59 | Decrypt.cc
|
---|
| 60 | Dict.cc
|
---|
| 61 | Error.cc
|
---|
| 62 | FontEncodingTables.cc
|
---|
| 63 | Form.cc
|
---|
| 64 | Function.cc
|
---|
| 65 | Gfx.cc
|
---|
| 66 | GfxFont.cc
|
---|
| 67 | GfxState.cc
|
---|
| 68 | GlobalParams.cc
|
---|
| 69 | JArithmeticDecoder.cc
|
---|
| 70 | JBIG2Stream.cc
|
---|
| 71 | JPXStream.cc
|
---|
| 72 | Lexer.cc
|
---|
| 73 | Link.cc
|
---|
| 74 | NameToCharCode.cc
|
---|
| 75 | Object.cc
|
---|
| 76 | OptionalContent.cc
|
---|
| 77 | Outline.cc
|
---|
| 78 | OutputDev.cc
|
---|
| 79 | Page.cc
|
---|
| 80 | Parser.cc
|
---|
| 81 | PDFDoc.cc
|
---|
| 82 | PDFDocEncoding.cc
|
---|
| 83 | PSTokenizer.cc
|
---|
| 84 | SecurityHandler.cc
|
---|
| 85 | Stream.cc
|
---|
| 86 | TextString.cc
|
---|
| 87 | UnicodeMap.cc
|
---|
| 88 | UnicodeTypeTable.cc
|
---|
| 89 | UTF8.cc
|
---|
| 90 | XFAForm.cc
|
---|
| 91 | XRef.cc
|
---|
| 92 | Zoox.cc
|
---|
| 93 | )
|
---|
| 94 |
|
---|
| 95 | #--- object files needed by XpdfWidget
|
---|
| 96 |
|
---|
| 97 | if ((QT4_FOUND OR Qt5Widgets_FOUND)
|
---|
| 98 | AND HAVE_SPLASH AND MULTITHREADED AND USE_EXCEPTIONS)
|
---|
| 99 |
|
---|
| 100 | if (HIGHLIGHTED_REGIONS)
|
---|
| 101 | set(HIGHLIGHT_SRC "HighlightFile.cc")
|
---|
| 102 | else ()
|
---|
| 103 | set(HIGHLIGHT_SRC "")
|
---|
| 104 | endif ()
|
---|
| 105 |
|
---|
| 106 | add_library(xpdf_widget_objs OBJECT
|
---|
| 107 | DisplayState.cc
|
---|
| 108 | PDFCore.cc
|
---|
| 109 | PreScanOutputDev.cc
|
---|
| 110 | PSOutputDev.cc
|
---|
| 111 | SplashOutputDev.cc
|
---|
| 112 | TextOutputDev.cc
|
---|
| 113 | TileCache.cc
|
---|
| 114 | TileCompositor.cc
|
---|
| 115 | TileMap.cc
|
---|
| 116 | ${HIGHLIGHT_SRC}
|
---|
| 117 | )
|
---|
| 118 | endif ()
|
---|
| 119 |
|
---|
| 120 | # We want to build static xpdf-tools binaries. See
|
---|
| 121 | # https://stackoverflow.com/questions/24648357/compiling-a-static-executable-with-cmake
|
---|
| 122 | # Want to make the min number of changes for building statically, so using the way
|
---|
| 123 | # below. Beware, must *append* "-static" to existing CMAKE_EXE_LINKER_FLAGS=LD_FLAGS
|
---|
| 124 | SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
---|
| 125 | SET(BUILD_SHARED_LIBS OFF)
|
---|
| 126 | SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
---|
| 127 |
|
---|
| 128 | # The original, unmodified CMakeLists.txt was not set up sufficiently
|
---|
| 129 | # for static compilation of xpdf-tools. As a result, compile would first fail
|
---|
| 130 | # with errors about undefined refs to mutex / lpthread.
|
---|
| 131 | # When building xpdf-tools statically, need to add the following 2 lines as well
|
---|
| 132 | # as append "Threads::Threads" to the end of each "target_link_libraries(<list>)"
|
---|
| 133 | # See https://stackoverflow.com/questions/1620918/cmake-and-libpthread
|
---|
| 134 | # found googling cmake and "-lpthread" (pthread) after ERRORS to do with this, like:
|
---|
| 135 | # undefined reference to `pthread_mutex_unlock'
|
---|
| 136 | set(THREADS_PREFER_PTHREAD_FLAG ON)
|
---|
| 137 | find_package(Threads REQUIRED)
|
---|
| 138 |
|
---|
| 139 | #--- pdftops
|
---|
| 140 |
|
---|
| 141 | if (HAVE_SPLASH)
|
---|
| 142 | add_executable(pdftops
|
---|
| 143 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 144 | PreScanOutputDev.cc
|
---|
| 145 | PSOutputDev.cc
|
---|
| 146 | SplashOutputDev.cc
|
---|
| 147 | pdftops.cc
|
---|
| 148 | )
|
---|
| 149 | target_link_libraries(pdftops goo fofi splash ${PDFTO_PS_PPM_LINK_FLAGS})
|
---|
| 150 | # -static -lfreetype -lpng -lz -lm -lc -lpthread)
|
---|
| 151 | # ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
|
---|
| 152 | # ${ZLIB_LIBRARIES}
|
---|
| 153 | # ${DTYPE_LIBRARY}
|
---|
| 154 | # ${LCMS_LIBRARY}
|
---|
| 155 | # Threads::Threads)
|
---|
| 156 | else ()
|
---|
| 157 | add_executable(pdftops
|
---|
| 158 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 159 | PreScanOutputDev.cc
|
---|
| 160 | PSOutputDev.cc
|
---|
| 161 | pdftops.cc
|
---|
| 162 | )
|
---|
| 163 | target_link_libraries(pdftops goo fofi ${LCMS_LIBRARY} Threads::Threads)
|
---|
| 164 | endif ()
|
---|
| 165 | install(TARGETS pdftops RUNTIME DESTINATION bin)
|
---|
| 166 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftops.1 DESTINATION man/man1)
|
---|
| 167 |
|
---|
| 168 | #--- pdftotext
|
---|
| 169 |
|
---|
| 170 | add_executable(pdftotext
|
---|
| 171 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 172 | TextOutputDev.cc
|
---|
| 173 | pdftotext.cc
|
---|
| 174 | )
|
---|
| 175 | target_link_libraries(pdftotext goo fofi ${LCMS_LIBRARY} Threads::Threads)
|
---|
| 176 | install(TARGETS pdftotext RUNTIME DESTINATION bin)
|
---|
| 177 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftotext.1 DESTINATION man/man1)
|
---|
| 178 |
|
---|
| 179 | #--- pdftohtml
|
---|
| 180 |
|
---|
| 181 | if (HAVE_SPLASH AND PNG_FOUND)
|
---|
| 182 | add_executable(pdftohtml
|
---|
| 183 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 184 | HTMLGen.cc
|
---|
| 185 | SplashOutputDev.cc
|
---|
| 186 | TextOutputDev.cc
|
---|
| 187 | pdftohtml.cc
|
---|
| 188 | )
|
---|
| 189 | target_link_libraries(pdftohtml goo fofi splash ${PDFTO_HTML_PNG_LINK_FLAGS})
|
---|
| 190 | # -static -lfreetype -lpng -lz -lm -lc -lpthread)
|
---|
| 191 | # ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
|
---|
| 192 | # ${DTYPE_LIBRARY}
|
---|
| 193 | # ${LCMS_LIBRARY} ${PNG_LIBRARIES}
|
---|
| 194 | # Threads::Threads)
|
---|
| 195 | # Doing the above builds with
|
---|
| 196 | # "-Wl,-Bstatic -lfreetype -lpng15 -lz -Wl,-Bdynamic -lpthread" at end
|
---|
| 197 | # and produces broken binaries for pdftohtml/pdftoppm/pdftops/pdftopng.
|
---|
| 198 | # Note that PNG_LIBRARIES includes zlib/lz: "-lpng -lz", and with freetype, is
|
---|
| 199 | # linked statically. However, Threads/lpthread is included as a dynamically
|
---|
| 200 | # linked library instead of including a .a (regardless of whether it's written
|
---|
| 201 | # as -lpthread or Threads::Threads above), making the pdfhtml binary produced
|
---|
| 202 | # a partially static, partially dynamic one, so dynamic executable overall.
|
---|
| 203 | # The order of dynamic .so files listed by ldd in the broken binary differs from
|
---|
| 204 | # a manually linked working version of pdftohtml, and seems to be the only difference
|
---|
| 205 | # between the two in ldd output. Not using "-Wl,-Bstatic" and using -static in its
|
---|
| 206 | # place creates a partially static dynamic executable that isn't broken, whereas
|
---|
| 207 | # additionally removing "-Wl,-Bdynamic -lpthread" and replacing it with -lpthread
|
---|
| 208 | # moreover produces a working pdftohtml that is a fully static linked executable.
|
---|
| 209 | # The inclusion of the math lib and c lib (lm and lc) in the final link command
|
---|
| 210 | # are to completely bypass the remaining .so dependencies that were present in
|
---|
| 211 | # the executable and produce the fully static executable.
|
---|
| 212 | # Not sure what colormanager (lcms) and typelibrary, or how they're written in -l
|
---|
| 213 | # form as they were not present when the original unmodified static linking command
|
---|
| 214 | # was run, so they've not been included in the replacement static linking command.
|
---|
| 215 | install(TARGETS pdftohtml RUNTIME DESTINATION bin)
|
---|
| 216 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftohtml.1 DESTINATION man/man1)
|
---|
| 217 | endif ()
|
---|
| 218 |
|
---|
| 219 | #--- pdfinfo
|
---|
| 220 |
|
---|
| 221 | add_executable(pdfinfo
|
---|
| 222 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 223 | pdfinfo.cc
|
---|
| 224 | )
|
---|
| 225 | target_link_libraries(pdfinfo goo fofi ${LCMS_LIBRARY} Threads::Threads)
|
---|
| 226 | install(TARGETS pdfinfo RUNTIME DESTINATION bin)
|
---|
| 227 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfinfo.1 DESTINATION man/man1)
|
---|
| 228 |
|
---|
| 229 | #--- pdffonts
|
---|
| 230 |
|
---|
| 231 | add_executable(pdffonts
|
---|
| 232 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 233 | pdffonts.cc
|
---|
| 234 | )
|
---|
| 235 | target_link_libraries(pdffonts goo fofi ${LCMS_LIBRARY} Threads::Threads)
|
---|
| 236 | install(TARGETS pdffonts RUNTIME DESTINATION bin)
|
---|
| 237 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdffonts.1 DESTINATION man/man1)
|
---|
| 238 |
|
---|
| 239 | #--- pdfdetach
|
---|
| 240 |
|
---|
| 241 | add_executable(pdfdetach
|
---|
| 242 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 243 | pdfdetach.cc
|
---|
| 244 | )
|
---|
| 245 | target_link_libraries(pdfdetach goo fofi ${LCMS_LIBRARY} Threads::Threads)
|
---|
| 246 | install(TARGETS pdfdetach RUNTIME DESTINATION bin)
|
---|
| 247 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfdetach.1 DESTINATION man/man1)
|
---|
| 248 |
|
---|
| 249 | #--- pdftoppm
|
---|
| 250 |
|
---|
| 251 | if (HAVE_SPLASH)
|
---|
| 252 | add_executable(pdftoppm
|
---|
| 253 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 254 | SplashOutputDev.cc
|
---|
| 255 | pdftoppm.cc
|
---|
| 256 | )
|
---|
| 257 | target_link_libraries(pdftoppm goo fofi splash ${PDFTO_PS_PPM_LINK_FLAGS})
|
---|
| 258 | # ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
|
---|
| 259 | # ${ZLIB_LIBRARIES}
|
---|
| 260 | # ${DTYPE_LIBRARY}
|
---|
| 261 | # ${LCMS_LIBRARY}
|
---|
| 262 | # Threads::Threads)
|
---|
| 263 | install(TARGETS pdftoppm RUNTIME DESTINATION bin)
|
---|
| 264 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftoppm.1 DESTINATION man/man1)
|
---|
| 265 | endif ()
|
---|
| 266 |
|
---|
| 267 | #--- pdftopng
|
---|
| 268 |
|
---|
| 269 | if (HAVE_SPLASH AND PNG_FOUND)
|
---|
| 270 | add_executable(pdftopng
|
---|
| 271 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 272 | SplashOutputDev.cc
|
---|
| 273 | pdftopng.cc
|
---|
| 274 | )
|
---|
| 275 | target_link_libraries(pdftopng goo fofi splash ${PDFTO_HTML_PNG_LINK_FLAGS})
|
---|
| 276 | # ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS}
|
---|
| 277 | # ${DTYPE_LIBRARY}
|
---|
| 278 | # ${LCMS_LIBRARY} ${PNG_LIBRARIES}
|
---|
| 279 | # Threads::Threads)
|
---|
| 280 | install(TARGETS pdftopng RUNTIME DESTINATION bin)
|
---|
| 281 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftopng.1 DESTINATION man/man1)
|
---|
| 282 | endif ()
|
---|
| 283 |
|
---|
| 284 | #--- pdfimages
|
---|
| 285 |
|
---|
| 286 | add_executable(pdfimages
|
---|
| 287 | $<TARGET_OBJECTS:xpdf_objs>
|
---|
| 288 | ImageOutputDev.cc
|
---|
| 289 | pdfimages.cc
|
---|
| 290 | )
|
---|
| 291 | target_link_libraries(pdfimages goo fofi ${LCMS_LIBRARY} Threads::Threads)
|
---|
| 292 | install(TARGETS pdfimages RUNTIME DESTINATION bin)
|
---|
| 293 | install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfimages.1 DESTINATION man/man1)
|
---|
| 294 |
|
---|
| 295 | #--- xpdfrc man page
|
---|
| 296 |
|
---|
| 297 | install(FILES ${PROJECT_SOURCE_DIR}/doc/xpdfrc.5 DESTINATION man/man5)
|
---|