Skip to content

Commit

Permalink
build: fix minizip build for cmake
Browse files Browse the repository at this point in the history
Issue #471
  • Loading branch information
jmcnamara committed Feb 26, 2025
1 parent f63ed56 commit 58248a0
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 375 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/cmake_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ jobs:
sudo apt-get -y install libssl-dev
- name: Configure CMake
working-directory: ${{ github.workspace }}/cmake
run: cmake .. -DBUILD_TESTS=ON ${{ matrix.cmake_flags }} -DCMAKE_BUILD_TYPE=Release
run: |
mkdir build
cd build
cmake .. -DBUILD_TESTS=ON ${{ matrix.cmake_flags }} -DCMAKE_BUILD_TYPE=Release
- name: Build
working-directory: ${{ github.workspace }}/cmake
run: cmake --build . --config Release --parallel
run: |
cd build
cmake --build . --config Release --parallel
- name: Test
working-directory: ${{ github.workspace }}/cmake
run: ctest -C Release -V
run: |
cd build
ctest -C Release -V
13 changes: 7 additions & 6 deletions .github/workflows/windows_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
matrix:
cmake_flags: ["-DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON",
"-DUSE_DTOA_LIBRARY=ON -DBUILD_TESTS=ON",
#"-DUSE_SYSTEM_MINIZIP=ON -DBUILD_TESTS=ON",
#"-DUSE_SYSTEM_MINIZIP=ON -DUSE_OPENSSL_MD5=ON -DBUILD_TESTS=ON",
"-DUSE_SYSTEM_MINIZIP=ON -DBUILD_TESTS=ON",
"-DUSE_SYSTEM_MINIZIP=ON -DUSE_OPENSSL_MD5=ON -DBUILD_TESTS=ON",
"-DUSE_OPENSSL_MD5=ON -DBUILD_TESTS=ON",
]

Expand All @@ -33,22 +33,23 @@ jobs:
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: cmd
run: |
cd cmake
mkdir build
cd build
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
cmake .. -DCMAKE_BUILD_TYPE=Release ${{ matrix.cmake_flags }} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -A x64
- name: Build
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: cmd
run: |
cd cmake
cd build
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
cmake --build . --config Release
- name: Test
working-directory: ${{env.GITHUB_WORKSPACE}}
shell: cmd
run: |
cd cmake
copy test\functional\src\Release\*.exe test\functional\src
cd build
copy test\functional\src\Release\*.* test\functional\src
pytest -v test/functional
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ third_party/zlib-1.2.8/minigzip
third_party/zlib-1.2.8/minigzipsh
third_party/zlib-1.2.8/zlib.pc

cmake
!cmake/FindMINIZIP.cmake
!cmake/FindPackage.cmake
!cmake/i686-toolchain.cmake

.vscode

*zig-cache/
Expand Down
58 changes: 19 additions & 39 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,6 @@ endif()
# -------------------------
# Configure the compilation
# -------------------------
if(NOT MSVC)
find_package(PkgConfig)
endif()

if(USE_SYSTEM_MINIZIP)
list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS USE_SYSTEM_MINIZIP)
Expand Down Expand Up @@ -307,36 +304,25 @@ enable_language(CXX)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

# Set the zlib includes.
if(PKG_CONFIG_FOUND)
pkg_check_modules(ZLIB zlib)
list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})
endif()
if(NOT ZLIB_FOUND)
find_package(ZLIB "1.0" REQUIRED)
list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})
endif()
find_package(ZLIB "1.2.8" REQUIRED)
list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})

# Set the minizip includes.
if(USE_SYSTEM_MINIZIP)
if(PKG_CONFIG_FOUND)
if(MSVC)
find_package(MINIZIP NAMES unofficial-minizip REQUIRED)
set(MINIZIP_LIBRARIES unofficial::minizip::minizip)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(MINIZIP minizip)
list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${MINIZIP_INCLUDE_DIRS}/..)
endif()
if(NOT MINIZIP_FOUND)
find_package(MINIZIP "1.0" REQUIRED)
list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${MINIZIP_INCLUDE_DIRS})
endif()
endif()

# Set the openssl includes.
if(USE_OPENSSL_MD5)
if(PKG_CONFIG_FOUND)
pkg_check_modules(LIBCRYPTO libcrypto)
include_directories(${LIBCRYPTO_INCLUDE_DIRS})
else()
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
endif()
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
endif()

# ----------------------------
Expand Down Expand Up @@ -398,25 +384,19 @@ add_library(${PROJECT_NAME} "")
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${SOVERSION})
target_sources(${PROJECT_NAME} PRIVATE ${LXW_SOURCES} PUBLIC ${LXW_HEADERS})

if(ZLIB_LDFLAGS)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${ZLIB_LDFLAGS})
else()
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${ZLIB_LIBRARIES})
endif()
if(MINIZIP_LDFLAGS)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${MINIZIP_LDFLAGS})
target_link_libraries(${PROJECT_NAME} PRIVATE ZLIB::ZLIB)

if(MINIZIP_LINK_LIBRARIES)
target_link_libraries(${PROJECT_NAME} PRIVATE ${MINIZIP_LINK_LIBRARIES})
else()
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${MINIZIP_LIBRARIES})
endif()
if(LIBCRYPTO_LDFLAGS)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${LIBCRYPTO_LDFLAGS})
else()
target_link_libraries(
${PROJECT_NAME}
LINK_PUBLIC ${LIB_CRYPTO} ${OPENSSL_CRYPTO_LIBRARY}
)
target_link_libraries(${PROJECT_NAME} PRIVATE ${MINIZIP_LIBRARIES})
endif()

target_link_libraries(
${PROJECT_NAME}
PRIVATE ${LIB_CRYPTO} ${OPENSSL_CRYPTO_LIBRARY}
)

target_compile_definitions(
${PROJECT_NAME}
PRIVATE ${LXW_PRIVATE_COMPILE_DEFINITIONS}
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ test_cpp : all
test_cmake :
ifneq ($(findstring m32,$(CFLAGS)),m32)
$(Q)$(MAKE) -C src clean
$(Q)cd cmake; cmake .. -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON; make clean; make; cp libxlsxwriter.a ../src/
$(Q)mkdir -p build
$(Q)cd build
$(Q)cmake .. -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON
$(Q)make clean; make; cp libxlsxwriter.a ../src/
$(Q)cmake/xlsxwriter_unit
$(Q)$(MAKE) -C test/functional/src
$(Q)$(PYTEST) test/functional -v -k $(PYTESTFILES)
Expand Down
121 changes: 0 additions & 121 deletions cmake/FindMINIZIP.cmake

This file was deleted.

Loading

0 comments on commit 58248a0

Please sign in to comment.