From 593f70eb8a7fef3a454bc27eec81f5d42313cf7c Mon Sep 17 00:00:00 2001 From: Petar Vutov Date: Fri, 15 May 2026 12:13:10 +0200 Subject: [PATCH 1/2] cmake: Fix installation failure when CMAKE_INSTALL_PREFIX is changed zlib is using absolute paths with the install command, which is bad practice. Installation paths should be relative, allowing cmake to resolve them relative to CMAKE_INSTALL_PREFIX. --- lib/zlib/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/zlib/CMakeLists.txt b/lib/zlib/CMakeLists.txt index 15ceebe78..f18c242fe 100644 --- a/lib/zlib/CMakeLists.txt +++ b/lib/zlib/CMakeLists.txt @@ -7,11 +7,11 @@ set(VERSION "1.3.1") option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON) -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") +set(INSTALL_BIN_DIR "bin" CACHE PATH "Installation directory for executables") +set(INSTALL_LIB_DIR "lib" CACHE PATH "Installation directory for libraries") +set(INSTALL_INC_DIR "include" CACHE PATH "Installation directory for headers") +set(INSTALL_MAN_DIR "share/man" CACHE PATH "Installation directory for manual pages") +set(INSTALL_PKGCONFIG_DIR "share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") include(CheckTypeSize) include(CheckFunctionExists) From 929d24b1c8dccc27a7272208ca55eb845f7297d7 Mon Sep 17 00:00:00 2001 From: Petar Vutov Date: Fri, 15 May 2026 12:19:59 +0200 Subject: [PATCH 2/2] zlib: Remove unnecessary cmake variables CMake is not a generic programming language. Unnecessary variables should be avoided. For example, if a variable name is misspelled, cmake will happily resolve it to an empty string. In addition, unnecessary cache variables make it difficult for users to configure the project (tyranny of choice). Cache variables should be limited to things that a user might reasonably want to customize. It makes no sense to offer installing libs to a place other than "lib", or binaries to a place other than "bin". "make install" is supposed to provide a standard install structure. --- lib/zlib/CMakeLists.txt | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/zlib/CMakeLists.txt b/lib/zlib/CMakeLists.txt index f18c242fe..a21d8df6b 100644 --- a/lib/zlib/CMakeLists.txt +++ b/lib/zlib/CMakeLists.txt @@ -7,12 +7,6 @@ set(VERSION "1.3.1") option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON) -set(INSTALL_BIN_DIR "bin" CACHE PATH "Installation directory for executables") -set(INSTALL_LIB_DIR "lib" CACHE PATH "Installation directory for libraries") -set(INSTALL_INC_DIR "include" CACHE PATH "Installation directory for headers") -set(INSTALL_MAN_DIR "share/man" CACHE PATH "Installation directory for manual pages") -set(INSTALL_PKGCONFIG_DIR "share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") - include(CheckTypeSize) include(CheckFunctionExists) include(CheckIncludeFile) @@ -180,18 +174,18 @@ endif() if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) install(TARGETS zlib zlibstatic - RUNTIME DESTINATION "${INSTALL_BIN_DIR}" - ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ) + RUNTIME DESTINATION "bin" + ARCHIVE DESTINATION "lib" + LIBRARY DESTINATION "lib" ) endif() if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) - install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}") + install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "include") endif() if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) - install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3") + install(FILES zlib.3 DESTINATION "share/man/man3") endif() if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) - install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}") + install(FILES ${ZLIB_PC} DESTINATION "share/pkgconfig") endif() #============================================================================