PNG.cmake 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # -*- cmake -*-
  2. if (PNG_CMAKE_INCLUDED)
  3. return()
  4. endif (PNG_CMAKE_INCLUDED)
  5. set (PNG_CMAKE_INCLUDED TRUE)
  6. include(Prebuilt)
  7. set(PNG_FIND_QUIETLY ON)
  8. set(PNG_FIND_REQUIRED OFF)
  9. if (USESYSTEMLIBS)
  10. include(FindPNG)
  11. endif (USESYSTEMLIBS)
  12. if (NOT PNG_FOUND)
  13. use_prebuilt_binary(libpng)
  14. if (WINDOWS)
  15. set(PNG_LIBRARIES libpng16)
  16. elseif(DARWIN)
  17. set(PNG_LIBRARIES png16)
  18. elseif(LINUX)
  19. #
  20. # When we have updated static libraries in competition with older shared
  21. # libraries and we want the former to win, we need to do some extra work.
  22. # The *_PRELOAD_ARCHIVES settings are invoked early and will pull in the
  23. # entire archive to the binary giving it priority in symbol resolution.
  24. # Beware of cmake moving the archive load itself to another place on the
  25. # link command line. If that happens, you can try something like
  26. # -Wl,-lpng16 here to hide the archive. Also be aware that the linker will
  27. # not tolerate a second whole-archive load of the archive. See viewer's
  28. # CMakeLists.txt for more information.
  29. #
  30. set(PNG_PRELOAD_ARCHIVES -Wl,--whole-archive png16 -Wl,--no-whole-archive)
  31. set(PNG_LIBRARIES png16)
  32. endif(WINDOWS)
  33. set(PNG_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/libpng16)
  34. endif (NOT PNG_FOUND)
  35. include_directories(SYSTEM ${PNG_INCLUDE_DIRS})