FindPNG.cmake 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #
  13. # Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  14. # See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  15. INCLUDE(FindZLIB)
  16. SET(PNG_FOUND "NO")
  17. IF(ZLIB_FOUND)
  18. FIND_PATH(PNG_PNG_INCLUDE_DIR png.h
  19. /usr/local/include
  20. /usr/include
  21. /usr/local/include/libpng # OpenBSD
  22. )
  23. SET(PNG_NAMES ${PNG_NAMES} png libpng)
  24. FIND_LIBRARY(PNG_LIBRARY
  25. NAMES ${PNG_NAMES}
  26. PATHS /usr/lib64 /usr/lib /usr/local/lib
  27. )
  28. IF (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR)
  29. # png.h includes zlib.h. Sigh.
  30. SET(PNG_INCLUDE_DIR ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
  31. SET(PNG_LIBRARIES ${PNG_LIBRARY} ${ZLIB_LIBRARY})
  32. SET(PNG_FOUND "YES")
  33. SET(HAVE_PNG_H)
  34. IF (CYGWIN)
  35. IF(BUILD_SHARED_LIBS)
  36. # No need to define PNG_USE_DLL here, because it's default for Cygwin.
  37. ELSE(BUILD_SHARED_LIBS)
  38. SET (PNG_DEFINITIONS -DPNG_STATIC)
  39. ENDIF(BUILD_SHARED_LIBS)
  40. ENDIF (CYGWIN)
  41. ENDIF (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR)
  42. ENDIF(ZLIB_FOUND)
  43. IF (PNG_FOUND)
  44. IF (NOT PNG_FIND_QUIETLY)
  45. MESSAGE(STATUS "Found PNG: ${PNG_LIBRARY}")
  46. ENDIF (NOT PNG_FIND_QUIETLY)
  47. ELSE (PNG_FOUND)
  48. IF (PNG_FIND_REQUIRED)
  49. MESSAGE(FATAL_ERROR "Could not find PNG library")
  50. ENDIF (PNG_FIND_REQUIRED)
  51. ENDIF (PNG_FOUND)
  52. MARK_AS_ADVANCED(PNG_PNG_INCLUDE_DIR PNG_LIBRARY )