diff options
author | Alexander Neundorf <neundorf@kde.org> | 2006-08-30 17:46:01 +0000 |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2006-08-30 17:46:01 +0000 |
commit | 1a50337ff5115bcb5e60b4b91c75a0e6a9a339b7 (patch) | |
tree | 736b18ab905cd2039c02a6d88c33517ce5650ad4 /modules | |
parent | 413f40c4d368ab28dfe16c49a9f5c6ebc98f9128 (diff) | |
download | extra-cmake-modules-1a50337ff5115bcb5e60b4b91c75a0e6a9a339b7.tar.gz extra-cmake-modules-1a50337ff5115bcb5e60b4b91c75a0e6a9a339b7.tar.bz2 |
-add a FindPNG.cmake which bails out with FATAL_ERROR if png was not found and which also searches in /usr/local/include/libpng/ (for OpenBSD)
-check that PNG was actually found
(both can be removed once we required cmake 2.4.4 ... so maybe next year)
Alex
svn path=/trunk/KDE/kdelibs/; revision=578973
Diffstat (limited to 'modules')
-rw-r--r-- | modules/FindPNG.cmake | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/modules/FindPNG.cmake b/modules/FindPNG.cmake new file mode 100644 index 00000000..797dd025 --- /dev/null +++ b/modules/FindPNG.cmake @@ -0,0 +1,58 @@ +# - Find the native PNG includes and library +# + +# This module defines +# PNG_INCLUDE_DIR, where to find png.h, etc. +# PNG_LIBRARIES, the libraries to link against to use PNG. +# PNG_DEFINITIONS - You should ADD_DEFINITONS(${PNG_DEFINITIONS}) before compiling code that includes png library files. +# PNG_FOUND, If false, do not try to use PNG. +# also defined, but not for general use are +# PNG_LIBRARY, where to find the PNG library. +# None of the above will be defined unles zlib can be found. +# PNG depends on Zlib +INCLUDE(FindZLIB) + +SET(PNG_FOUND "NO") + +IF(ZLIB_FOUND) + FIND_PATH(PNG_PNG_INCLUDE_DIR png.h + /usr/local/include + /usr/include + /usr/local/include/libpng # OpenBSD + ) + + SET(PNG_NAMES ${PNG_NAMES} png libpng) + FIND_LIBRARY(PNG_LIBRARY + NAMES ${PNG_NAMES} + PATHS /usr/lib /usr/local/lib + ) + + IF (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR) + # png.h includes zlib.h. Sigh. + SET(PNG_INCLUDE_DIR ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ) + SET(PNG_LIBRARIES ${PNG_LIBRARY} ${ZLIB_LIBRARY}) + SET(PNG_FOUND "YES") + + IF (CYGWIN) + IF(BUILD_SHARED_LIBS) + # No need to define PNG_USE_DLL here, because it's default for Cygwin. + ELSE(BUILD_SHARED_LIBS) + SET (PNG_DEFINITIONS -DPNG_STATIC) + ENDIF(BUILD_SHARED_LIBS) + ENDIF (CYGWIN) + + ENDIF (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR) + +ENDIF(ZLIB_FOUND) + +IF (PNG_FOUND) + IF (NOT PNG_FIND_QUIETLY) + MESSAGE(STATUS "Found PNG: ${PNG_LIBRARY}") + ENDIF (NOT PNG_FIND_QUIETLY) +ELSE (PNG_FOUND) + IF (PNG_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find PNG library") + ENDIF (PNG_FIND_REQUIRED) +ENDIF (PNG_FOUND) + +MARK_AS_ADVANCED(PNG_PNG_INCLUDE_DIR PNG_LIBRARY ) |