FindPNG.cmake 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. IF(ZLIB_FOUND)
  14. FIND_PATH(PNG_PNG_INCLUDE_DIR png.h
  15. /usr/local/include/libpng # OpenBSD
  16. )
  17. SET(PNG_NAMES ${PNG_NAMES} png libpng)
  18. FIND_LIBRARY(PNG_LIBRARY NAMES ${PNG_NAMES} )
  19. IF (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR)
  20. # png.h includes zlib.h. Sigh.
  21. SET(PNG_INCLUDE_DIR ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
  22. SET(PNG_LIBRARIES ${PNG_LIBRARY} ${ZLIB_LIBRARY})
  23. IF (CYGWIN)
  24. IF(BUILD_SHARED_LIBS)
  25. # No need to define PNG_USE_DLL here, because it's default for Cygwin.
  26. ELSE(BUILD_SHARED_LIBS)
  27. SET (PNG_DEFINITIONS -DPNG_STATIC)
  28. ENDIF(BUILD_SHARED_LIBS)
  29. ENDIF (CYGWIN)
  30. ENDIF (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR)
  31. ENDIF(ZLIB_FOUND)
  32. # handle the QUIETLY and REQUIRED arguments and set PNG_FOUND to TRUE if
  33. # all listed variables are TRUE
  34. INCLUDE(FindPackageHandleStandardArgs)
  35. FIND_PACKAGE_HANDLE_STANDARD_ARGS(PNG DEFAULT_MSG PNG_LIBRARY PNG_PNG_INCLUDE_DIR)
  36. MARK_AS_ADVANCED(PNG_PNG_INCLUDE_DIR PNG_LIBRARY )