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