Skip to content
Browse files

Added Zlib addon to CMake build system.

  • Loading branch information...
1 parent 30b6e55 commit 1baf3f8dc2ddcd45e445823b01d3141202f3ba76 @jeremytregunna jeremytregunna committed May 9, 2010
Showing with 65 additions and 1 deletion.
  1. +1 −1 addons/CMakeLists.txt
  2. +41 −0 addons/Zlib/CMakeLists.txt
  3. +23 −0 modules/FindZlib.cmake
View
2 addons/CMakeLists.txt
@@ -111,4 +111,4 @@ add_subdirectory(User)
#add_subdirectory(Volcano)
#add_subdirectory(Vorbis)
add_subdirectory(Yajl)
-#add_subdirectory(Zlib)
+add_subdirectory(Zlib)
View
41 addons/Zlib/CMakeLists.txt
@@ -0,0 +1,41 @@
+# Base Io build system
+# Written by Jeremy Tregunna <jeremy.tregunna@me.com>
+#
+# Builds the Zlib addon
+
+# Find zlib
+find_package(Zlib)
+
+# Create the _build bundle hierarchy if needed.
+make_build_bundle(_build)
+
+# Did we find zlib? if so, set up the targets and all the support
+# variables.
+if(ZLIB_FOUND)
+ # Output our dynamic library to the top-level _build hierarchy
+ set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/_build/dll)
+
+ # Additional include directories
+ include_directories(${ZLIB_INCLUDE_DIR})
+
+ # Generate the IoZlibInit.c file.
+ # Argument SHOULD ALWAYS be the exact name of the addon, case is
+ # important.
+ generate_ioinit(Zlib)
+
+ # Our library sources.
+ set(SRCS
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoZlibEncoder.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoZlibDecoder.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoZlibInit.c"
+ )
+
+ # Now build the shared library
+ add_library(IoZlib SHARED ${SRCS})
+ add_dependencies(IoZlib iovmall)
+ target_link_libraries(IoZlib iovmall ${ZLIB_LIBRARY})
+
+ # Install the addon to our global addons hierarchy.
+ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/io/addons)
+ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/_build DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/io/addons/Zlib)
+endif(ZLIB_FOUND)
View
23 modules/FindZlib.cmake
@@ -0,0 +1,23 @@
+# Base Io build system
+# Written by Jeremy Tregunna <jeremy.tregunna@me.com>
+#
+# Find libzlib
+
+FIND_PATH(ZLIB_INCLUDE_DIR zlib.h)
+
+SET(ZLIB_NAMES ${ZLIB_NAMES} z libz)
+FIND_LIBRARY(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} PATH)
+
+IF(ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
+ SET(ZLIB_FOUND TRUE)
+ENDIF(ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
+
+IF(ZLIB_FOUND)
+ IF(NOT ZLIB_FIND_QUIETLY)
+ MESSAGE(STATUS "Found ZLIB: ${ZLIB_LIBRARY}")
+ ENDIF (NOT ZLIB_FIND_QUIETLY)
+ELSE(ZLIB_FOUND)
+ IF(ZLIB_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find ZLIB")
+ ENDIF(ZLIB_FIND_REQUIRED)
+ENDIF(ZLIB_FOUND)

0 comments on commit 1baf3f8

Please sign in to comment.
Something went wrong with that request. Please try again.