FindPNG.cmake 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 2002-2009 Kitware, Inc.
  14. #
  15. # Distributed under the OSI-approved BSD License (the "License");
  16. # see accompanying file Copyright.txt for details.
  17. #
  18. # This software is distributed WITHOUT ANY WARRANTY; without even the
  19. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  20. # See the License for more information.
  21. #=============================================================================
  22. # (To distributed this file outside of CMake, substitute the full
  23. # License text for the above reference.)
  24. if(PNG_FIND_QUIETLY)
  25. set(_FIND_ZLIB_ARG QUIET)
  26. endif(PNG_FIND_QUIETLY)
  27. find_package(ZLIB ${_FIND_ZLIB_ARG})
  28. if(ZLIB_FOUND)
  29. find_path(PNG_PNG_INCLUDE_DIR png.h
  30. /usr/local/include/libpng # OpenBSD
  31. )
  32. set(PNG_NAMES ${PNG_NAMES} png libpng png12 libpng12)
  33. find_library(PNG_LIBRARY NAMES ${PNG_NAMES} )
  34. if (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR)
  35. # png.h includes zlib.h. Sigh.
  36. SET(PNG_INCLUDE_DIR ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
  37. SET(PNG_LIBRARIES ${PNG_LIBRARY} ${ZLIB_LIBRARY})
  38. if (CYGWIN)
  39. if(BUILD_SHARED_LIBS)
  40. # No need to define PNG_USE_DLL here, because it's default for Cygwin.
  41. else(BUILD_SHARED_LIBS)
  42. SET (PNG_DEFINITIONS -DPNG_STATIC)
  43. endif(BUILD_SHARED_LIBS)
  44. endif (CYGWIN)
  45. endif (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR)
  46. endif(ZLIB_FOUND)
  47. # handle the QUIETLY and REQUIRED arguments and set PNG_FOUND to TRUE if
  48. # all listed variables are TRUE
  49. include(FindPackageHandleStandardArgs)
  50. find_package_handle_standard_args(PNG DEFAULT_MSG PNG_LIBRARY PNG_PNG_INCLUDE_DIR)
  51. mark_as_advanced(PNG_PNG_INCLUDE_DIR PNG_LIBRARY )