fixed: auto_ptr -> unique_ptr
[opensg.git] / CMake / FindPNG_OpenSG.cmake
blob9b0ecf878b1a17b6455416e2ce2518ad68d2213e
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   FIND_PATH(PNG_INCLUDE_DIR png.h
17   /usr/local/include/libpng             # OpenBSD
18   )
20   SET(PNG_NAMES_RELEASE ${PNG_NAMES_RELEASE} png libpng png12 libpng12)
21   FIND_LIBRARY(PNG_LIBRARY_RELEASE NAMES ${PNG_NAMES_RELEASE} )
23   SET(PNG_NAMES_DEBUG ${PNG_NAMES_DEBUG} pngd libpngd png12d libpng12d)
24   FIND_LIBRARY(PNG_LIBRARY_DEBUG NAMES ${PNG_NAMES_DEBUG} )
26   SET(PNG_LIBRARIES_FOUND )
28   IF(PNG_LIBRARY_DEBUG)
29     SET(PNG_LIBRARIES_FOUND TRUE)
30     MARK_AS_ADVANCED(PNG_LIBRARY_DEBUG)
31   ENDIF(PNG_LIBRARY_DEBUG)
33   IF(PNG_LIBRARY_RELEASE)
34     SET(PNG_LIBRARIES_FOUND TRUE)
35     MARK_AS_ADVANCED(PNG_LIBRARY_RELEASE)
36   ENDIF(PNG_LIBRARY_RELEASE)
39   IF(PNG_LIBRARIES_FOUND AND PNG_INCLUDE_DIR)
40       # png.h includes zlib.h. Sigh.
41 #      SET(PNG_INCLUDE_DIR ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
42 #      SET(PNG_LIBRARIES ${PNG_LIBRARY} ${ZLIB_LIBRARY})
44       IF(CYGWIN)
45         IF(BUILD_SHARED_LIBS)
46            # No need to define PNG_USE_DLL here, because it's default for
47            # Cygwin. 
48         ELSE(BUILD_SHARED_LIBS)
49           SET (PNG_DEFINITIONS -DPNG_STATIC)
50         ENDIF(BUILD_SHARED_LIBS)
51       ENDIF (CYGWIN)
53   ENDIF(PNG_LIBRARIES_FOUND AND PNG_INCLUDE_DIR)
55 ENDIF(ZLIB_FOUND)
57 # handle the QUIETLY and REQUIRED arguments and set PNG_FOUND to TRUE if 
58 # all listed variables are TRUE
59 INCLUDE(FindPackageHandleStandardArgs)
60 FIND_PACKAGE_HANDLE_STANDARD_ARGS(PNG DEFAULT_MSG 
61                                   PNG_LIBRARIES_FOUND PNG_INCLUDE_DIR)
63 MARK_AS_ADVANCED(PNG_INCLUDE_DIR PNG_LIBRARIES_FOUND)