CMAKE_INSTALL_MODE — CMake 4.0.1 Documentation (original) (raw)

Added in version 3.22.

This is a CMake Environment Variable. Its initial value is taken from the calling process environment.

The CMAKE_INSTALL_MODE environment variable allows users to operate CMake in an alternate mode of file(INSTALL) and install().

The default behavior for an installation is to copy a source file from a source directory into a destination directory. This environment variable however allows the user to override this behavior, causing CMake to create symbolic links instead.

Usage Scenarios

Installing symbolic links rather than copying files can help in the following ways:

Allowed Values

The following values are allowed for CMAKE_INSTALL_MODE:

COPY, empty or unset

Duplicate the file at its destination. This is the default behavior.

ABS_SYMLINK

Create an absolute symbolic link to the source file at the destination. Halt with an error if the link cannot be created.

ABS_SYMLINK_OR_COPY

Like ABS_SYMLINK but fall back to silently copying if the symlink couldn't be created.

REL_SYMLINK

Create a relative symbolic link to the source file at the destination. Halt with an error if the link cannot be created.

REL_SYMLINK_OR_COPY

Like REL_SYMLINK but fall back to silently copying if the symlink couldn't be created.

SYMLINK

Try as if through REL_SYMLINK and fall back to ABS_SYMLINK if the referenced file cannot be expressed using a relative path. Halt with an error if the link cannot be created.

SYMLINK_OR_COPY

Like SYMLINK but fall back to silently copying if the symlink couldn't be created.

Note

A symbolic link consists of a reference file path rather than contents of its own, hence there are two ways to express the relation, either by a _relative_or an absolute path.

When To Set The Environment Variable

For the environment variable to take effect, it must be set during the correct build phase(s).

Given the above, it is recommended to set the environment variable consistently across all phases (configure, build and install).

Caveats

Use this environment variable with caution. The following highlights some points to be considered: