CMP0221ΒΆ

Added in version 4.5.

cmake_host_system_information() DISTRIB_* queries read the host os-release.

The cmake_host_system_information() command is documented to query information about the host system on which CMake runs. However, its DISTRIB_* queries read the /etc/os-release (or /usr/lib/os-release) file under the CMAKE_SYSROOT, if set. During cross compilation this reports the target distribution rather than the host, contradicting the rest of the command.

The OLD behavior of this policy is for DISTRIB_* queries with no FROM_SYSROOT to read the os-release under CMAKE_SYSROOT. The NEW behavior is for such queries to read the host os-release, ignoring CMAKE_SYSROOT.

Either behavior may be requested explicitly, regardless of this policy, with the FROM_SYSROOT <bool> option:

  • A false value reads the host os-release.

  • A true value reads the os-release under CMAKE_SYSROOT, which is useful for querying the target distribution (e.g. for packaging).

# Always the host distribution:
cmake_host_system_information(RESULT host QUERY FROM_SYSROOT OFF DISTRIB_ID)

# Always the target (CMAKE_SYSROOT) distribution:
cmake_host_system_information(RESULT target QUERY FROM_SYSROOT ON DISTRIB_ID)

The warning is issued only when it can matter: a DISTRIB_* query with no FROM_SYSROOT while CMAKE_SYSROOT is non-empty. Passing FROM_SYSROOT, or leaving CMAKE_SYSROOT empty, is silent.

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.