mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-11 17:37:53 +00:00
Respect static for zlib with CMake
This commit is contained in:
parent
759dfb28ce
commit
9d70851eb9
@ -238,8 +238,12 @@ if (NOT ZLIB_FOUND )
|
|||||||
include( ExternalProject )
|
include( ExternalProject )
|
||||||
ExternalProject_Add(zlib-project
|
ExternalProject_Add(zlib-project
|
||||||
URL http://zlib.net/zlib-1.2.8.tar.gz
|
URL http://zlib.net/zlib-1.2.8.tar.gz
|
||||||
|
URL_MD5 44d667c142d7cda120332623eab69f40
|
||||||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/zlib
|
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/zlib
|
||||||
|
# patch on Windows might be found in C:/Program Files/Git/usr/bin
|
||||||
|
PATCH_COMMAND patch -p0 < ${CMAKE_CURRENT_SOURCE_DIR}/cmake-zlib-static.patch
|
||||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
||||||
|
-DWITH_STATIC=${WITH_STATIC}
|
||||||
-DAMD64=ON -DASM686=ON "-DCMAKE_ASM_MASM_FLAGS=/W0 /safeseh"
|
-DAMD64=ON -DASM686=ON "-DCMAKE_ASM_MASM_FLAGS=/W0 /safeseh"
|
||||||
)
|
)
|
||||||
if (WITH_PCH)
|
if (WITH_PCH)
|
||||||
@ -249,9 +253,14 @@ if (NOT ZLIB_FOUND )
|
|||||||
endif ()
|
endif ()
|
||||||
# ExternalProject_Get_Property(zlib-project install_dir)
|
# ExternalProject_Get_Property(zlib-project install_dir)
|
||||||
set ( ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/zlib/include" CACHE FILEPATH "zlib include dir" FORCE)
|
set ( ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/zlib/include" CACHE FILEPATH "zlib include dir" FORCE)
|
||||||
set ( ZLIB_LIBRARY debug zlibd optimized zlib CACHE STRING "zlib libraries" FORCE)
|
if (NOT WITH_STATIC)
|
||||||
|
set ( ZLIB_LIBRARY debug zlibd optimized zlib CACHE STRING "zlib libraries" FORCE)
|
||||||
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
link_directories("${CMAKE_CURRENT_BINARY_DIR}/zlib/lib")
|
if (WITH_STATIC AND (MSVC OR MSYS))
|
||||||
|
set ( ZLIB_LIBRARY debug zlibstaticd optimized zlibstatic CACHE STRING "zlib libraries" FORCE)
|
||||||
|
endif ()
|
||||||
|
link_directories(${CMAKE_CURRENT_BINARY_DIR}/zlib/lib ${ZLIB_ROOT}/lib)
|
||||||
|
|
||||||
# load includes
|
# load includes
|
||||||
include_directories( ${Boost_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
|
include_directories( ${Boost_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
|
||||||
|
28
build/cmake-zlib-static.patch
Normal file
28
build/cmake-zlib-static.patch
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
--- CMakeLists.txt.orig 2013-04-28 17:57:10.000000000 -0500
|
||||||
|
+++ CMakeLists.txt 2015-12-03 12:53:52.371087900 -0600
|
||||||
|
@@ -7,6 +7,7 @@
|
||||||
|
|
||||||
|
option(ASM686 "Enable building i686 assembly implementation")
|
||||||
|
option(AMD64 "Enable building amd64 assembly implementation")
|
||||||
|
+option(WITH_STATIC "Static runtime on Windows" OFF)
|
||||||
|
|
||||||
|
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
|
||||||
|
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
|
||||||
|
@@ -66,6 +67,17 @@
|
||||||
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
+if(WITH_STATIC AND (MSVC OR MSYS))
|
||||||
|
+ # http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace
|
||||||
|
+ foreach(flag_var
|
||||||
|
+ CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||||
|
+ CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
|
||||||
|
+ if(${flag_var} MATCHES "/MD")
|
||||||
|
+ string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||||
|
+ endif(${flag_var} MATCHES "/MD")
|
||||||
|
+ endforeach(flag_var)
|
||||||
|
+endif()
|
||||||
|
+
|
||||||
|
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
||||||
|
# If we're doing an out of source build and the user has a zconf.h
|
||||||
|
# in their source tree...
|
Loading…
Reference in New Issue
Block a user