#======================================================================== # # xpdf/cmake-xpdf.txt # # CMake script for the Xpdf tools. # # Copyright 2015 Glyph & Cog, LLC # #======================================================================== #======================================================================== # This is a customised version of Xpdf Tools' CMake file for Greenstone # where we want to build static xpdf-tools executables. # Refer to the GS-README.txt file for the Greenstone "xpdf-tools" # gs2-extension and read section D for the GS specific customisations # in this file and the reasoning behind them, most of which have to do # with attempting to successfully build xpdf-tools statically. #======================================================================== include_directories("${PROJECT_SOURCE_DIR}") include_directories("${PROJECT_BINARY_DIR}") include_directories("${PROJECT_SOURCE_DIR}/goo") include_directories("${PROJECT_SOURCE_DIR}/fofi") include_directories("${PROJECT_SOURCE_DIR}/splash") # When compiling statically, XPDFTOOLS.sh will have set the custom # GSDLFLAG_STATIC flag to either "-static" for linux or "-Bstatic" for darwin if(GSDLFLAG_STATIC) message(STATUS "@@@@ GSDLFLAG_STATIC SET to ${GSDLFLAG_STATIC}. Building xpdf-tools statically.") else () message(STATUS "@@@@ GSDLFLAG_STATIC not SET. Building dynamically using xpdf-tools' (mostly) original, unmodified linker flags.") endif () if (JPEG_FOUND) include_directories("${JPEG_INCLUDE_DIR}") add_definitions("${JPEG_DEFINITIONS}") message(STATUS "@@@@@@@@@@@@@@@ JPEG_FOUND (include_dir ; include_dirs): ${JPEG_INCLUDE_DIR} ; ${JPEG_INCLUDE_DIRS}") else () message(STATUS "@@@@@@@@@@@@@@@ NO JPEG_FOUND") endif () if (TIFF_FOUND) include_directories("${TIFF_INCLUDE_DIRS}") add_definitions("${TIFF_DEFINITIONS}") message(STATUS "@@@@@@@@@@@@@@@ TIFF_FOUND ${TIFF_INCLUDE_DIRS}") else () message(STATUS "@@@@@@@@@@@@@@@ NO TIFF_FOUND") endif () if (PNG_FOUND) include_directories("${PNG_INCLUDE_DIRS}") add_definitions("${PNG_DEFINITIONS}") else () message(STATUS "@@@@@@@@@@@@@@@ NO PNG_FOUND") endif () # https://stackoverflow.com/questions/36126333/mingw-cmake-undefined-reference-to-zlib if (ZLIB_FOUND) include_directories("${ZLIB_INCLUDE_DIRS}") add_definitions("${ZLIB_DEFINITIONS}") else () message(STATUS "@@@@@@@@@@@@@@@ NO ZLIB_FOUND") endif () if (HAVE_LCMS) include_directories("${LCMS_INCLUDE_DIR}") set(COLOR_MANAGER_SOURCE "ColorManager.cc") if(GSDLFLAG_STATIC) # Untested combination, warn https://cmake.org/cmake/help/v3.0/command/message.html message(AUTHOR_WARNING "@@@@@@@@@@@@@@@ GSDL Warning: static building with HAVE_LCMS on. If running ldd/file on generated binaries shows any binary to be partially a dynamic executable, then Export VERBOSE=1 and re-run the CMake build. Then check the verbose build output's linker flags (for static building) for that binary: they should not be -Wl,-Bstatic LIBS -Wl,-Bdynamic -lpthread but -static LIBS. Fix it by removing all references to LCMS_LIBRARY in the static linking flags of target_link_libraries statements (i.e. when GSDLFLAG_STATIC is set) in file gs-CMakeLists.txt and replacing them with the -l equivalent for the color manager library, (l)cms. @@@@@@@@@@@@@@@") endif () else () set(COLOR_MANAGER_SOURCE "") endif () if (DTYPE_LIBRARY) if(GSDLFLAG_STATIC) # Untested combination, warn message(AUTHOR_WARNING "@@@@@@@@@@@@@@@ GSDL Warning: static building with TYPE_LIBRARY. If running ldd/file on generated binaries shows any binary to be partially a dynamic executable, then export VERBOSE=1 and re-run the CMake build. Then check the verbose build output's linker flags (for static building) for that binary: they should not be -Wl,-Bstatic LIBS -Wl,-Bdynamic -lpthread but -static LIBS. Fix it by removing all references to DTYPE_LIBRARY in the static linking flags of target_link_libraries statements (i.e. when GSDLFLAG_STATIC is set) in file gs-CMakeLists.txt and replacing them with the -l equivalent for typelib. @@@@@@@@@@@@@@@") endif () endif () add_library(xpdf_objs OBJECT AcroForm.cc Annot.cc Array.cc BuiltinFont.cc BuiltinFontTables.cc Catalog.cc CharCodeToUnicode.cc CMap.cc ${COLOR_MANAGER_SOURCE} Decrypt.cc Dict.cc Error.cc FontEncodingTables.cc Form.cc Function.cc Gfx.cc GfxFont.cc GfxState.cc GlobalParams.cc JArithmeticDecoder.cc JBIG2Stream.cc JPXStream.cc Lexer.cc Link.cc NameToCharCode.cc Object.cc OptionalContent.cc Outline.cc OutputDev.cc Page.cc Parser.cc PDFDoc.cc PDFDocEncoding.cc PSTokenizer.cc SecurityHandler.cc Stream.cc TextString.cc UnicodeMap.cc UnicodeTypeTable.cc UTF8.cc XFAForm.cc XRef.cc Zoox.cc ) #--- object files needed by XpdfWidget if ((QT4_FOUND OR Qt5Widgets_FOUND) AND HAVE_SPLASH AND MULTITHREADED AND USE_EXCEPTIONS) if (HIGHLIGHTED_REGIONS) set(HIGHLIGHT_SRC "HighlightFile.cc") else () set(HIGHLIGHT_SRC "") endif () add_library(xpdf_widget_objs OBJECT DisplayState.cc PDFCore.cc PreScanOutputDev.cc PSOutputDev.cc SplashOutputDev.cc TextOutputDev.cc TileCache.cc TileCompositor.cc TileMap.cc ${HIGHLIGHT_SRC} ) endif () #--- pdftops if (HAVE_SPLASH) add_executable(pdftops $ PreScanOutputDev.cc PSOutputDev.cc SplashOutputDev.cc pdftops.cc ) if(GSDLFLAG_STATIC) target_link_libraries(pdftops goo fofi splash ${GSDLFLAG_STATIC} -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -ltiff -ljpeg -lz -lm -lc -lpthread) # Threads::Threads instead of -lpthread results in a partially dynamic executable else () target_link_libraries(pdftops goo fofi splash ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS} ${DTYPE_LIBRARY} ${LCMS_LIBRARY} ${TIFF_LIBRARY} ${JPEG_LIBRARY} ${ZLIB_LIBRARIES}) endif () else () add_executable(pdftops $ PreScanOutputDev.cc PSOutputDev.cc pdftops.cc ) if(GSDLFLAG_STATIC) target_link_libraries(pdftops goo fofi ${GSDLFLAG_STATIC} ${LCMS_LIBRARY} -ltiff -ljpeg -lm -lc -lpthread) else () target_link_libraries(pdftops goo fofi ${LCMS_LIBRARY} ${TIFF_LIBRARY} ${JPEG_LIBRARY}) endif () endif () install(TARGETS pdftops RUNTIME DESTINATION bin) install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftops.1 DESTINATION man/man1) #--- pdftotext add_executable(pdftotext $ TextOutputDev.cc pdftotext.cc ) if(GSDLFLAG_STATIC) target_link_libraries(pdftotext goo fofi ${GSDLFLAG_STATIC} ${LCMS_LIBRARY} -ltiff -ljpeg -lpthread) # Threads::Threads instead of -lpthread results in a partially dynamic executable else () target_link_libraries(pdftotext goo fofi ${LCMS_LIBRARY} ${TIFF_LIBRARY} ${JPEG_LIBRARY}) endif () install(TARGETS pdftotext RUNTIME DESTINATION bin) install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftotext.1 DESTINATION man/man1) #--- pdftohtml if (HAVE_SPLASH AND PNG_FOUND) add_executable(pdftohtml $ HTMLGen.cc SplashOutputDev.cc TextOutputDev.cc pdftohtml.cc ) if(GSDLFLAG_STATIC) target_link_libraries(pdftohtml goo fofi splash ${GSDLFLAG_STATIC} -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -ltiff -ljpeg -lpng -lz -lm -lc -lpthread) else () target_link_libraries(pdftohtml goo fofi splash ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS} ${DTYPE_LIBRARY} ${LCMS_LIBRARY} ${TIFF_LIBRARY} ${JPEG_LIBRARY} ${PNG_LIBRARIES}) endif () install(TARGETS pdftohtml RUNTIME DESTINATION bin) install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftohtml.1 DESTINATION man/man1) endif () #--- pdfinfo add_executable(pdfinfo $ pdfinfo.cc ) if(GSDLFLAG_STATIC) target_link_libraries(pdfinfo goo fofi ${GSDLFLAG_STATIC} ${LCMS_LIBRARY} -ltiff -ljpeg -lpthread) else () target_link_libraries(pdfinfo goo fofi ${LCMS_LIBRARY} ${TIFF_LIBRARY} ${JPEG_LIBRARY}) endif() install(TARGETS pdfinfo RUNTIME DESTINATION bin) install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfinfo.1 DESTINATION man/man1) #--- pdffonts add_executable(pdffonts $ pdffonts.cc ) if(GSDLFLAG_STATIC) target_link_libraries(pdffonts goo fofi ${GSDLFLAG_STATIC} ${LCMS_LIBRARY} -ltiff -ljpeg -lpthread) else () target_link_libraries(pdffonts goo fofi ${LCMS_LIBRARY} ${TIFF_LIBRARY} ${JPEG_LIBRARY}) endif () install(TARGETS pdffonts RUNTIME DESTINATION bin) install(FILES ${PROJECT_SOURCE_DIR}/doc/pdffonts.1 DESTINATION man/man1) #--- pdfdetach add_executable(pdfdetach $ pdfdetach.cc ) if(GSDLFLAG_STATIC) target_link_libraries(pdfdetach goo fofi ${GSDLFLAG_STATIC} ${LCMS_LIBRARY} -ltiff -ljpeg -lpthread) else () target_link_libraries(pdfdetach goo fofi ${LCMS_LIBRARY} ${TIFF_LIBRARY} ${JPEG_LIBRARY}) endif () install(TARGETS pdfdetach RUNTIME DESTINATION bin) install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfdetach.1 DESTINATION man/man1) #--- pdftoppm if (HAVE_SPLASH) add_executable(pdftoppm $ SplashOutputDev.cc pdftoppm.cc ) if(GSDLFLAG_STATIC) target_link_libraries(pdftoppm goo fofi splash ${GSDLFLAG_STATIC} -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -ltiff -ljpeg -lz -lm -lc -lpthread) else () target_link_libraries(pdftoppm goo fofi splash ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS} ${DTYPE_LIBRARY} ${LCMS_LIBRARY} ${TIFF_LIBRARY} ${JPEG_LIBRARY} ${ZLIB_LIBRARIES}) endif () install(TARGETS pdftoppm RUNTIME DESTINATION bin) install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftoppm.1 DESTINATION man/man1) endif () #--- pdftopng if (HAVE_SPLASH AND PNG_FOUND) add_executable(pdftopng $ SplashOutputDev.cc pdftopng.cc ) if(GSDLFLAG_STATIC) target_link_libraries(pdftopng goo fofi splash ${GSDLFLAG_STATIC} -lfreetype ${DTYPE_LIBRARY} ${LCMS_LIBRARY} -ltiff -ljpeg -lpng -lz -lm -lc -lpthread) else () target_link_libraries(pdftopng goo fofi splash ${FREETYPE_LIBRARY} ${FREETYPE_OTHER_LIBS} ${DTYPE_LIBRARY} ${TIFF_LIBRARY} ${JPEG_LIBRARY} ${LCMS_LIBRARY} ${PNG_LIBRARIES}) endif () install(TARGETS pdftopng RUNTIME DESTINATION bin) install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftopng.1 DESTINATION man/man1) endif () #--- pdfimages add_executable(pdfimages $ ImageOutputDev.cc pdfimages.cc ) if(GSDLFLAG_STATIC) target_link_libraries(pdfimages goo fofi ${GSDLFLAG_STATIC} ${LCMS_LIBRARY} -ltiff -ljpeg -lpthread) else () target_link_libraries(pdfimages goo fofi ${LCMS_LIBRARY} ${TIFF_LIBRARY} ${JPEG_LIBRARY}) endif () install(TARGETS pdfimages RUNTIME DESTINATION bin) install(FILES ${PROJECT_SOURCE_DIR}/doc/pdfimages.1 DESTINATION man/man1) #--- xpdfrc man page install(FILES ${PROJECT_SOURCE_DIR}/doc/xpdfrc.5 DESTINATION man/man5)