ZLIB.cmake 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # -*- cmake -*-
  2. if (ZLIB_CMAKE_INCLUDED)
  3. return()
  4. endif (ZLIB_CMAKE_INCLUDED)
  5. set (ZLIB_CMAKE_INCLUDED TRUE)
  6. include(Prebuilt)
  7. # Note: We do not allow USESYSTEMLIBS here, because we are using zlib-ng,
  8. # which is very unlikely to be used on any Linux system (for now, at least),
  9. # and if present, just as unlikely with the same compile-time configuration
  10. # as ours... HB
  11. #if (USESYSTEMLIBS)
  12. # set(ZLIB_FIND_QUIETLY ON)
  13. # set(ZLIB_FIND_REQUIRED OFF)
  14. # include(FindZLIBNG)
  15. # find_library(MINIZIP_LIBRARY NAMES minizip)
  16. # set(MINIZIP_FIND_QUIETLY ON)
  17. # set(MINIZIP_FIND_REQUIRED OFF)
  18. # include(FindPackageHandleStandardArgs)
  19. # find_package_handle_standard_args(MiniZip DEFAULT_MSG MINIZIP_LIBRARY)
  20. #endif (USESYSTEMLIBS)
  21. #if (NOT ZLIB_FOUND OR NOT MINIZIP_FOUND)
  22. use_prebuilt_binary(zlib)
  23. if (WINDOWS)
  24. set(ZLIB_LIBRARIES zlib)
  25. set(MINIZIP_LIBRARIES libminizip)
  26. set(ZLIB_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/zlib-ng)
  27. elseif (LINUX)
  28. set(ZLIB_LIBRARIES ${ARCH_PREBUILT_DIRS_RELEASE}/libz.a)
  29. set(MINIZIP_LIBRARIES ${ARCH_PREBUILT_DIRS_RELEASE}/libminizip.a)
  30. #
  31. # When we have updated static libraries in competition with older shared
  32. # libraries and we want the former to win, we need to do some extra work.
  33. # The *_PRELOAD_ARCHIVES settings are invoked early and will pull in the
  34. # entire archive to the binary giving it priority in symbol resolution.
  35. # Beware of cmake moving the archive load itself to another place on the
  36. # link command line. If that happens, you can try something like -Wl,-lz
  37. # here to hide the archive. Also be aware that the linker will not tolerate
  38. # a second whole-archive load of the archive. See viewer's CMakeLists.txt
  39. # for more information.
  40. #
  41. set(ZLIB_PRELOAD_ARCHIVES "-Wl,--whole-archive ${ZLIB_LIBRARIES} -Wl,--no-whole-archive")
  42. set(ZLIB_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/zlib-ng)
  43. elseif (DARWIN)
  44. set(ZLIB_LIBRARIES ${ARCH_PREBUILT_DIRS_RELEASE}/libz.a)
  45. set(MINIZIP_LIBRARIES ${ARCH_PREBUILT_DIRS_RELEASE}/libminizip.a)
  46. set(ZLIB_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/zlib-ng)
  47. endif (WINDOWS)
  48. #else (NOT ZLIB_FOUND OR NOT MINIZIP_FOUND)
  49. # set(MINIZIP_LIBRARIES ${MINIZIP_LIBRARY})
  50. #endif (NOT ZLIB_FOUND OR NOT MINIZIP_FOUND)
  51. include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})