GNUInstallDirs: Need exception for /opt/homebrew for homebrew
On M1 homebrew is located in /opt/homebrew
(on intel that is /usr/local
).
That is root, and is expecting everything is located inside (like /opt/homebrew/usr
, /opt/homebrew/etc
, etc.)
When building a formula, homebrew set CMAKE_INSTALL_PREFIX into absolute path like /opt/homebrew/Cellar/foo/XXX
.
According to Filesystem Hierarchy Standard
, some dirs like SYSCONFDIR, LOCALSTATEDIR, and RUNSTATEDIR moved before prefix, if it starts with /opt
.
However for homebrew on M1 it causes error, and need special tricks, because it expects /opt/homebrew/
to be absolute root.
That is, with CMAKE_INSTALL_PREFIX=/opt/homebrew/Cellar/foo/XXX, CMAKE_INSTALL_FULL_SYSCONFDIR must be /opt/homebrew/Cellar/foo/XXX/etc, NOT /etc/opt/homebrew/Cellar/foo/XXX.
It seems, that clause like
elseif("${CMAKE_INSTALL_PREFIX}" MATCHES "^/opt/homebrew/.*")
set(${absvar} "${CMAKE_INSTALL_PREFIX}/${${var}}")
just before line elseif("${CMAKE_INSTALL_PREFIX}" MATCHES "^/opt/.*")
in Modules/GNUInstallDirs.cmake would solve the issue.