From cbbf473d5999bddadc1363aaee4832dd9413306d Mon Sep 17 00:00:00 2001 From: Tobias Frost Date: Sat, 1 Nov 2014 14:13:16 +0100 Subject: [PATCH] patch to use system's zlib when enabled by the CMake option USE_SYSTEM_ZLIB --- neo/CMakeLists.txt | 25 ++++++++++++++++++++++++- neo/framework/File_SaveGame.h | 2 +- neo/framework/Zip.h | 4 ++-- neo/swf/SWF_Zlib.cpp | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index 062a9fa5..fb3b8d0c 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -21,6 +21,9 @@ option(FFMPEG option(ONATIVE "Optimize for the host CPU" OFF) +option(USE_SYSTEM_ZLIB + "Use the system zlib instead of the bundled one" OFF) + if(UNIX) set(OPENAL TRUE) endif() @@ -179,6 +182,18 @@ endif() # add_definitions(-DSTANDALONE) #endif() +if (USE_SYSTEM_ZLIB) + find_package(ZLIB REQUIRED) +endif(USE_SYSTEM_ZLIB) + +if (ZLIB_FOUND) + include_directories(${ZLIB_INCLUDE_DIRS}) + set(ZLIB_LIBRARY ${ZLIB_LIBRARIES}) +else (ZLIB_FOUND) + include_directories("libs/zlib") + set(ZLIB_LIBRARY "" ) +endif (ZLIB_FOUND) + add_subdirectory(idlib) file(GLOB AAS_INCLUDES aas/*.h) @@ -379,8 +394,14 @@ set(JPEG_SOURCES file(GLOB PNG_INCLUDES libs/png/*.h) file(GLOB PNG_SOURCES libs/png/*.c) +if (NOT ZLIB_FOUND) file(GLOB ZLIB_INCLUDES libs/zlib/*.h) file(GLOB ZLIB_SOURCES libs/zlib/*.c) +else (NOT ZLIB_FOUND) + set(ZLIB_INCLUDES "") + set(ZLIB_SOURCES "") +endif (NOT ZLIB_FOUND) + file(GLOB MINIZIP_INCLUDES libs/zlib/minizip/*.h) file(GLOB MINIZIP_SOURCES libs/zlib/minizip/*.c libs/zlib/minizip/*.cpp) @@ -1134,7 +1155,7 @@ include_directories( #libs/openal/include libs/glew/include #libs/freetype/include - libs/zlib) + ) #link_directories( # ${CMAKE_CURRENT_SOURCE_DIR}/libs/curl/lib @@ -1312,6 +1333,7 @@ if(MSVC) wsock32.lib ${OpenAL_LIBRARIES} ${FFmpeg_LIBRARIES} + ${ZLIB_LIBRARY} ) #CMAKE_BINARY_DIR @@ -1473,6 +1495,7 @@ else() ${SDLx_LIBRARY} ${OPENAL_LIBRARY} ${FFMPEG_LIBRARIES} + ${ZLIB_LIBRARY} ) endif() diff --git a/neo/framework/File_SaveGame.h b/neo/framework/File_SaveGame.h index ef3f9cd4..497df898 100644 --- a/neo/framework/File_SaveGame.h +++ b/neo/framework/File_SaveGame.h @@ -28,7 +28,7 @@ If you have questions concerning this license or the applicable additional terms #ifndef __FILE_SAVEGAME_H__ #define __FILE_SAVEGAME_H__ -#include "../libs/zlib/zlib.h" +#include // Listing of the types of files within a savegame package enum saveGameType_t diff --git a/neo/framework/Zip.h b/neo/framework/Zip.h index 2a90f9db..092bb503 100644 --- a/neo/framework/Zip.h +++ b/neo/framework/Zip.h @@ -28,10 +28,10 @@ If you have questions concerning this license or the applicable additional terms #ifndef __ZIP_H__ #define __ZIP_H__ -#include "../libs/zlib/zlib.h" +#include // DG: all the zip access stuff from minizip is now in minizip/zip.h -#include "minizip/zip.h" +#include "libs/zlib/minizip/zip.h" /* diff --git a/neo/swf/SWF_Zlib.cpp b/neo/swf/SWF_Zlib.cpp index 4dd86484..e3ed8d6a 100644 --- a/neo/swf/SWF_Zlib.cpp +++ b/neo/swf/SWF_Zlib.cpp @@ -27,7 +27,7 @@ If you have questions concerning this license or the applicable additional terms */ #pragma hdrstop #include "precompiled.h" -#include "../libs/zlib/zlib.h" +#include /* ========================