ENH: fix bug where sharedforward would not work if there was a space in the path...
[cmake.git] / Modules / FindPNG.cmake
blobd64b074bb6950c256a5527c22cddf13b87c9f352
1 # - Find the native PNG includes and library
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)
14 IF(ZLIB_FOUND)
15   FIND_PATH(PNG_PNG_INCLUDE_DIR png.h
16   /usr/local/include/libpng             # OpenBSD
17   )
19   SET(PNG_NAMES ${PNG_NAMES} png libpng png12 libpng12)
20   FIND_LIBRARY(PNG_LIBRARY NAMES ${PNG_NAMES} )
22   IF (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR)
23       # png.h includes zlib.h. Sigh.
24       SET(PNG_INCLUDE_DIR ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
25       SET(PNG_LIBRARIES ${PNG_LIBRARY} ${ZLIB_LIBRARY})
27       IF (CYGWIN)
28         IF(BUILD_SHARED_LIBS)
29            # No need to define PNG_USE_DLL here, because it's default for Cygwin.
30         ELSE(BUILD_SHARED_LIBS)
31           SET (PNG_DEFINITIONS -DPNG_STATIC)
32         ENDIF(BUILD_SHARED_LIBS)
33       ENDIF (CYGWIN)
35   ENDIF (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR)
37 ENDIF(ZLIB_FOUND)
39 # handle the QUIETLY and REQUIRED arguments and set PNG_FOUND to TRUE if 
40 # all listed variables are TRUE
41 INCLUDE(FindPackageHandleStandardArgs)
42 FIND_PACKAGE_HANDLE_STANDARD_ARGS(PNG DEFAULT_MSG PNG_LIBRARY PNG_PNG_INCLUDE_DIR)
44 MARK_AS_ADVANCED(PNG_PNG_INCLUDE_DIR PNG_LIBRARY )