From e4f130ab6cc19766c8bda7b425b04d0d1c9afaf3 Mon Sep 17 00:00:00 2001 From: Zedong Peng Date: Mon, 19 Jan 2026 10:21:17 -0500 Subject: [PATCH 1/2] fetch ZLIB if missing --- CMakeLists.txt | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f22cdf..e84bc83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,38 @@ cmake_dependent_option(CUPDLPX_BUILD_TESTS "Build the cuPDLPx test suite" OFF # ----------------------------------------------------------------------------- # Core dependencies (required for Julia/Yggdrasil and Python) find_package(CUDAToolkit REQUIRED) -find_package(ZLIB REQUIRED) + +include(FetchContent) +# 1. Try to find ZLIB in the system first (Standard for Linux/Mac) +find_package(ZLIB QUIET) + +if(ZLIB_FOUND) + message(STATUS "Found System ZLIB: ${ZLIB_LIBRARIES}") +else() + # 2. If not found (Common on Windows), fetch from source + message(STATUS "ZLIB not found in system. Fetching from source...") + + FetchContent_Declare( + zlib + GIT_REPOSITORY https://github.com/madler/zlib.git + GIT_TAG v1.3 + ) + FetchContent_MakeAvailable(zlib) + + # 3. Create alias ZLIB::ZLIB to match your CORE_LINK_LIBS usage + if(NOT TARGET ZLIB::ZLIB) + if(TARGET zlibstatic) + # Prefer zlibstatic to ensure static linking (avoids DLL issues on Windows) + add_library(ZLIB::ZLIB ALIAS zlibstatic) + # Expose include directories so zlib.h can be found + target_include_directories(zlibstatic INTERFACE ${zlib_SOURCE_DIR} ${zlib_BINARY_DIR}) + else() + # Fallback if the target is simply named 'zlib' + add_library(ZLIB::ZLIB ALIAS zlib) + target_include_directories(zlib INTERFACE ${zlib_SOURCE_DIR} ${zlib_BINARY_DIR}) + endif() + endif() +endif() if (CUPDLPX_BUILD_PYTHON) # Dependencies required only for Python bindings @@ -75,8 +106,6 @@ if (CUPDLPX_BUILD_PYTHON) find_package(Python3 COMPONENTS Interpreter REQUIRED) # For versioning script and pybind11 endif() -include(FetchContent) - set(PSLP_VERSION_TAG "v0.0.4") FetchContent_Declare( From 52278e88a0b5fffe41c6ff5083bc0fa206e0530b Mon Sep 17 00:00:00 2001 From: Bo Tang Date: Wed, 21 Jan 2026 15:19:56 -0500 Subject: [PATCH 2/2] Bug fixed: specify compile flags --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e84bc83..7dd01bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,10 @@ else() endif() # Global Compile flags (corresponding to CFLAGS/NVCCFLAGS) -add_compile_options(-fPIC -O3 -Wall -Wextra -g) +add_compile_options(-O3 -Wall -Wextra -g) +if (NOT WIN32) + add_compile_options(-fPIC) +endif() # Windows compatibility if (WIN32)