FindPNG.cmake 1.2 KB

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