jmcnamara / libxlsxwriter

A C library for creating Excel XLSX files.
https://libxlsxwriter.github.io
Other
1.48k stars 332 forks source link

Build fail with CMake 3.26.3 while trying to find zlib #398

Closed ivspenna closed 1 year ago

ivspenna commented 1 year ago

The syntax of find_package in CMakeLists.txt will result in failure while trying to find zlib :

 $ cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON  ..
CMake Warning (dev) at /usr/share/cmake/Modules/FindZLIB.cmake:88 (message):
  ZLIB does not provide any COMPONENTS.  Calling

    find_package(ZLIB COMPONENTS ...)

  will always fail.
Call Stack (most recent call first):
  CMakeLists.txt:222 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find ZLIB (missing: 1.0) (found version "1.2.13")
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake/Modules/FindZLIB.cmake:200 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:222 (find_package)

-- Configuring incomplete, errors occurred!

I used the following syntax :

+++ CMakeLists.txt      2023-04-12 16:25:10.889028467 -0300
@@ -219,13 +219,13 @@
 list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

 # ZLIB
-find_package(ZLIB REQUIRED "1.0")
+find_package(ZLIB "1.0" REQUIRED)
 list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})
 message("zlib version: " ${ZLIB_VERSION})

 # MINIZIP
 if (USE_SYSTEM_MINIZIP)
-    find_package(MINIZIP REQUIRED "1.0")
+    find_package(MINIZIP "1.0" REQUIRED)
     list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${MINIZIP_INCLUDE_DIRS})
 endif()
jmcnamara commented 1 year ago

Thanks for the report. I'll fix it soon.