← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~qcumber-some/widelands/minizip into lp:widelands

 

Jens Beyer (Qcumber-some) has proposed merging lp:~qcumber-some/widelands/minizip into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #536161 in widelands: "Widelands bundles internal copy of unzip.cc"
  https://bugs.launchpad.net/widelands/+bug/536161

For more details, see:
https://code.launchpad.net/~qcumber-some/widelands/minizip/+merge/101180

Try to detect Minizip library, if found use this one, if not, issue a warning in CMake run and include the widelands shipped ones (no source changes there).
-- 
https://code.launchpad.net/~qcumber-some/widelands/minizip/+merge/101180
Your team Widelands Developers is requested to review the proposed merge of lp:~qcumber-some/widelands/minizip into lp:widelands.
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt	2012-04-02 16:02:45 +0000
+++ CMakeLists.txt	2012-04-07 15:32:23 +0000
@@ -391,6 +391,12 @@
 find_package(ZLIB REQUIRED)
 include_directories(${ZLIB_INCLUDE_DIR})
 
+# Check if we have a working minizip library
+find_package(Minizip)
+if (MINIZIP_FOUND)
+  include_directories(${MINIZIP_INCLUDE_DIR})
+endif (MINIZIP_FOUND)
+
 if (APPLE OR WIN32)
   find_package(intl REQUIRED)
   include_directories(${INTL_INCLUDE_DIR})

=== added file 'cmake/Modules/FindMinizip.cmake'
--- cmake/Modules/FindMinizip.cmake	1970-01-01 00:00:00 +0000
+++ cmake/Modules/FindMinizip.cmake	2012-04-07 15:32:23 +0000
@@ -0,0 +1,37 @@
+# - Try to find Minizip
+# Once done this will define
+#  
+#  MINIZIP_FOUND        - system has MINIZIP
+#  MINIZIP_INCLUDE_DIR  - the MINIZIP include directory
+#  MINIZIP_LIBRARY_DIR  - where the libraries are
+#  MINIZIP_LIBRARY      - Link these to use MINIZIP
+#   
+
+IF (MINIZIP_INCLUDE_DIR)
+  # Already in cache, be silent
+  SET(MINIZIP_FIND_QUIETLY TRUE)
+ENDIF (MINIZIP_INCLUDE_DIR)
+
+FIND_PATH( MINIZIP_INCLUDE_DIR 
+	  NAMES zip.h unzip.h ioapi.h
+	  PATHS /usr/local/include /usr/include
+	  PATH_SUFFIXES minizip/ )
+SET( MINIZIP_NAMES minizip MINIZIP )
+FIND_LIBRARY( MINIZIP_LIBRARY
+	      NAMES ${MINIZIP_NAMES}
+	      PATHS /usr/lib /usr/local/lib )
+
+GET_FILENAME_COMPONENT( MINIZIP_LIBRARY_DIR ${MINIZIP_LIBRARY} PATH )
+
+IF (MINIZIP_INCLUDE_DIR AND MINIZIP_LIBRARY)
+   SET(MINIZIP_FOUND TRUE)
+   SET(MINIZIP_LIBRARY_DIR ${MINIZIP_LIBRARY} )
+   IF (NOT MINIZIP_FIND_QUIETLY)
+     MESSAGE (STATUS "Found Minizip: ${MINIZIP_LIBRARY} ${MINIZIP_INCLUDE_DIR}")
+   ENDIF (NOT MINIZIP_FIND_QUIETLY)
+ELSE (MINIZIP_INCLUDE_DIR AND MINIZIP_LIBRARY)
+   SET( MINIZIP_FOUND FALSE )
+   SET( MINIZIP_LIBRARY_DIR )
+   SET( MINIZIP_EXTRA_DEFINITIONS )
+ENDIF (MINIZIP_INCLUDE_DIR AND MINIZIP_LIBRARY)
+

=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt	2012-03-03 19:23:20 +0000
+++ src/CMakeLists.txt	2012-04-07 15:32:23 +0000
@@ -112,6 +112,11 @@
   add_subdirectory(scripting)
 endif (WL_UNIT_TESTS)
 
+if (NOT MINIZIP_FOUND)
+  add_subdirectory(minizip)
+  target_link_libraries(widelands_all wl_minizip)
+endif (NOT MINIZIP_FOUND)
+
 target_link_libraries(widelands_all ${SDLIMAGE_LIBRARY})
 target_link_libraries(widelands_all ${SDLMIXER_LIBRARY})
 target_link_libraries(widelands_all ${SDLNET_LIBRARY})
@@ -123,6 +128,9 @@
 target_link_libraries(widelands_all ${OPENGL_gl_LIBRARY})
 target_link_libraries(widelands_all ${GLEW_LIBRARY})
 target_link_libraries(widelands_all ${Boost_LIBRARIES})
+if (MINIZIP_FOUND)
+  target_link_libraries(widelands_all ${MINIZIP_LIBRARY})
+endif (MINIZIP_FOUND)
 if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
   target_link_libraries(widelands_all ${EXECINFO_LIBRARY})
 endif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")

=== modified file 'src/io/filesystem/zip_filesystem.h'
--- src/io/filesystem/zip_filesystem.h	2012-02-15 21:25:34 +0000
+++ src/io/filesystem/zip_filesystem.h	2012-04-07 15:32:23 +0000
@@ -21,8 +21,8 @@
 #define ZIP_FILESYSTEM_H
 
 #include "filesystem.h"
-#include "unzip.h"
-#include "zip.h"
+#include <minizip/unzip.h>
+#include <minizip/zip.h>
 
 #include <string>
 #include <cstring>

=== added directory 'src/minizip'
=== added file 'src/minizip/CMakeLists.txt'
--- src/minizip/CMakeLists.txt	1970-01-01 00:00:00 +0000
+++ src/minizip/CMakeLists.txt	2012-04-07 15:32:23 +0000
@@ -0,0 +1,3 @@
+add_library(wl_minizip STATIC EXCLUDE_FROM_ALL "unzip.cc")
+
+message(WARNING "You are using widelands-bundled minizip sources. Please install your distribution's minizip library or urge your distribution maintainer to include the minizip library in your package repository. Thank you.")

=== added file 'src/minizip/README.txt'
--- src/minizip/README.txt	1970-01-01 00:00:00 +0000
+++ src/minizip/README.txt	2012-04-07 15:32:23 +0000
@@ -0,0 +1,5 @@
+The files in this directory are either original or derived sources from zlib's minizip examples.
+
+The sources are only included in Widelands if you don't have Minizip installed.
+Please install your distribution's minizip library or urge your distribution maintainer 
+to include the minizip library in your package repository. Thank you.

=== renamed file 'src/io/filesystem/ioapi.h' => 'src/minizip/ioapi.h'
=== renamed file 'src/io/filesystem/unzip.cc' => 'src/minizip/unzip.cc'
=== renamed file 'src/io/filesystem/unzip.h' => 'src/minizip/unzip.h'
=== renamed file 'src/io/filesystem/zip.h' => 'src/minizip/zip.h'