From bfddac7b901ffc0a0c28d730d95f13e0d793f023 Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Thu, 11 Jul 2024 17:29:44 +0700 Subject: [PATCH 1/3] fix: use zlib static --- cortex-cpp/cortex-cpp-deps/CMakeLists.txt | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cortex-cpp/cortex-cpp-deps/CMakeLists.txt b/cortex-cpp/cortex-cpp-deps/CMakeLists.txt index b28c48d19..6a55434e1 100644 --- a/cortex-cpp/cortex-cpp-deps/CMakeLists.txt +++ b/cortex-cpp/cortex-cpp-deps/CMakeLists.txt @@ -19,18 +19,22 @@ 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 +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() @@ -76,7 +80,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 @@ -114,10 +117,7 @@ endif() include_directories(${THIRD_PARTY_INSTALL_PATH}/include) link_directories(${THIRD_PARTY_INSTALL_PATH}/lib) # Optionally link or add dependencies to your targets -add_dependencies(drogon c-ares jsoncpp brotli) +add_dependencies(drogon c-ares jsoncpp brotli zlib) -if(ZLIB_USE_STATIC_LIBS) - add_dependencies(drogon zlib) -endif() # target_link_libraries( ...) From 1e6a59187c0fc5c4c829d0d5556f4910efc3c021 Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Thu, 11 Jul 2024 17:37:26 +0700 Subject: [PATCH 2/3] fix: exclude macOS --- cortex-cpp/cortex-cpp-deps/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cortex-cpp/cortex-cpp-deps/CMakeLists.txt b/cortex-cpp/cortex-cpp-deps/CMakeLists.txt index 6a55434e1..b610d1c3d 100644 --- a/cortex-cpp/cortex-cpp-deps/CMakeLists.txt +++ b/cortex-cpp/cortex-cpp-deps/CMakeLists.txt @@ -19,6 +19,7 @@ set(THIRD_PARTY_INSTALL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../build-deps/_install) #set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) # # Add the external project +if(NOT APPLE) ExternalProject_Add( zlib GIT_REPOSITORY https://github.com/madler/zlib.git @@ -37,6 +38,7 @@ if(WIN32) DEPENDEES install ) endif() +endif() ExternalProject_Add( brotli @@ -117,7 +119,11 @@ endif() include_directories(${THIRD_PARTY_INSTALL_PATH}/include) link_directories(${THIRD_PARTY_INSTALL_PATH}/lib) # Optionally link or add dependencies to your targets -add_dependencies(drogon c-ares jsoncpp brotli zlib) +add_dependencies(drogon c-ares jsoncpp brotli) + +if(NOT APPLE) + add_dependencies(drogon zlib) +endif() # target_link_libraries( ...) From b91d071b0d216be5b66da6477f7b33bc67bb9227 Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Thu, 11 Jul 2024 17:43:07 +0700 Subject: [PATCH 3/3] fix: do not pack zlib.dll --- cortex-cpp/Makefile | 1 - 1 file changed, 1 deletion(-) 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\;"