Bug: Target install should allow possible absolute CMAKE_INSTALL_INCLUDEDIR

According to GNUInstallDirs an absolute CMAKE_INSTALL_INCLUDEDIR should be expected by install(TARGETS FILE_SET HEADERS).

But cmake generates configs which constructs include directories like “D:/Repositories/cmake/build/Tests/RunCMake/target_sources/FileSetAbsoluteInstallIncludeDirExport-build/install/D:/Repositories/cmake/build/Tests/RunCMake/target_sources/FileSetAbsoluteInstallIncludeDirExport-build/install/include” or “/nix/store/-//nix/store/-/include”.

Originally i discovered the issue while using NixOS, where they use absolute paths only for CMAKE_INSTALL_DIR.

-DCMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=OFF
-DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF
-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON
-DCMAKE_BUILD_TYPE=Release
-DBUILD_TESTING=OFF
-DCMAKE_INSTALL_LOCALEDIR=/nix/store/hnxnbjbcgbl8gj30bb8cd90w5l5kmzmh-my-hello/share/locale
-DCMAKE_INSTALL_LIBEXECDIR=/nix/store/hnxnbjbcgbl8gj30bb8cd90w5l5kmzmh-my-hello/libexec
-DCMAKE_INSTALL_LIBDIR=/nix/store/hnxnbjbcgbl8gj30bb8cd90w5l5kmzmh-my-hello/lib
-DCMAKE_INSTALL_DOCDIR=/nix/store/hnxnbjbcgbl8gj30bb8cd90w5l5kmzmh-my-hello/share/doc/hello
-DCMAKE_INSTALL_INFODIR=/nix/store/hnxnbjbcgbl8gj30bb8cd90w5l5kmzmh-my-hello/share/info
-DCMAKE_INSTALL_MANDIR=/nix/store/hnxnbjbcgbl8gj30bb8cd90w5l5kmzmh-my-hello/share/man
-DCMAKE_INSTALL_OLDINCLUDEDIR=/nix/store/hnxnbjbcgbl8gj30bb8cd90w5l5kmzmh-my-hello/include
-DCMAKE_INSTALL_INCLUDEDIR=/nix/store/hnxnbjbcgbl8gj30bb8cd90w5l5kmzmh-my-hello/include
-DCMAKE_INSTALL_SBINDIR=/nix/store/hnxnbjbcgbl8gj30bb8cd90w5l5kmzmh-my-hello/sbin
-DCMAKE_INSTALL_BINDIR=/nix/store/hnxnbjbcgbl8gj30bb8cd90w5l5kmzmh-my-hello/bin
-DCMAKE_INSTALL_NAME_DIR=/nix/store/hnxnbjbcgbl8gj30bb8cd90w5l5kmzmh-my-hello/lib
-DCMAKE_POLICY_DEFAULT_CMP0025=NEW
-DCMAKE_OSX_SYSROOT=
-DCMAKE_FIND_FRAMEWORK=LAST
-DCMAKE_STRIP=/nix/store/d9fndiing52fkalp5knfalrvlb3isi6w-gcc-wrapper-12.2.0/bin/strip
-DCMAKE_RANLIB=/nix/store/d9fndiing52fkalp5knfalrvlb3isi6w-gcc-wrapper-12.2.0/bin/ranlib
-DCMAKE_AR=/nix/store/d9fndiing52fkalp5knfalrvlb3isi6w-gcc-wrapper-12.2.0/bin/ar
-DCMAKE_C_COMPILER=gcc
-DCMAKE_CXX_COMPILER=g++
-DCMAKE_INSTALL_PREFIX=/nix/store/hnxnbjbcgbl8gj30bb8cd90w5l5kmzmh-my-hello

I think this is a bug in the recent 3.23 FILE_SET feature.
This contains a failing test.

Your thoughts?

Is there a reason that CMAKE_INSTALL_PREFIX and relative paths isn’t sufficient?

Cc: @kyle.edwards

Yeah, this is a bug. Go ahead and open an issue at https://gitlab.kitware.com/cmake/cmake/-/issues. I’ve opened an issue at https://gitlab.kitware.com/cmake/cmake/-/issues/25010.

I’ve opened https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8577 to fix this. @ItsBasi since you wrote the test case, how would you like to be credited in the commit message? (I see your commit message has an auto-generated GitHub email address.)