CMake drop non-standard variables
This is a proposed Change for Fedora Linux.
This document represents a proposed Change. As part of the Changes process, proposals are publicly announced in order to receive community feedback. This proposal will only be implemented if approved by the Fedora Engineering Steering Committee.
Summary
Drop variables that are not standardized by CMake in the %cmake
macro. The dropped options are-DINCLUDE_INSTALL_DIR
, -DLIB_INSTALL_DIR
, -DSYSCONF_INSTALL_DIR
, -DSHARE_INSTALL_PREFIX
and -DLIB_SUFFIX
. Affected projects are tracked in this copr repo, please check if your packages are failing there.
Owner
- Name: Cristian Le
- Email: fedora@lecris.me
Detailed Description
The variables *_INSTALL_DIR
, SHARE_INSTALL_PREFIX
and LIB_SUFFIX
have been passed by default in the %cmake
macro, however these variables have never been standardized by CMake, and thus the definition and usage of these variables is up to the individual project, e.g. it is unclear if INCLUDE_INSTALL_DIR
is meant to be the absolute or relative path.
Since CMake 3.0, the standardized installation path is defined in GNUInstallDirs
and many distributions and packaging environment have been defining their standards in that module. Upstream projects should be migrating to this standard instead.
Migration
Compatibility with fedora releases
Any proposed changes here are compatible with any CMake versions and can be included at any point and backported to any Fedora release.
The corresponding cmake PR will not be merged until the affected packages are patched.
- As a quick fix, the affected package can manually add the corresponding variables, specifically:
%cmake \ -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \ -DLIB_INSTALL_DIR:PATH=%{_libdir} \ -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \ -DSHARE_INSTALL_PREFIX:PATH=%{_datadir} \ %if “%{?_lib}” == “lib64” %{?_cmake_lib_suffix64} \ %endif …
- Upstream projects can alter the defaults of these variables based on
GNUInstallDirs
variables, e.g.
project(…) include(GNUInstallDirs) set(LIB_INSTALL_DIR “${CMAKE_INSTALL_LIBDIR}” CACHE PATH “”)
- To replicate the
LIB_SUFFIX
the project could use:
include(GNUInstallDirs) if(CMAKE_INSTALL_LIBDIR MATCHES “lib64$”) set(LIB_SUFFIX 64) endif()
Benefit to Fedora
- Avoid packaging issue due to the current assumption that the the paths used are meant to be absolute paths.
- Encourage upstream build system modernization and standardization.
Scope
-
Proposal owners:
- Drop the non-standard CMake variables
- Try to propose appropriate fixes as much as possible
- Assist the more complicated migrations and be a point of contact for upstream issue
-
Other developers:
-
Release engineering: #Releng issue number
-
Policies and guidelines: N/A (not needed for this Change)
Upgrade/compatibility impact
Affected packages would be FTBFS (in the tracked copr repo) and would require patching before the corresponding cmake PR can be merged.
How To Test
A copr repo will be provided with these variables dropped. Use it to try local builds, e.g. using:
copr mock-config lecris/cmake-drop_vars fedora-rawhide-x86_64
If the build is successful, that should be sufficient.
Dependencies
There are currently 309/2359 packages affected gathered and built using mass-pre-build in copr, many of them are previously FTBFS in rawhide.
Contingency Plan
- Contingency mechanism: N/A (no deadline set)
- Contingency deadline: No deadline necessary yet
- Blocks release? No
Documentation
- GNUInstallDirs
- Example migrations: complex project
Release Notes
Last edited by @amoloney 2025-04-16T12:10:41Z
Last edited by @amoloney 2025-04-16T12:10:41Z