cmakeanaconda3xcode-command-line-toolslibzgeant4

How to update ZLIB version in MacOS CommandLine Tools from version "1.2.11" to "1.2.13" to use CMake?


I am attempting to run a Geant4 simulation installed via Conda. To do so, it requires compiling "cmake". Though all of the packages required my Geant4 are up-to-date, a set library files required by "cmake" (located in my XCode CommandLine Tools) are not. ZLIB is at version 1.2.11 but needs to be at 1.2.13.

I first attempted to fix this problem by updating my XCode CommandLine Tools (CLT) before then removing and reinstalling them. Nether process updated the ZLIB. I then attempted to install ZLIB directly from Homebrew and it appears I now have an up-to-date version (1.2.13), but this version did not translate into the CLT and only exist in the /usr/local/Cellar/zlib/1.2.13/... which makes sense. Similarly, this was also done with MacPorts and the install is stored in its associated file directory.

I worry about copying directly into CLT because none of the files match the necessary "libz.tbd" format, and I don't feel confident in modifying library files themselves. Is there another way to update ZLIB in the CommandLine Tools such that I can compile "cmake" properly?

The following is the command ran and associated error:

%cmake -DGeant4_DIR=~/.anaconda3/pkgs/geant4-11.0.3-py311h69de116_0/share/Geant4-11.0.3/ $HOME/B1/ 

CMake Error at /Applications/CMake.app/Contents/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find ZLIB: Found unsuitable version "1.2.11", but required is at
  least "1.2.13" (found
  /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/lib/libz.tbd)
Call Stack (most recent call first):
  /Applications/CMake.app/Contents/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:598 (_FPHSA_FAILURE_MESSAGE)
  /Applications/CMake.app/Contents/share/cmake-3.25/Modules/FindZLIB.cmake:166 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  /Applications/CMake.app/Contents/share/cmake-3.25/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
  /Users/ayelland/.anaconda3/envs/geant4_env/lib/Geant4-11.0.3/Geant4Config.cmake:274 (find_dependency)
  CMakeLists.txt:13 (find_package)

Note: I am running macOS Monterey 12.6.3 with a zsh kernel.


Solution

  • After some additional research on this over the past couple of weeks, the solution I have found has been to modify the environmental cmake variable like so:

    % export CMAKE_PREFIX_PATH=/usr/local/opt/zlib
    

    This allows CMake to search an alternative location for the library, where I have the 1.2.13 version of ZLIB. Given $CMAKE_PREFIX_PATH was empty before setting it in my conda environment, I don't anticipate any errors coming from this; however, I will update if I come across any.