CMP0225ΒΆ

Added in version 4.5.

ExternalProject_Add() sets CMAKE_INSTALL_PREFIX to <INSTALL_DIR> in the default configure command.

When no CONFIGURE_COMMAND is given, ExternalProject_Add() drives the external project as a CMake project with a default configure command. CMake 4.4 and below do not pass CMAKE_INSTALL_PREFIX in that command, so the external project's install step uses CMake's built-in default prefix, such as /usr/local on Unix or C:/Program Files on Windows, rather than the INSTALL_DIR that the module reserves for it inside the build tree. Installing to a shared system prefix as a side effect of a build is surprising and often fails for lack of permission.

CMake 4.5 and above prefer to set CMAKE_INSTALL_PREFIX to the external project's INSTALL_DIR, so that it installs to the location the module reserves for it.

The OLD behavior of this policy does not set CMAKE_INSTALL_PREFIX in the default configure command. The NEW behavior sets it to the external project's INSTALL_DIR.

This policy affects only the default configure command; a custom CONFIGURE_COMMAND, including an empty one, is unaffected.

A CMAKE_INSTALL_PREFIX given by the caller in CMAKE_ARGS (for example, through cmake --install-prefix) or in CMAKE_CACHE_ARGS still takes precedence. A prefix given in CMAKE_CACHE_DEFAULT_ARGS does not, matching that option's non-overriding-default semantics.

Setting CMAKE_INSTALL_PREFIX in the external project also has effects beyond the install location: CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT is left false, and the prefix is prepended to CMAKE_SYSTEM_PREFIX_PATH, which can change find_*() results. These effects apply even when the install step is disabled with INSTALL_COMMAND "".

Adopting the NEW behavior in an existing build tree reconfigures the external project and overwrites its cached CMAKE_INSTALL_PREFIX; returning to the OLD behavior does not restore the previous cached value. As with the other directory placeholders, changing INSTALL_DIR later may not reconfigure the external project with every generator, so its build tree may need to be cleaned for the cached prefix to update.

This policy was introduced in CMake version 4.5. It may be set by cmake_policy() or cmake_minimum_required(). If it is not set, CMake warns, and uses OLD behavior.

Note

The OLD behavior of a policy is deprecated by definition and may be removed in a future version of CMake.