CMAKE_INSTALL_PREFIX¶
Install directory used by install().
If make install is invoked or INSTALL is built, this directory is
prepended onto all install directories.
This variable defaults as follows:
Added in version 3.29: If the
CMAKE_INSTALL_PREFIXenvironment variable is set, its value is used as default for this variable.c:/Program Files/${PROJECT_NAME}on Windows./usr/localon UNIX platforms.
See CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT for how a
project might choose its own default.
On UNIX one can use the DESTDIR mechanism in order to relocate the
whole installation to a staging area. See the DESTDIR environment
variable for more information.
The installation prefix is also added to CMAKE_SYSTEM_PREFIX_PATH
so that find_package(), find_program(),
find_library(), find_path(), and find_file()
will search the prefix for other software. This behavior can be disabled by
setting the CMAKE_FIND_NO_INSTALL_PREFIX to TRUE before the
first project() invocation.
Note
Use the GNUInstallDirs module to provide GNU-style
options for the layout of directories within the installation.
The CMAKE_INSTALL_PREFIX may be defined when configuring a build tree
to set its installation prefix. Or, when using the cmake(1)
command-line tool's --install mode, one may specify
a different prefix using the --prefix
option:
cmake --install . --prefix /my/install/prefix
Note
When the project is using the GNUInstallDirs module, there are
some special cases that are
evaluated based on the value of the CMAKE_INSTALL_PREFIX
variable during the configuration phase. The results persist even
if an alternative --prefix option
is used during installation.
See Also¶
The
--install-prefixoption.The
$<INSTALL_PREFIX>generator expression.The installDir field in CMake configure presets.
The
CPACK_PACKAGING_INSTALL_PREFIXvariable.