GNUInstallDirs: CMake 3.22 broken on 64-bit RedHat platforms: forces lib/ instead of lib64/
ecaca8c1 from !6512 (merged) broke builds on RedHat platforms.
The problem has a few interacting components, some of which preexist the visible breakage:
-
RH dev and build machines normally have the 'conda' build environment installed and set up for use. That means the various CONDA_XXX environment vars are always present in the shell environment, even on containerized 'clean' builds, whether building in the conda environment or not. This has ~always been the case AFAIK.
-
CMake has always treated the mere presence of the ENV{CONDA_XXXX} vars as indicating we're building with conda, whether we are or not. This is pre-existing breakage, and __system_type_for_install gets set to "conda" in GNUInstallDirs.cmake. Although CMkae has always made this error, it has not been visible until...
-
ecaca8c1 changed:
diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake
index ead55ca1d8..1b9cfce258 100644
--- a/Modules/GNUInstallDirs.cmake
+++ b/Modules/GNUInstallDirs.cmake
[...]
@@ -251,7 +277,8 @@
set(__LAST_LIBDIR_DEFAULT "lib/${CMAKE_LIBRARY_ARCHITECTURE}")
endif()
endif()
- else() # not debian, rely on CMAKE_SIZEOF_VOID_P:
+ elseif(NOT DEFINED __system_type_for_install)
+ # not debian, alpine, arch, or conda so rely on CMAKE_SIZEOF_VOID_P:
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(_LIBDIR_DEFAULT "lib64")
if(DEFINED _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX)
Now instead of getting lib64 if 'not debian', we get lib64 only if __system_type_for_install is unset, but it's set to the misidentified 'conda'. So CMake tries to install to lib/ on 64-bit RedHat distros.
Note that the other 'improvement' of checking to see if the conda install dir exist is uninvolved (and neither helps nor hurts) here; it's set by the system to '/usr'
Obviously, the best course is to fix conda detection, but given that it was always broken on RH, perhaps temporarily rolling back the change for now is sufficient if fixing conda detect is tricky.