From a6c43c86966438c5a2aaebb8d1dd3f06f62f70b7 Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Thu, 11 Jul 2024 17:59:51 +0700 Subject: [PATCH] fix: use zlib static (#872) --- cortex-cpp/Makefile | 1 - cortex-cpp/cortex-cpp-deps/CMakeLists.txt | 22 ++++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/cortex-cpp/Makefile b/cortex-cpp/Makefile index ef703c60c..83c3f61f1 100644 --- a/cortex-cpp/Makefile +++ b/cortex-cpp/Makefile @@ -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\;" diff --git a/cortex-cpp/cortex-cpp-deps/CMakeLists.txt b/cortex-cpp/cortex-cpp-deps/CMakeLists.txt index b28c48d19..b610d1c3d 100644 --- a/cortex-cpp/cortex-cpp-deps/CMakeLists.txt +++ b/cortex-cpp/cortex-cpp-deps/CMakeLists.txt @@ -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 @@ -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 @@ -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( ...)