Define GNU standard installation directories
Provides install directory variables as defined by the GNU Coding Standards.
Inclusion of this module defines the following variables:
CMAKE_INSTALL_<dir>
Destination for files of a given type. This value may be passed to the
DESTINATION
options ofinstall()
commands for the corresponding file type. It should be a path relative to the installation prefix so that it can be converted to an absolute path in a relocatable way.While absolute paths are allowed, they are not recommended as they do not work with the
cmake --install
command's--prefix
option, or with thecpack
installer generators. In particular, there is no need to make paths absolute by prependingCMAKE_INSTALL_PREFIX
; this prefix is used by default if the DESTINATION is a relative path.
CMAKE_INSTALL_FULL_<dir>
The absolute path generated from the corresponding
CMAKE_INSTALL_<dir>
value. If the value is not already an absolute path, an absolute path is constructed typically by prepending the value of theCMAKE_INSTALL_PREFIX
variable. However, there are some special cases as documented below.These variables shouldn't be used in
install()
commands as they do not work with thecmake --install
command's--prefix
option, or with thecpack
installer generators.
where <dir>
is one of:
BINDIR
user executables (bin
)
SBINDIR
system admin executables (sbin
)
LIBEXECDIR
program executables (libexec
)
SYSCONFDIR
read-only single-machine data (etc
)
SHAREDSTATEDIR
modifiable architecture-independent data (com
)
LOCALSTATEDIR
modifiable single-machine data (var
)
RUNSTATEDIR
Added in version 3.9: run-time variable data (LOCALSTATEDIR/run
)
LIBDIR
object code libraries (lib
or lib64
)
On Debian, this may be lib/<multiarch-tuple>
when
CMAKE_INSTALL_PREFIX
is /usr
.
INCLUDEDIR
C header files (include
)
OLDINCLUDEDIR
C header files for non-gcc (/usr/include
)
DATAROOTDIR
read-only architecture-independent data root (share
)
DATADIR
read-only architecture-independent data (DATAROOTDIR
)
INFODIR
info documentation (DATAROOTDIR/info
)
LOCALEDIR
locale-dependent data (DATAROOTDIR/locale
)
MANDIR
man documentation (DATAROOTDIR/man
)
DOCDIR
documentation root (DATAROOTDIR/doc/PROJECT_NAME
)
If the includer does not define a value the above-shown default will be used and the value will appear in the cache for editing by the user.
Added in version 3.4.
The following values of CMAKE_INSTALL_PREFIX
are special:
/
For
<dir>
other than theSYSCONFDIR
,LOCALSTATEDIR
andRUNSTATEDIR
, the value ofCMAKE_INSTALL_<dir>
is prefixed withusr/
if it is not user-specified as an absolute path. For example, theINCLUDEDIR
valueinclude
becomesusr/include
. This is required by the GNU Coding Standards, which state:When building the complete GNU system, the prefix will be empty and
/usr
will be a symbolic link to/
.
/usr
For
<dir>
equal toSYSCONFDIR
,LOCALSTATEDIR
orRUNSTATEDIR
, theCMAKE_INSTALL_FULL_<dir>
is computed by prepending just/
to the value ofCMAKE_INSTALL_<dir>
if it is not user-specified as an absolute path. For example, theSYSCONFDIR
valueetc
becomes/etc
. This is required by the GNU Coding Standards.
/opt/...
For
<dir>
equal toSYSCONFDIR
,LOCALSTATEDIR
orRUNSTATEDIR
, theCMAKE_INSTALL_FULL_<dir>
is computed by appending the prefix to the value ofCMAKE_INSTALL_<dir>
if it is not user-specified as an absolute path. For example, theSYSCONFDIR
valueetc
becomes/etc/opt/...
. This is defined by the Filesystem Hierarchy Standard.This behavior does not apply to paths under
/opt/homebrew/...
.
GNUInstallDirs_get_absolute_install_dir(absvar var dirname)
Added in version 3.7.
Set the given variable absvar
to the absolute path contained
within the variable var
. This is to allow the computation of an
absolute path, accounting for all the special cases documented
above. While this macro is used to compute the various
CMAKE_INSTALL_FULL_<dir>
variables, it is exposed publicly to
allow users who create additional path variables to also compute
absolute paths where necessary, using the same logic. dirname
is
the directory name to get, e.g. BINDIR
.
Changed in version 3.20: Added the <dirname>
parameter. Previous versions of CMake passed
this value through the variable ${dir}
.