From a6f977685ec8614add007cbe69cbfbb9905789ca Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Sun, 31 May 2026 15:33:21 -0700 Subject: [PATCH 1/2] Fix installed basis.h getting source file permissions (e.g. 0600) basis.h is the only public header generated directly into the install prefix via configure_file() inside an install(CODE) block (so that LIBINT_DATADIR_ABSOLUTE reflects a --prefix override). configure_file() defaults to USE_SOURCE_PERMISSIONS, so the installed header inherits the mode of basis.h.in. When basis.h.in happens to be 0600 in the build environment (restrictive umask at checkout/extract), the installed basis.h ends up 0600, unreadable to other users. Other generated headers (e.g. config2.h) avoid this because they pass through install(FILES), which applies a fixed 0644 rather than preserving source permissions. Add NO_SOURCE_PERMISSIONS to the configure_file() so the installed basis.h always gets the standard 0644, independent of the build env. --- export/CMakeLists.txt.export | 3 ++- src/lib/libint/CMakeLists.txt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/export/CMakeLists.txt.export b/export/CMakeLists.txt.export index 061ee962e..d0c46287a 100644 --- a/export/CMakeLists.txt.export +++ b/export/CMakeLists.txt.export @@ -792,7 +792,8 @@ install(CODE " configure_file( \"${PROJECT_SOURCE_DIR}/include/libint2/basis.h.in\" \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${LIBINT2_INSTALL_INCLUDEDIR}/libint2/basis.h\" - @ONLY) + @ONLY + NO_SOURCE_PERMISSIONS) # else installed basis.h inherits basis.h.in's perms (e.g. 0600), which vary by build env ") # install bundled Boost headers if needed diff --git a/src/lib/libint/CMakeLists.txt b/src/lib/libint/CMakeLists.txt index c407c9eb2..ef8dfb35c 100644 --- a/src/lib/libint/CMakeLists.txt +++ b/src/lib/libint/CMakeLists.txt @@ -234,6 +234,7 @@ else() configure_file( \"${PROJECT_SOURCE_DIR}/include/libint2/basis.h.in\" \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/libint2/basis.h\" - @ONLY) + @ONLY + NO_SOURCE_PERMISSIONS) # else installed basis.h inherits basis.h.in's perms (e.g. 0600), which vary by build env ") endif() From b575c73698b575e943ebac4003669e253891d4fb Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Mon, 1 Jun 2026 12:29:46 -0700 Subject: [PATCH 2/2] Address review: fix basis.h staged-install DESTDIR + drop CMake 3.19-only NO_SOURCE_PERMISSIONS - configure_file into the build tree, then file(COPY ... FILE_PERMISSIONS) into the install tree, giving the installed basis.h a fixed 0644 mode without configure_file's NO_SOURCE_PERMISSIONS (which needs CMake 3.19, but the exported project declares cmake_minimum_required 3.16). - prepend $ENV{DESTDIR} in the in-tree src/lib/libint copy too, so staged installs write into the staging root rather than the real prefix (matching the exported-library template). --- export/CMakeLists.txt.export | 16 ++++++++++++---- src/lib/libint/CMakeLists.txt | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/export/CMakeLists.txt.export b/export/CMakeLists.txt.export index d0c46287a..9fcff3a88 100644 --- a/export/CMakeLists.txt.export +++ b/export/CMakeLists.txt.export @@ -785,15 +785,23 @@ install( # install basis.h at install time so LIBINT_DATADIR_ABSOLUTE reflects # any --prefix override. $ENV{DESTDIR} must be prepended manually # here: install(CODE) runs custom code and does not get the automatic -# DESTDIR handling that install(FILES) etc. have. +# DESTDIR handling that install(FILES) etc. have. configure_file into the +# build tree, then file(COPY) into the install tree with explicit +# FILE_PERMISSIONS so the installed header does not inherit basis.h.in's +# mode (e.g. 0600, which varies by build env); this also works with the +# 3.16 minimum required here, unlike configure_file's NO_SOURCE_PERMISSIONS +# (CMake 3.19+). install(CODE " set(LIBINT_VERSION \"${LIBINT_VERSION}\") set(LIBINT_DATADIR_ABSOLUTE \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/libint/${LIBINT_VERSION}\") configure_file( \"${PROJECT_SOURCE_DIR}/include/libint2/basis.h.in\" - \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${LIBINT2_INSTALL_INCLUDEDIR}/libint2/basis.h\" - @ONLY - NO_SOURCE_PERMISSIONS) # else installed basis.h inherits basis.h.in's perms (e.g. 0600), which vary by build env + \"${PROJECT_BINARY_DIR}/basis.h.install/basis.h\" + @ONLY) + file(COPY + \"${PROJECT_BINARY_DIR}/basis.h.install/basis.h\" + DESTINATION \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${LIBINT2_INSTALL_INCLUDEDIR}/libint2\" + FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) ") # install bundled Boost headers if needed diff --git a/src/lib/libint/CMakeLists.txt b/src/lib/libint/CMakeLists.txt index ef8dfb35c..00193b847 100644 --- a/src/lib/libint/CMakeLists.txt +++ b/src/lib/libint/CMakeLists.txt @@ -227,14 +227,22 @@ else() ) endforeach() - # generate basis.h at install time so LIBINT_DATADIR_ABSOLUTE reflects any --prefix override + # generate basis.h at install time so LIBINT_DATADIR_ABSOLUTE reflects any --prefix override. + # configure_file into the build tree, then file(COPY) into the install tree with explicit + # FILE_PERMISSIONS: this avoids the installed header inheriting basis.h.in's mode (e.g. 0600, + # which varies by build env) without relying on NO_SOURCE_PERMISSIONS, and prepends + # $ENV{DESTDIR} manually -- install(CODE) runs custom code and does not get the automatic + # DESTDIR handling that install(FILES) etc. have. install(CODE " set(LIBINT_VERSION \"${LIBINT_VERSION}\") set(LIBINT_DATADIR_ABSOLUTE \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/libint/${LIBINT_VERSION}\") configure_file( \"${PROJECT_SOURCE_DIR}/include/libint2/basis.h.in\" - \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/libint2/basis.h\" - @ONLY - NO_SOURCE_PERMISSIONS) # else installed basis.h inherits basis.h.in's perms (e.g. 0600), which vary by build env + \"${CMAKE_CURRENT_BINARY_DIR}/basis.h.install/basis.h\" + @ONLY) + file(COPY + \"${CMAKE_CURRENT_BINARY_DIR}/basis.h.install/basis.h\" + DESTINATION \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/libint2\" + FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) ") endif()