浏览代码

Adding Zlib and PNG find modules in the new format

Ian Scott 23 年之前
父节点
当前提交
8600beb1ed
共有 2 个文件被更改,包括 48 次插入1 次删除
  1. 47 0
      Modules/FindPNG.cmake
  2. 1 1
      Modules/FindZLib.cmake

+ 47 - 0
Modules/FindPNG.cmake

@@ -0,0 +1,47 @@
+#
+# 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_FOUND, If false, do 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( ${MODULE_PATH}/NewCMake/FindZLIB.cmake )
+
+IF(ZLIB_FOUND)
+  FIND_PATH(PNG_PNG_INCLUDE_DIR png.h
+  /usr/local/include
+  /usr/include
+  )
+
+  FIND_LIBRARY(PNG_LIBRARY png
+  /usr/lib
+  /usr/local/lib
+  )
+
+  IF (PNG_LIBRARY)
+    IF (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_PNG_INCLUDE_DIR)
+  ENDIF (PNG_LIBRARY)
+
+ENDIF(ZLIB_FOUND)

+ 1 - 1
Modules/FindZLib.cmake

@@ -19,5 +19,5 @@ IF(ZLIB_INCLUDE_DIR)
   IF(ZLIB_LIBRARY)
     SET( ZLIB_LIBRARIES ${ZLIB_LIBRARY} )
     SET( ZLIB_FOUND "YES" )
-  ENDIF(ZLIB_LIBRARIES)
+  ENDIF(ZLIB_LIBRARY)
 ENDIF(ZLIB_INCLUDE_DIR)