Skip to content

Commit

Permalink
fix: use zlib static (#872)
Browse files Browse the repository at this point in the history
  • Loading branch information
vansangpfiev authored Jul 11, 2024
1 parent d2332da commit a6c43c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
1 change: 0 additions & 1 deletion cortex-cpp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ pre-package:
ifeq ($(OS),Windows_NT)
@powershell -Command "mkdir -p cortex-cpp;"
@powershell -Command "cp build\cortex-cpp.exe .\cortex-cpp\;"
@powershell -Command "cp build-deps\_install\bin\zlib.dll .\cortex-cpp\;"
@powershell -Command "cp ..\.github\patches\windows\msvcp140.dll .\cortex-cpp\;"
@powershell -Command "cp ..\.github\patches\windows\vcruntime140_1.dll .\cortex-cpp\;"
@powershell -Command "cp ..\.github\patches\windows\vcruntime140.dll .\cortex-cpp\;"
Expand Down
22 changes: 14 additions & 8 deletions cortex-cpp/cortex-cpp-deps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,26 @@ set(THIRD_PARTY_INSTALL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../build-deps/_install)
#set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
#
# Add the external project
set(ZLIB_USE_STATIC_LIBS OFF)
find_package(ZLIB)
if(NOT ZLIB_FOUND)
set(ZLIB_USE_STATIC_LIBS ON)
ExternalProject_Add(
zlib
if(NOT APPLE)
ExternalProject_Add(
zlib
GIT_REPOSITORY https://github.com/madler/zlib.git
GIT_TAG v1.2.11
CMAKE_ARGS
-DBUILD_SHARED_LIBS=OFF
-DCMAKE_INSTALL_PREFIX=${THIRD_PARTY_INSTALL_PATH}
-DCMAKE_BUILD_TYPE=RELEASE
)

if(WIN32)
SET(ZLIB_DYN_PATH "${THIRD_PARTY_INSTALL_PATH}/lib/zlib.lib")
ExternalProject_Add_Step(
zlib remove_dynamic_lib
COMMAND ${CMAKE_COMMAND} -E rm -f ${ZLIB_DYN_PATH}
DEPENDEES install
)
endif()
endif()

ExternalProject_Add(
brotli
Expand Down Expand Up @@ -76,7 +82,6 @@ ExternalProject_Add(
CMAKE_ARGS
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DOPENSSL_USE_STATIC_LIBS=TRUE
-DZLIB_USE_STATIC_LIBS=${ZLIB_USE_STATIC_LIBS}
-DBUILD_ORM=OFF
-DBUILD_YAML_CONFIG=OFF
-DBUILD_EXAMPLES=OFF
Expand Down Expand Up @@ -116,8 +121,9 @@ link_directories(${THIRD_PARTY_INSTALL_PATH}/lib)
# Optionally link or add dependencies to your targets
add_dependencies(drogon c-ares jsoncpp brotli)

if(ZLIB_USE_STATIC_LIBS)
if(NOT APPLE)
add_dependencies(drogon zlib)
endif()

# target_link_libraries(<your-target> ...)

0 comments on commit a6c43c8

Please sign in to comment.