- Timestamp:
- 2018-07-06T21:31:53+12:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/xpdf-tools/trunk/src/packages/gs-CMakeLists.txt
r32247 r32248 10 10 11 11 #======================================================================== 12 # This is a customised version of Xpdf Tools' CMake file. 13 # Customised for Greenstone. 12 # This is a customised version of Xpdf Tools' CMake file for Greenstone 13 # where we want to build static xpdf-tools executables. 14 # Refer to the GS-README.txt file for the Greenstone "xpdf-tools" 15 # gs2-extension and read section D for the GS specific customisations 16 # in this file and the reasoning behind them, most of which have to do 17 # with attempting to successfully build xpdf-tools statically. 14 18 #======================================================================== 15 19 … … 21 25 22 26 23 # For Mac OSX, when -static is passed in for linking, we end up with the error "ld: library not found for -lcrt0.o" 24 # See https://stackoverflow.com/questions/3801011/ld-library-not-found-for-lcrt0-o-on-osx-10-6-with-gcc-clang-static-flag 25 # On Mac OSX, compile it with -Bstatic, as per https://stackoverflow.com/questions/844819/how-to-static-link-on-os-x 26 # XPDFTOOLS.sh will have set the GSDLFLAG_STATIC to either "-static" (for linux) or "-Bstatic" for darwin 27 # When compiling statically, XPDFTOOLS.sh will have set the custom 28 # GSDLFLAG_STATIC flag to either "-static" for linux or "-Bstatic" for darwin 27 29 28 30 if(GSDLFLAG_STATIC) … … 131 133 endif () 132 134 133 # We want to build static xpdf-tools binaries. See134 # https://stackoverflow.com/questions/24648357/compiling-a-static-executable-with-cmake135 # Want to make the min number of changes for building statically, so using the way136 # below. Beware, must *append* "-static" to existing CMAKE_EXE_LINKER_FLAGS=LD_FLAGS137 ##SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")138 ##SET(BUILD_SHARED_LIBS OFF)139 ##SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")140 141 # The original, unmodified CMakeLists.txt was not set up sufficiently142 # for static compilation of xpdf-tools. As a result, compile would first fail143 # with errors about undefined refs to mutex / lpthread.144 # When building xpdf-tools statically, need to add the following 2 lines as well145 # as append "Threads::Threads" to the end of each "target_link_libraries(<list>)"146 # See https://stackoverflow.com/questions/1620918/cmake-and-libpthread147 # found googling cmake and "-lpthread" (pthread) after ERRORS to do with this, like:148 # undefined reference to `pthread_mutex_unlock'149 ##set(THREADS_PREFER_PTHREAD_FLAG ON)150 ##find_package(Threads REQUIRED)151 152 135 #--- pdftops 153 136 … … 222 205 ${LCMS_LIBRARY} ${PNG_LIBRARIES}) 223 206 endif () 224 # Doing the regular target_link_libraries() in static mode results in building with225 # "-Wl,-Bstatic -lfreetype -lpng15 -lz -Wl,-Bdynamic -lpthread" at end of link line226 # and produces broken binaries for pdftohtml/pdftoppm/pdftops/pdftopng.227 # Note that PNG_LIBRARIES includes zlib/lz: "-lpng -lz", and along with freetype,228 # these are linked statically. However, Threads/lpthread is included as a dynamically229 # linked library instead of including a .a (regardless of whether it's appended230 # as -lpthread or Threads::Threads in else above), contributing to the pdfhtml binary231 # produced being a partially static, partially dynamic one,232 # so a dynamic executable overall.233 # The order of dynamic .so files listed by ldd in the broken binary differs from234 # a manually linked working version of pdftohtml, and seems to be the only difference235 # between the two in ldd output. Not using "-Wl,-Bstatic" and using -static (-Bstatic on Mac)236 # in its place creates a partially static dynamic executable that isn't broken, whereas237 # additionally removing "-Wl,-Bdynamic -lpthread" and replacing it with -lpthread238 # moreover produces a working pdftohtml that is a fully static linked executable.239 # The inclusion of the math lib and c lib (lm and lc) in the final link command240 # are to completely bypass the remaining .so dependencies that were present in241 # the executable and produce the fully static executable.242 # Not sure what colormanager (lcms) and typelibrary, or how they're written in -l243 # form as they were not present when the original unmodified static linking command244 # was run, so they've not been included in the replacement static linking command.245 207 install(TARGETS pdftohtml RUNTIME DESTINATION bin) 246 208 install(FILES ${PROJECT_SOURCE_DIR}/doc/pdftohtml.1 DESTINATION man/man1)
Note:
See TracChangeset
for help on using the changeset viewer.