Files
Daksh Mamodiya 52c8b8104b cmake_host_system_information: select host vs sysroot for DISTRIB_*
`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
2026-09-02 14:48:36 +02:00

18 lines
693 B
CMake

# FROM_SYSROOT is accepted after and between keys, not just as the first token.
cmake_policy(SET CMP0221 NEW)
set(CMAKE_SYSROOT "${CMAKE_CURRENT_LIST_DIR}/Sentinel")
# After a key.
cmake_host_system_information(RESULT after QUERY DISTRIB_ID FROM_SYSROOT ON)
if(NOT after STREQUAL "sentineltarget")
message(FATAL_ERROR "FROM_SYSROOT after a key read '${after}', expected 'sentineltarget'")
endif()
# Between keys.
cmake_host_system_information(RESULT between QUERY DISTRIB_ID FROM_SYSROOT ON DISTRIB_NAME)
list(GET between 0 between_id)
if(NOT between_id STREQUAL "sentineltarget")
message(FATAL_ERROR "FROM_SYSROOT between keys read '${between_id}', expected 'sentineltarget'")
endif()