diff options
author | sfan5 <sfan5@live.de> | 2016-09-20 21:40:05 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2016-09-21 20:16:31 +0200 |
commit | af4c2107e0e893077deaec7b068b2e4e3e6932c6 (patch) | |
tree | c4bacaa6229370fd189ee95c43c96aa14bb4ef25 | |
parent | 3a57e525009ade2aa039b0bab33e4b10eda36bf4 (diff) | |
download | minetest-af4c2107e0e893077deaec7b068b2e4e3e6932c6.tar.gz minetest-af4c2107e0e893077deaec7b068b2e4e3e6932c6.tar.bz2 minetest-af4c2107e0e893077deaec7b068b2e4e3e6932c6.zip |
Don't use ZLIB_WINAPI if the required DLL is not provided to CMake
This allows you to use an stdcall zlib (zlib1.dll instead of zlibwapi.dll)
when building Minetest for win32.
-rw-r--r-- | src/CMakeLists.txt | 13 | ||||
-rw-r--r-- | src/serialization.cpp | 2 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 608437f3a..ef40bf8fc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -293,9 +293,10 @@ if(WIN32) set(ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../zlib/zlib-1.2.5" CACHE PATH "Zlib include directory") set(ZLIB_LIBRARIES "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.lib" - CACHE FILEPATH "Path to zlibwapi.lib") + CACHE FILEPATH "Path to zlib library (usually zlibwapi.lib)") set(ZLIB_DLL "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.dll" - CACHE FILEPATH "Path to zlibwapi.dll (for installation)") + CACHE FILEPATH "Path to zlib DLL (for installation)") + set(ZLIBWAPI_DLL "" CACHE FILEPATH "Path to zlibwapi DLL") set(IRRLICHT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../../irrlicht-1.7.2" CACHE PATH "irrlicht dir") if(USE_FREETYPE) @@ -723,8 +724,14 @@ else() set(OTHER_FLAGS "${OTHER_FLAGS} -Wsign-compare") endif() + if(NOT ZLIBWAPI_DLL AND CMAKE_SIZEOF_VOID_P EQUAL 4) + set(OTHER_FLAGS "${OTHER_FLAGS} -DWIN32_NO_ZLIB_WINAPI") + message(WARNING "Defaulting to cdecl for zlib on win32 because ZLIBWAPI_DLL" + " isn't set, ensure that ZLIBWAPI_DLL is set if you want stdcall.") + endif() + if(MINGW) - set(OTHER_FLAGS "-mthreads -fexceptions") + set(OTHER_FLAGS "${OTHER_FLAGS} -mthreads -fexceptions") endif() set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} ${OTHER_FLAGS} -ffast-math -Wall -pipe -funroll-loops") diff --git a/src/serialization.cpp b/src/serialization.cpp index 79f66fcae..d30e83726 100644 --- a/src/serialization.cpp +++ b/src/serialization.cpp @@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "serialization.h" #include "util/serialize.h" -#ifdef _WIN32 +#if defined(_WIN32) && !defined(WIN32_NO_ZLIB_WINAPI) #define ZLIB_WINAPI #endif #include "zlib.h" |