Hey everyone. I’m compiling hdf5 as a part of a project and want to link it with my own zlib. The problem is that cmake always tries to link it with /usr/lib64/libz.a, even though I specify my own zlib. Notice that in the command below the paths ZLIB_ROOT, ZLIB_LIBRARIES and ZLIB_INCLUDE_DIRS are set correctly to my project under /home/manuel/Programs/mycfs/master.
/usr/bin/cmake -DCMAKE_INSTALL_PREFIX:PATH=/home/manuel/Programs/mycfs/master -DCMAKE_INSTALL_LIBDIR:PATH=/home/manuel/Programs/mycfs/master/lib -DCMAKE_COLOR_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_RANLIB:FILEPATH=/usr/bin/ranlib -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/cc "-DCMAKE_C_FLAGS:STRING= -m64 -O3 -w -Wno-everything -Wno-int-conversion -Wno-implicit-function-declaration -Wno-implicit-int" -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++ "-DCMAKE_CXX_FLAGS:STRING= -m64 -O3 -w -Wno-everything" -DHDF5_INSTALL_BIN_DIR:PATH=bin -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_TESTING:BOOL=OFF -DHDF5_BUILD_CPP_LIB:BOOL=ON -DHDF5_BUILD_HL_LIB:BOOL=ON -DHDF5_BUILD_FORTRAN:BOOL=OFF -DHDF5_BUILD_EXAMPLES:BOOL=OFF -DHDF5_ENABLE_HSIZET:BOOL=OFF -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=ON -DZLIB_ROOT:PATH=/home/manuel/Programs/mycfs/master -DZLIB_LIBRARIES:FILEPATH=/home/manuel/Programs/mycfs/master/lib/libz.a -DZLIB_INCLUDE_DIRS:PATH=/home/manuel/Programs/mycfs/master/include -DHDF5_BUILD_TOOLS:BOOL=OFF -DH5_HAVE_STRDUP:BOOL=OFF -DCMAKE_POLICY_DEFAULT_CMP0075=NEW -DCMAKE_POLICY_DEFAULT_CMP0074=NEW "-GUnix Makefiles" -S /home/manuel/Programs/mycfs/master/cfsdeps/hdf5/src/hdf5 -B /home/manuel/Programs/mycfs/master/cfsdeps/hdf5/src/hdf5-build
After running the command the following error occurs:
CMake Error at /usr/lib64/cmake/ZLIB/ZLIB.cmake:81 (message):
The imported target "ZLIB::zlibstatic" references the file
"/usr/lib64/libz.a"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib64/cmake/ZLIB/ZLIB.cmake"
but not all the files it references.
Call Stack (most recent call first):
/usr/lib64/cmake/ZLIB/zlib-config.cmake:44 (include)
CMakeFilters.cmake:44 (find_package)
CMakeLists.txt:580 (include)
Here is a snipped from the CMakeCache.txt:
//The directory containing a CMake configuration file for ZLIB.
ZLIB_DIR:PATH=/usr/lib64/cmake/ZLIB
//No help, variable specified on the command line.
ZLIB_INCLUDE_DIRS:PATH=/home/manuel/Programs/mycfs/master/include
//No help, variable specified on the command line.
ZLIB_LIBRARIES:FILEPATH=/home/manuel/Programs/mycfs/master/lib/libz.a
//No help, variable specified on the command line.
ZLIB_ROOT:PATH=/home/manuel/Programs/mycfs/master
I’m doing this on Fedora 40. Everything works fine until one installs zlib-ng-compat-devel
, which adds libraries and headers under /usr/lib64/cmake/ZLIB. Has anybody an idea why cmake tries to use the system’s libz.a instead of my own?
P.S.: specifying -DZLIB_DIR doesn’t work as well… It doesn’t affect the ZLIB_DIR in the CMakeCache.txt
P.P.S.: Of course removing zlib-ng-compat-devel or renaming/deleting zlib-config.cmake works, but I would like to keep the system as it is.