[GH-ISSUE #242] CMAKE doesn't find ZLIB_ROOT issue, maybe related to missing zlib.h in 3rd party lib #193

Closed
opened 2026-05-05 11:53:32 -06:00 by gitea-mirror · 6 comments
Owner

Originally created by @GordonEldest on GitHub (Aug 29, 2019).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/242

Originally assigned to: @jmcnamara on GitHub.

Good lib but Not easy to use the Visual GUI of CMAKE (VS2017 x64 CMAKE 3.10.2)

Major CMAKE issues related to ZLIB
A non fatal ZLIB_ROOT Env not defined (Not everybody define Zlib as an env path) but non blocking
I was eventually able to make it running but by patching in hard de CmakeFile.txt wit ZLIB

SET($ENV{ZLIB_ROOT} "../libzlib/")
SET(ZLIB_ROOT "../libzlib/")
SET(ZLIB_LIBRARY "../libzlib/")
SET(ZLIB_INCLUDE_DIR "../libzlib/")
SET(MINIZIP_INCLUDE_DIR "./third_party/minizip/")
SET(MINIZIP_LIBRARY "./third_party/minizip/")

WARNING theses path are specific to my config
Not enough knowledege of CMAKE arcan to cross check minimal modif to make it running

Latest issue is missing zlib.h in 3rd party minizip,
(minizip is not ought to contain this header but zip.c call it)
=> Checking "USE_SYSTEM_MINIZIP" seems missleading as ZLIB is mandatory

Suggestion:
Remove reference to USE_SYSTEM_MINIZIP (and explain that a zlib.lib is needed)
or include zlib.h in thirdparty
or see if zlib.h is really needed in zip,c (seems so as stream struct is not defined anywhere else)

Without any patch------------>

Selecting Windows SDK version 10.0.17763.0 to target Windows 6.1.7601.
CMake Error at C:/Program Files/CMake/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake/share/cmake-3.10/Modules/FindZLIB.cmake:112 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:161 (find_package)

Configuring incomplete, errors occurred!
See also "D:/SourcesWorkip/Lib/libxlsx/libxlsxwriter-master/build/CMakeFiles/CMakeOutput.log".

With patch but WITH USE_SYSTEM_MINIZIP checked--------------->

zlib version: 
CMake Error at cmake/FindMINIZIP.cmake:93 (file):
  file STRINGS file
  "D:/SourcesWorkip/Lib/libxlsx/libxlsxwriter-master/third_party/minizip//zlib.h"
  cannot be read.
Call Stack (most recent call first):
  CMakeLists.txt:179 (find_package)
Originally created by @GordonEldest on GitHub (Aug 29, 2019). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/242 Originally assigned to: @jmcnamara on GitHub. Good lib but Not easy to use the Visual GUI of CMAKE (VS2017 x64 CMAKE 3.10.2) Major CMAKE issues related to ZLIB A non fatal ZLIB_ROOT Env not defined (Not everybody define Zlib as an env path) but non blocking I was eventually able to make it running but by patching in hard de CmakeFile.txt wit ZLIB ``` SET($ENV{ZLIB_ROOT} "../libzlib/") SET(ZLIB_ROOT "../libzlib/") SET(ZLIB_LIBRARY "../libzlib/") SET(ZLIB_INCLUDE_DIR "../libzlib/") SET(MINIZIP_INCLUDE_DIR "./third_party/minizip/") SET(MINIZIP_LIBRARY "./third_party/minizip/") ``` WARNING theses path are specific to my config Not enough knowledege of CMAKE arcan to cross check minimal modif to make it running Latest issue is missing zlib.h in 3rd party minizip, (minizip is not ought to contain this header but zip.c call it) => Checking "USE_SYSTEM_MINIZIP" seems missleading as ZLIB is mandatory Suggestion: Remove reference to USE_SYSTEM_MINIZIP (and explain that a zlib.lib is needed) or include zlib.h in thirdparty or see if zlib.h is really needed in zip,c (seems so as stream struct is not defined anywhere else) Without any patch------------> ``` Selecting Windows SDK version 10.0.17763.0 to target Windows 6.1.7601. CMake Error at C:/Program Files/CMake/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message): Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR) Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE) C:/Program Files/CMake/share/cmake-3.10/Modules/FindZLIB.cmake:112 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:161 (find_package) Configuring incomplete, errors occurred! See also "D:/SourcesWorkip/Lib/libxlsx/libxlsxwriter-master/build/CMakeFiles/CMakeOutput.log". ``` With patch but WITH USE_SYSTEM_MINIZIP checked---------------> ``` zlib version: CMake Error at cmake/FindMINIZIP.cmake:93 (file): file STRINGS file "D:/SourcesWorkip/Lib/libxlsx/libxlsxwriter-master/third_party/minizip//zlib.h" cannot be read. Call Stack (most recent call first): CMakeLists.txt:179 (find_package) ```
gitea-mirror 2026-05-05 11:53:32 -06:00
  • closed this issue
  • added the
    bug
    cmake
    labels
Author
Owner

@John-Colvin commented on GitHub (Aug 30, 2019):

What was the full cmake command you used?

<!-- gh-comment-id:526589100 --> @John-Colvin commented on GitHub (Aug 30, 2019): What was the full cmake command you used?
Author
Owner

@jmcnamara commented on GitHub (Aug 31, 2019):

@Alexhuszagh or @evanmiller could you take a look at this Libxlsxwriter CMake/Zlib issue and maybe also #243. Thanks.

<!-- gh-comment-id:526837629 --> @jmcnamara commented on GitHub (Aug 31, 2019): @Alexhuszagh or @evanmiller could you take a look at this Libxlsxwriter CMake/Zlib issue and maybe also #243. Thanks.
Author
Owner

@Alexhuszagh commented on GitHub (Sep 3, 2019):

Taking a look, it might take me a few days to fully get to this project, but I'll try now.

<!-- gh-comment-id:527493600 --> @Alexhuszagh commented on GitHub (Sep 3, 2019): Taking a look, it might take me a few days to fully get to this project, but I'll try now.
Author
Owner

@Alexhuszagh commented on GitHub (Sep 3, 2019):

@GordonEldest You shouldn't need to set it as an environment variable, and you should never use relative paths in CMake since they're not guaranteed to be invoked from the same directory.

Say you you have the following package structure:

- parent folder
  - libzlib
  - project
    - CMakeLists.txt

We can invoke CMake from any folder, and relative paths are treated as relative to the working directory from which CMake is run. Therefore, ../libzlib run from parent folder/project/build will point to parent folder/project/libzlib, and not parent folder/libzlib, as you may have intended. To fix this, check the following code sample:

# Do not do this.
SET($ENV{ZLIB_ROOT} "../libzlib/")
# Do this (you can also use `${CMAKE_CURRENT_SOURCE_DIR}`
SET(ZLIB_ROOT, "${PROJECT_SOURCE_DIR}/../libzlib")

Let me know if that doesn't solve your issues, I'll try to get a working example up shortly. We're currently suffering a CMake backwards compatibility (for CMake versions >= 3.12.0) issue as well, so that might be an additional issue as well.

<!-- gh-comment-id:527496692 --> @Alexhuszagh commented on GitHub (Sep 3, 2019): @GordonEldest You shouldn't need to set it as an environment variable, and you should never use relative paths in CMake since they're not guaranteed to be invoked from the same directory. Say you you have the following package structure: ```markdown - parent folder - libzlib - project - CMakeLists.txt ``` We can invoke CMake from any folder, and relative paths are treated as relative to the working directory from which CMake is run. Therefore, `../libzlib` run from `parent folder/project/build` will point to `parent folder/project/libzlib`, and not `parent folder/libzlib`, as you may have intended. To fix this, check the following code sample: ```cmake # Do not do this. SET($ENV{ZLIB_ROOT} "../libzlib/") # Do this (you can also use `${CMAKE_CURRENT_SOURCE_DIR}` SET(ZLIB_ROOT, "${PROJECT_SOURCE_DIR}/../libzlib") ``` Let me know if that doesn't solve your issues, I'll try to get a working example up shortly. We're currently suffering a CMake backwards compatibility (for CMake versions >= 3.12.0) issue as well, so that might be an additional issue as well.
Author
Owner

@jmcnamara commented on GitHub (Sep 5, 2019):

@GordonEldest Can you test the proposed fix.

<!-- gh-comment-id:528253301 --> @jmcnamara commented on GitHub (Sep 5, 2019): @GordonEldest Can you test the proposed fix.
Author
Owner

@jmcnamara commented on GitHub (Sep 8, 2019):

@GordonEldest I'm closing this issue. You can test against the current master to see if your issue is fixed. If it isn't then open a new issue, with details on how to reproduce, or post a follow-up here.

<!-- gh-comment-id:529231117 --> @jmcnamara commented on GitHub (Sep 8, 2019): @GordonEldest I'm closing this issue. You can test against the current master to see if your issue is fixed. If it isn't then open a new issue, with details on how to reproduce, or post a follow-up here.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/libxlsxwriter#193
No description provided.