mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
`DISTRIB_*` read os-release under `CMAKE_SYSROOT`, so cross builds got the target distro from a host-oriented command, and a process-wide static froze the first result. Add a `FROM_SYSROOT <bool>` option and policy `CMP0221` to default to the host, parse per call, and scope `CMAKE_SYSROOT` so the fallback scripts follow the same choice. Fixes: #27640
16 lines
612 B
CMake
16 lines
612 B
CMake
# Explicit host selection must ignore CMAKE_SYSROOT and read the host os-release.
|
|
cmake_policy(SET CMP0221 NEW)
|
|
|
|
# Baseline: query the host with no sysroot in effect.
|
|
cmake_host_system_information(RESULT baseline QUERY DISTRIB_ID)
|
|
|
|
set(CMAKE_SYSROOT "${CMAKE_CURRENT_LIST_DIR}/Sentinel")
|
|
cmake_host_system_information(RESULT host QUERY FROM_SYSROOT OFF DISTRIB_ID)
|
|
|
|
if(NOT host STREQUAL baseline)
|
|
message(FATAL_ERROR "FROM_SYSROOT OFF read '${host}', expected host baseline '${baseline}'")
|
|
endif()
|
|
if(host STREQUAL "sentineltarget")
|
|
message(FATAL_ERROR "FROM_SYSROOT OFF leaked the target sentinel")
|
|
endif()
|