FindPNG.cmake 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # - Find the native PNG includes and library
  2. #
  3. # This module defines
  4. # PNG_INCLUDE_DIR, where to find png.h, etc.
  5. # PNG_LIBRARIES, the libraries to link against to use PNG.
  6. # PNG_DEFINITIONS - You should ADD_DEFINITONS(${PNG_DEFINITIONS}) before compiling code that includes png library files.
  7. # PNG_FOUND, If false, do not try to use PNG.
  8. # also defined, but not for general use are
  9. # PNG_LIBRARY, where to find the PNG library.
  10. # None of the above will be defined unles zlib can be found.
  11. # PNG depends on Zlib
  12. INCLUDE(FindZLIB)
  13. SET(PNG_FOUND "NO")
  14. IF(ZLIB_FOUND)
  15. FIND_PATH(PNG_PNG_INCLUDE_DIR png.h
  16. /usr/local/include
  17. /usr/include
  18. /usr/local/include/libpng # OpenBSD
  19. )
  20. SET(PNG_NAMES ${PNG_NAMES} png libpng)
  21. FIND_LIBRARY(PNG_LIBRARY
  22. NAMES ${PNG_NAMES}
  23. PATHS /usr/lib /usr/local/lib
  24. )
  25. IF (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR)
  26. # png.h includes zlib.h. Sigh.
  27. SET(PNG_INCLUDE_DIR ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
  28. SET(PNG_LIBRARIES ${PNG_LIBRARY} ${ZLIB_LIBRARY})
  29. SET(PNG_FOUND "YES")
  30. IF (CYGWIN)
  31. IF(BUILD_SHARED_LIBS)
  32. # No need to define PNG_USE_DLL here, because it's default for Cygwin.
  33. ELSE(BUILD_SHARED_LIBS)
  34. SET (PNG_DEFINITIONS -DPNG_STATIC)
  35. ENDIF(BUILD_SHARED_LIBS)
  36. ENDIF (CYGWIN)
  37. ENDIF (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR)
  38. ENDIF(ZLIB_FOUND)
  39. IF (PNG_FOUND)
  40. IF (NOT PNG_FIND_QUIETLY)
  41. MESSAGE(STATUS "Found PNG: ${PNG_LIBRARY}")
  42. ENDIF (NOT PNG_FIND_QUIETLY)
  43. ELSE (PNG_FOUND)
  44. IF (PNG_FIND_REQUIRED)
  45. MESSAGE(FATAL_ERROR "Could not find PNG library")
  46. ENDIF (PNG_FIND_REQUIRED)
  47. ENDIF (PNG_FOUND)
  48. MARK_AS_ADVANCED(PNG_PNG_INCLUDE_DIR PNG_LIBRARY )