Commit | Line | Data |
---|---|---|
9299da13 AEFG |
1 | Description: use the system-wide minizip instead of the embeeded one if found. |
2 | Forwarded-Upstream: It was provided by upstream: http://bazaar.launchpad.net/~widelands-dev/widelands/b19-debian/revision/8147 | |
3 | . | |
4 | Thanks to Fòram na Gàidhlig for the patch. | |
5 | ||
6 | I just added this line to make its use easier: | |
7 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_HOME_DIRECTORY}/Modules) | |
8 | ||
9 | === modified file 'CMakeLists.txt' | |
10 | --- | |
11 | CMakeLists.txt | 3 +++ | |
12 | Modules/FindMinizip.cmake | 37 +++++++++++++++++++++++++++++++++++++ | |
13 | cmake/WlFunctions.cmake | 7 +++++++ | |
14 | src/io/CMakeLists.txt | 2 +- | |
15 | src/third_party/CMakeLists.txt | 20 +++++++++++--------- | |
16 | src/third_party/minizip/README.txt | 4 ++++ | |
17 | 6 files changed, 63 insertions(+), 10 deletions(-) | |
18 | ||
19 | --- a/CMakeLists.txt | |
20 | +++ b/CMakeLists.txt | |
21 | @@ -43,6 +43,7 @@ | |
22 | endif(POLICY CMP0074) | |
23 | ||
24 | include("${CMAKE_SOURCE_DIR}/cmake/WlFunctions.cmake") | |
25 | +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_HOME_DIRECTORY}/Modules) | |
26 | ||
27 | option(OPTION_USE_GLBINDING "Use glbinding instead of GLEW" OFF) | |
28 | option(OPTION_GLEW_STATIC "Use static GLEW Library" OFF) | |
29 | @@ -105,6 +106,8 @@ | |
30 | find_package(SDL2_ttf REQUIRED) | |
31 | find_package(ZLIB REQUIRED) | |
32 | find_package(ICU REQUIRED) | |
33 | +find_package(Minizip) | |
34 | + | |
35 | if(OPTION_USE_GLBINDING) | |
36 | find_package(glbinding REQUIRED) | |
37 | else() | |
38 | --- /dev/null | |
39 | +++ b/Modules/FindMinizip.cmake | |
40 | @@ -0,0 +1,37 @@ | |
41 | +# - Try to find Minizip | |
42 | +# Once done this will define | |
43 | +# | |
44 | +# MINIZIP_FOUND - system has MINIZIP | |
45 | +# MINIZIP_INCLUDE_DIR - the MINIZIP include directory | |
46 | +# MINIZIP_LIBRARY_DIR - where the libraries are | |
47 | +# MINIZIP_LIBRARY - Link these to use MINIZIP | |
48 | +# | |
49 | + | |
50 | +IF (MINIZIP_INCLUDE_DIR) | |
51 | + # Already in cache, be silent | |
52 | + SET(MINIZIP_FIND_QUIETLY TRUE) | |
53 | +ENDIF (MINIZIP_INCLUDE_DIR) | |
54 | + | |
55 | +FIND_PATH( MINIZIP_INCLUDE_DIR | |
56 | + NAMES zip.h unzip.h ioapi.h | |
57 | + PATHS /usr/local/include /usr/include | |
58 | + PATH_SUFFIXES minizip/ ) | |
59 | +SET( MINIZIP_NAMES minizip MINIZIP ) | |
60 | +FIND_LIBRARY( MINIZIP_LIBRARY | |
61 | + NAMES ${MINIZIP_NAMES} | |
62 | + PATHS /usr/lib /usr/local/lib ) | |
63 | + | |
64 | +GET_FILENAME_COMPONENT( MINIZIP_LIBRARY_DIR ${MINIZIP_LIBRARY} PATH ) | |
65 | + | |
66 | +IF (MINIZIP_INCLUDE_DIR AND MINIZIP_LIBRARY) | |
67 | + SET(MINIZIP_FOUND TRUE) | |
68 | + SET(MINIZIP_LIBRARY_DIR ${MINIZIP_LIBRARY} ) | |
69 | + IF (NOT MINIZIP_FIND_QUIETLY) | |
70 | + MESSAGE (STATUS "Found Minizip: ${MINIZIP_LIBRARY} ${MINIZIP_INCLUDE_DIR}") | |
71 | + ENDIF (NOT MINIZIP_FIND_QUIETLY) | |
72 | +ELSE (MINIZIP_INCLUDE_DIR AND MINIZIP_LIBRARY) | |
73 | + SET( MINIZIP_FOUND FALSE ) | |
74 | + SET( MINIZIP_LIBRARY_DIR ) | |
75 | + SET( MINIZIP_EXTRA_DEFINITIONS ) | |
76 | +ENDIF (MINIZIP_INCLUDE_DIR AND MINIZIP_LIBRARY) | |
77 | + | |
78 | --- a/cmake/WlFunctions.cmake | |
79 | +++ b/cmake/WlFunctions.cmake | |
80 | @@ -81,6 +81,14 @@ | |
81 | if(ARG_USES_ZLIB) | |
82 | wl_include_system_directories(${NAME} ${ZLIB_INCLUDE_DIRS}) | |
83 | target_link_libraries(${NAME} ${ZLIB_LIBRARY}) | |
84 | + if (MINIZIP_FOUND) | |
85 | + wl_include_system_directories(${NAME} ${MINIZIP_INCLUDE_DIR}) | |
86 | + target_link_libraries(${NAME} ${MINIZIP_LIBRARY}) | |
87 | + target_compile_definitions(${NAME} PUBLIC -DHAVE_SYSTEM_MINIZIP) | |
88 | + else(MINIZIP_FOUND) | |
89 | + target_link_libraries(${NAME} third_party_minizip) | |
90 | + message(FATAL_ERROR "You are using widelands-bundled minizip sources. Please install your distribution's minizip dev library or urge your distribution maintainer to include the minizip library in your package repository. Thank you.") | |
91 | + endif(MINIZIP_FOUND) | |
92 | endif() | |
93 | ||
94 | # OpenGL and GLEW are one thing for us. If you use the one, you also use the | |
95 | --- a/src/third_party/CMakeLists.txt | |
96 | +++ b/src/third_party/CMakeLists.txt | |
97 | @@ -1,12 +1,14 @@ | |
98 | -wl_library(third_party_minizip | |
99 | - THIRD_PARTY | |
100 | - SRCS | |
101 | - minizip/ioapi.h | |
102 | - minizip/unzip.cc | |
103 | - minizip/unzip.h | |
104 | - minizip/zip.h | |
105 | - USES_ZLIB | |
106 | -) | |
107 | +if(NOT MINIZIP_FOUND) | |
108 | + wl_library(third_party_minizip | |
109 | + THIRD_PARTY | |
110 | + SRCS | |
111 | + ioapi.h | |
112 | + unzip.cc | |
113 | + unzip.h | |
114 | + zip.h | |
115 | + USES_ZLIB | |
116 | + ) | |
117 | +endif(NOT MINIZIP_FOUND) | |
118 | ||
119 | wl_library(third_party_eris | |
120 | THIRD_PARTY | |
121 | --- a/src/io/filesystem/CMakeLists.txt | |
122 | +++ b/src/io/filesystem/CMakeLists.txt | |
123 | @@ -12,6 +12,7 @@ | |
124 | zip_exceptions.h | |
125 | zip_filesystem.cc | |
126 | zip_filesystem.h | |
127 | + USES_ZLIB | |
128 | DEPENDS | |
129 | base_exceptions | |
130 | base_i18n | |
131 | @@ -19,5 +20,4 @@ | |
132 | base_macros | |
133 | graphic_text_layout | |
134 | io_stream | |
135 | - third_party_minizip | |
136 | ) | |
137 | --- a/src/io/filesystem/zip_filesystem.h | |
138 | +++ b/src/io/filesystem/zip_filesystem.h | |
139 | @@ -28,8 +28,14 @@ | |
140 | #include "io/filesystem/filesystem.h" | |
141 | #include "io/streamread.h" | |
142 | #include "io/streamwrite.h" | |
143 | + | |
144 | +#ifndef HAVE_SYSTEM_MINIZIP | |
145 | #include "third_party/minizip/unzip.h" | |
146 | #include "third_party/minizip/zip.h" | |
147 | +#else | |
148 | +#include <minizip/unzip.h> | |
149 | +#include <minizip/zip.h> | |
150 | +#endif | |
151 | ||
152 | class ZipFilesystem : public FileSystem { | |
153 | public: |