cmake --install prefix not work

https://zlib.net/zlib-1.2.11.tar.gz
I follow the steps to install the project and use the prefix in Install a Project step. But it doesnt change the install path.

cd %project%
# Generate a Project Buildsystem
cmake -G "Visual Studio 16 2019" ^
	-S . ^
	-B .\build
# Build a Project
cmake --build . --config Release
# Install a Project
cmake --install . --config Release --prefix ..\release

If I follow the steps, it can change the preifx path in Generate a Project step

cmake -G "Visual Studio 16 2019" ^
	-S . ^
	-B .\build-release ^
	-DCMAKE_INSTALL_PREFIX=..\release
cmake --build . --config Release
cmake --install . --config Release --prefix ..\release

Who knows the reason ?

That’s because some people just like to watch the world burn.
CMakeLists.txt:11-15

set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages")
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")

This is an issue with how they written their CMake file.

Yes, my PR from over 5 years ago has comments about that, but given the lack of interest…not sure how much it’s worth doing anything about it :confused: .

1 Like

It’s getting a bit off-topic, but the zlib project is known for being relatively unresponsive to contributions. The zlib-ng project is an alternative that aims to be better in that regard. It has a zlib API compatibility flag, for those who need it. Their README has more information.

1 Like