[Pkg-cmake-team] Bug#1114681: cmake: CMake-4 weirdness with CMAKE_INSTALL_LIBDIR

Timo Röhling roehling at debian.org
Wed Sep 10 12:49:27 BST 2025


Hi IOhannes,

On Mon, 08 Sep 2025 14:57:28 +0200 
=?utf-8?q?IOhannes_m_zm=C3=B6lnig_=28Debian/GNU=29?= 
<umlaeute at debian.org> wrote:
> this works nicely with CMake-3.x.
> 
> however, for reasons unknown to me, the very same code with CMake-4.x
> installs the files to /usr/lib/$(DEB_HOST_MULTIARCH)

I looked into it, and it turns out CMake 4 gained some code in 
GNUInstallDirs.cmake to automatically update the CMAKE_INSTALL_<dir> 
variables if the CMAKE_INSTALL_PREFIX is changed after the initial 
configuration step, to deal with the special cases for the "/" and 
"/usr" prefixes (/lib/MULTIARCH, /etc, ...).

The code tries to be smart and not update the variables if they have a 
non-default value. However, "lib" happens to be the initial default for 
LIBDIR, so the CMake will happily (and wrongly) update your manually set 
variable when the CMAKE_INSTALL_PREFIX is initialized with "/usr".

I will file a bug with upstream. In the meantime, I found that using an 
equivalent but not string-equal value works around the issue. For 
example, both -DCMAKE_INSTALL_LIBDIR=./lib or 
-DMCAKE_INSTALL_LIBDIR=lib/ seem to work.


Cheers
Timo


-- 
⢀⣴⠾⠻⢶⣦⠀   ╭────────────────────────────────────────────────────╮
⣾⠁⢠⠒⠀⣿⡁   │ Timo Röhling                                       │
⢿⡄⠘⠷⠚⠋⠀   │ 9B03 EBB9 8300 DF97 C2B1  23BF CC8C 6BDD 1403 F4CA │
⠈⠳⣄⠀⠀⠀⠀   ╰────────────────────────────────────────────────────╯
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-cmake-team/attachments/20250910/18154aff/attachment.sig>


More information about the Pkg-cmake-team mailing list