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
This commit is contained in:
Daksh Mamodiya
2026-09-02 14:48:36 +02:00
parent 825bcff387
commit 52c8b8104b
32 changed files with 375 additions and 25 deletions
+24 -2
View File
@@ -9,7 +9,7 @@ Synopsis
.. parsed-literal::
`Query host system specific information`_
cmake_host_system_information(RESULT <variable> `QUERY`_ <key> ...)
cmake_host_system_information(RESULT <variable> `QUERY`_ [FROM_SYSROOT <bool>] <key> ...)
`Query the Windows registry`_
cmake_host_system_information(RESULT <variable> `QUERY WINDOWS_REGISTRY`_ <key> ...)
@@ -18,7 +18,7 @@ Query host system specific information
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. signature::
cmake_host_system_information(RESULT <variable> QUERY <key> ...)
cmake_host_system_information(RESULT <variable> QUERY [FROM_SYSROOT <bool>] <key> ...)
:target:
QUERY
@@ -26,6 +26,19 @@ Queries system information of the host system on which cmake runs.
One or more ``<key>`` can be provided to select the information to be
queried. The list of queried values is stored in ``<variable>``.
.. versionadded:: 4.5
The ``FROM_SYSROOT <bool>`` option controls whether ``DISTRIB_*`` keys read
the os-release under :variable:`CMAKE_SYSROOT` or the host os-release:
* A true value reads the os-release under :variable:`CMAKE_SYSROOT`, i.e. the
target distribution. This is useful, for example, to label packages for
the target system.
* A false value reads the host os-release, ignoring :variable:`CMAKE_SYSROOT`.
This is the default. See policy :policy:`CMP0221`.
It affects only ``DISTRIB_*`` keys.
``<key>`` can be one of the following values:
``NUMBER_OF_LOGICAL_CORES``
@@ -270,6 +283,15 @@ identification via fallback scripts. The fallback script can use `various
distribution-specific files`_ to collect OS identification data and map it
into `man 5 os-release`_ variables.
.. versionadded:: 4.5
The ``DISTRIB_*`` keys, including the fallback scripts, read the os-release
under the selected root (see ``FROM_SYSROOT`` above and policy
:policy:`CMP0221`): the host root, or the :variable:`CMAKE_SYSROOT` (target)
root. For ``DISTRIB_INFO``, only the names in the returned list are
authoritative; reusing ``<variable>`` across queries may leave stale
``<variable>_<key>`` definitions from a previous root.
Fallback Interface Variables
""""""""""""""""""""""""""""
+1
View File
@@ -100,6 +100,7 @@ Policies Introduced by CMake 4.5
.. toctree::
:maxdepth: 1
CMP0221: cmake_host_system_information() DISTRIB_* queries read the host os-release. </policy/CMP0221>
CMP0220: Languages enabled in subdirectories propagate to the top-level directory. </policy/CMP0220>
Policies Introduced by CMake 4.4
+44
View File
@@ -0,0 +1,44 @@
CMP0221
-------
.. versionadded:: 4.5
:command:`cmake_host_system_information` ``DISTRIB_*`` queries read the host
os-release.
The :command:`cmake_host_system_information` command is documented to query
information about the host system on which CMake runs. However, its
``DISTRIB_*`` queries read the :file:`/etc/os-release` (or
:file:`/usr/lib/os-release`) file under the :variable:`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 :variable:`CMAKE_SYSROOT`.
The ``NEW`` behavior is for such queries to read the host os-release,
ignoring :variable:`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 :variable:`CMAKE_SYSROOT`, which is
useful for querying the target distribution (e.g. for packaging).
.. code-block:: cmake
# 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 :variable:`CMAKE_SYSROOT` is non-empty. Passing
``FROM_SYSROOT``, or leaving :variable:`CMAKE_SYSROOT` empty, is silent.
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 4.5
.. |WARNS_OR_DOES_NOT_WARN| replace:: warns
.. include:: include/STANDARD_ADVICE.rst
.. include:: include/DEPRECATED.rst
@@ -0,0 +1,7 @@
cmake_host_system_information-distrib-host
------------------------------------------
* The :command:`cmake_host_system_information` command's ``DISTRIB_*`` queries
now read the host os-release by default. See policy :policy:`CMP0221`.
A new ``FROM_SYSROOT <bool>`` option explicitly enables or disables reading
the target os-release from :variable:`CMAKE_SYSROOT`.
+134 -15
View File
@@ -9,6 +9,7 @@
#include <map>
#include <string>
#include <utility>
#include <vector>
#include <cm/optional>
#include <cm/string_view>
@@ -28,6 +29,7 @@
#include "cmExecutionStatus.h"
#include "cmList.h"
#include "cmMakefile.h"
#include "cmPolicies.h"
#include "cmRange.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
@@ -325,17 +327,49 @@ cm::optional<std::pair<std::string, std::string>> ParseOSReleaseLine(
return {};
}
// Fallback os-release scripts read ${CMAKE_SYSROOT} directly, so point it at
// the effective root while they run; restored on destruction even if one
// fails.
class SysrootOverride
{
public:
SysrootOverride(cmMakefile& makefile, std::string const& root)
: Makefile(makefile)
{
cmValue value = this->Makefile.GetDefinition("CMAKE_SYSROOT");
this->Existed = static_cast<bool>(value);
if (this->Existed) {
this->Saved = *value;
}
this->Makefile.AddDefinition("CMAKE_SYSROOT", root);
}
~SysrootOverride()
{
if (this->Existed) {
this->Makefile.AddDefinition("CMAKE_SYSROOT", this->Saved);
} else {
this->Makefile.RemoveDefinition("CMAKE_SYSROOT");
}
}
SysrootOverride(SysrootOverride const&) = delete;
SysrootOverride& operator=(SysrootOverride const&) = delete;
private:
cmMakefile& Makefile;
std::string Saved;
bool Existed;
};
std::map<std::string, std::string> GetOSReleaseVariables(
cmExecutionStatus& status)
cmExecutionStatus& status, std::string const& root)
{
auto& makefile = status.GetMakefile();
auto const& sysroot = makefile.GetSafeDefinition("CMAKE_SYSROOT");
std::map<std::string, std::string> data;
// Based on
// https://www.freedesktop.org/software/systemd/man/latest/os-release.html
for (auto name : { "/etc/os-release"_s, "/usr/lib/os-release"_s }) {
auto const& filename = cmStrCat(sysroot, name);
auto const& filename = cmStrCat(root, name);
if (cmSystemTools::FileExists(filename)) {
cmsys::ifstream fin(filename.c_str());
for (std::string line; !std::getline(fin, line).fail();) {
@@ -397,6 +431,8 @@ std::map<std::string, std::string> GetOSReleaseVariables(
// Name of the variable to put the results
std::string const result_variable{ "CMAKE_GET_OS_RELEASE_FALLBACK_RESULT" };
SysrootOverride const sysrootOverride(makefile, root);
for (auto const& script : scripts) {
// Unset the result variable
makefile.RemoveDefinition(result_variable);
@@ -440,17 +476,21 @@ std::map<std::string, std::string> GetOSReleaseVariables(
return data;
}
cm::optional<std::string> GetDistribValue(cmExecutionStatus& status,
std::string const& key,
std::string const& variable)
cm::optional<std::string> GetDistribValue(
cmExecutionStatus& status, std::string const& key,
std::string const& variable, std::string const& root,
cm::optional<std::map<std::string, std::string>>& os_release)
{
auto const prefix = "DISTRIB_"_s;
if (!cmHasPrefix(key, prefix)) {
return {};
}
static std::map<std::string, std::string> const s_os_release =
GetOSReleaseVariables(status);
// Parse once per call, not in a static: a static would freeze the first
// call's result and ignore a later change of root.
if (!os_release.has_value()) {
os_release = GetOSReleaseVariables(status, root);
}
auto& makefile = status.GetMakefile();
@@ -458,7 +498,7 @@ cm::optional<std::string> GetDistribValue(cmExecutionStatus& status,
key.substr(prefix.size(), key.size() - prefix.size());
if (subkey == "INFO"_s) {
std::string vars;
for (auto const& kv : s_os_release) {
for (auto const& kv : *os_release) {
auto cmake_var_name = cmStrCat(variable, '_', kv.first);
vars += DELIM[!vars.empty()] + cmake_var_name;
makefile.AddDefinition(cmake_var_name, kv.second);
@@ -467,8 +507,8 @@ cm::optional<std::string> GetDistribValue(cmExecutionStatus& status,
}
// Query individual variable
auto const it = s_os_release.find(subkey);
if (it != s_os_release.cend()) {
auto const it = os_release->find(subkey);
if (it != os_release->cend()) {
return it->second;
}
@@ -739,6 +779,82 @@ bool cmCMakeHostSystemInformationCommand(std::vector<std::string> const& args,
status, variable);
}
// FROM_SYSROOT <bool> selects the CMAKE_SYSROOT (target) or host root for
// DISTRIB_* keys. Handled after the registry signature above, since a
// registry argument could itself be "FROM_SYSROOT".
enum class SysrootMode
{
Default,
Host,
Target,
};
auto mode = SysrootMode::Default;
std::vector<std::string> keys;
for (size_t i = current_index + 1; i < args.size(); ++i) {
if (args[i] != "FROM_SYSROOT"_s) {
keys.push_back(args[i]);
continue;
}
if (mode != SysrootMode::Default) {
status.SetError("FROM_SYSROOT may be given at most once.");
return false;
}
if (i + 1 >= args.size()) {
status.SetError("FROM_SYSROOT requires a boolean value.");
return false;
}
std::string const& value = args[++i];
if (cmIsOn(value)) {
mode = SysrootMode::Target;
} else if (cmIsOff(value)) {
mode = SysrootMode::Host;
} else {
status.SetError(cmStrCat("FROM_SYSROOT requires a boolean value, got \"",
value, "\"."));
return false;
}
}
cmMakefile& makefile = status.GetMakefile();
bool anyDistrib = false;
for (std::string const& key : keys) {
if (cmHasPrefix(key, "DISTRIB_"_s)) {
anyDistrib = true;
break;
}
}
std::string const& sysroot = makefile.GetSafeDefinition("CMAKE_SYSROOT");
bool selectHost = false;
switch (mode) {
case SysrootMode::Host:
selectHost = true;
break;
case SysrootMode::Target:
selectHost = false;
break;
case SysrootMode::Default:
switch (makefile.GetPolicyStatus(cmPolicies::CMP0221)) {
case cmPolicies::NEW:
selectHost = true;
break;
case cmPolicies::WARN:
// Warn only where OLD and NEW diverge: a DISTRIB_* query with a
// real sysroot. Empty sysroot or non-DISTRIB keys stay silent.
if (anyDistrib && !sysroot.empty()) {
makefile.IssuePolicyWarning(cmPolicies::CMP0221);
}
CM_FALLTHROUGH;
case cmPolicies::OLD:
selectHost = false;
break;
}
break;
}
std::string const effectiveRoot = selectHost ? std::string{} : sysroot;
static cmsys::SystemInformation info;
static auto initialized = false;
if (!initialized) {
@@ -748,16 +864,19 @@ bool cmCMakeHostSystemInformationCommand(std::vector<std::string> const& args,
initialized = true;
}
cm::optional<std::map<std::string, std::string>> os_release;
std::string result_list;
for (auto i = current_index + 1; i < args.size(); ++i) {
for (std::string const& key : keys) {
result_list += DELIM[!result_list.empty()];
auto const& key = args[i];
// clang-format off
auto value =
GetValueChained(
[&]() { return GetValue(info, key); }
, [&]() { return GetDistribValue(status, key, variable); }
, [&]() {
return GetDistribValue(status, key, variable, effectiveRoot,
os_release);
}
#ifdef _WIN32
, [&]() { return GetWindowsValue(status, key); }
#endif
@@ -770,7 +889,7 @@ bool cmCMakeHostSystemInformationCommand(std::vector<std::string> const& args,
result_list += value.value();
}
status.GetMakefile().AddDefinition(variable, result_list);
makefile.AddDefinition(variable, result_list);
return true;
}
+4
View File
@@ -662,6 +662,10 @@ class cmMakefile;
SELECT(POLICY, CMP0220, \
"Languages enabled in subdirectories propagate to the top-level " \
"directory.", \
4, 5, 0, WARN) \
SELECT(POLICY, CMP0221, \
"cmake_host_system_information() DISTRIB_* queries read the host " \
"os-release.", \
4, 5, 0, WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
@@ -1,4 +1,4 @@
cmake_host_system_information(RESULT CENTOS6 QUERY DISTRIB_INFO)
cmake_host_system_information(RESULT CENTOS6 QUERY FROM_SYSROOT ON DISTRIB_INFO)
foreach(VAR IN LISTS CENTOS6)
message(STATUS "${VAR}=`${${VAR}}`")
@@ -1,4 +1,4 @@
cmake_host_system_information(RESULT DEBIAN6 QUERY DISTRIB_INFO)
cmake_host_system_information(RESULT DEBIAN6 QUERY FROM_SYSROOT ON DISTRIB_INFO)
foreach(VAR IN LISTS DEBIAN6)
message(STATUS "${VAR}=`${${VAR}}`")
@@ -0,0 +1,28 @@
# Pre-os-release fallback scripts read ${CMAKE_SYSROOT}; FROM_SYSROOT must
# scope-override it so target/host selection is honored, and the original
# CMAKE_SYSROOT must be restored after each call.
cmake_policy(SET CMP0221 NEW)
# Host baseline with no sysroot in effect (the host itself may be CentOS).
cmake_host_system_information(RESULT baseline QUERY DISTRIB_ID)
set(sysroot "${CMAKE_CURRENT_LIST_DIR}/CentOS6")
set(CMAKE_SYSROOT "${sysroot}")
# Target: the CentOS fallback script detects the fixture under CMAKE_SYSROOT.
cmake_host_system_information(RESULT tgt QUERY FROM_SYSROOT ON DISTRIB_ID)
if(NOT tgt STREQUAL "centos")
message(FATAL_ERROR "FROM_SYSROOT ON fallback read ID '${tgt}', expected 'centos'")
endif()
if(NOT CMAKE_SYSROOT STREQUAL "${sysroot}")
message(FATAL_ERROR "CMAKE_SYSROOT not restored after target fallback: '${CMAKE_SYSROOT}'")
endif()
# Host: must read the host os-release, not the target fixture.
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(NOT CMAKE_SYSROOT STREQUAL "${sysroot}")
message(FATAL_ERROR "CMAKE_SYSROOT not restored after host fallback: '${CMAKE_SYSROOT}'")
endif()
@@ -0,0 +1,15 @@
# 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()
@@ -0,0 +1,14 @@
# With CMP0221 NEW, the no-keyword default ignores CMAKE_SYSROOT (host).
cmake_policy(SET CMP0221 NEW)
cmake_host_system_information(RESULT baseline QUERY DISTRIB_ID)
set(CMAKE_SYSROOT "${CMAKE_CURRENT_LIST_DIR}/Sentinel")
cmake_host_system_information(RESULT def QUERY DISTRIB_ID)
if(NOT def STREQUAL baseline)
message(FATAL_ERROR "CMP0221 NEW default read '${def}', expected host baseline '${baseline}'")
endif()
if(def STREQUAL "sentineltarget")
message(FATAL_ERROR "CMP0221 NEW default leaked the target sentinel")
endif()
@@ -0,0 +1,5 @@
# CMP0221 unset (WARN): a non-DISTRIB_* query must not warn, even with a
# non-empty CMAKE_SYSROOT. Also proves the os-release is not read lazily when
# no DISTRIB_* key is requested (no stderr, no side effects).
set(CMAKE_SYSROOT "${CMAKE_CURRENT_LIST_DIR}/Sentinel")
cmake_host_system_information(RESULT cores QUERY NUMBER_OF_LOGICAL_CORES)
@@ -0,0 +1,9 @@
# With CMP0221 OLD, the no-keyword default follows CMAKE_SYSROOT (target).
cmake_policy(SET CMP0221 OLD)
set(CMAKE_SYSROOT "${CMAKE_CURRENT_LIST_DIR}/Sentinel")
cmake_host_system_information(RESULT def QUERY DISTRIB_ID)
if(NOT def STREQUAL "sentineltarget")
message(FATAL_ERROR "CMP0221 OLD default read '${def}', expected target 'sentineltarget'")
endif()
@@ -0,0 +1,8 @@
^CMake Warning \(policy\) at [^
]*/DistribPolicyWarn\.cmake:[0-9]+ \(cmake_host_system_information\):
Policy CMP0221 is not set: cmake_host_system_information\(\) DISTRIB_\*
queries read the host os-release\. Run "cmake --help-policy CMP0221" for
policy details\. Use the cmake_policy command to set the policy and
suppress this warning\.
This warning is for project developers\. Use -Wno-author or -Wno-policy to
suppress it\.$
@@ -0,0 +1,8 @@
# CMP0221 unset (WARN): a DISTRIB_* query with a non-empty CMAKE_SYSROOT and no
# selector keyword warns once and uses the OLD behavior (target).
set(CMAKE_SYSROOT "${CMAKE_CURRENT_LIST_DIR}/Sentinel")
cmake_host_system_information(RESULT def QUERY DISTRIB_ID)
if(NOT def STREQUAL "sentineltarget")
message(FATAL_ERROR "CMP0221 WARN read '${def}', expected target 'sentineltarget'")
endif()
@@ -0,0 +1,3 @@
^CMake Error at [^
]*/DistribRegistrySelector\.cmake:[0-9]+ \(cmake_host_system_information\):
cmake_host_system_information does not recognize <key> WINDOWS_REGISTRY$
@@ -0,0 +1,4 @@
# FROM_SYSROOT before QUERY's content makes WINDOWS_REGISTRY no longer the
# registry signature, so it is rejected as an unknown <key>. This guards the
# registry-first dispatch: registry queries never see FROM_SYSROOT.
cmake_host_system_information(RESULT r QUERY FROM_SYSROOT ON WINDOWS_REGISTRY "HKLM")
@@ -0,0 +1,4 @@
^CMake Error at [^
]*/DistribSysrootBadValue\.cmake:[0-9]+ \(cmake_host_system_information\):
cmake_host_system_information FROM_SYSROOT requires a boolean value, got
"bogus"\.$
@@ -0,0 +1,3 @@
# FROM_SYSROOT requires a boolean value. A non-boolean is rejected, which also
# guards the "forgot the value, ate the next key" mistake.
cmake_host_system_information(RESULT r QUERY FROM_SYSROOT bogus DISTRIB_ID)
@@ -0,0 +1,3 @@
^CMake Error at [^
]*/DistribSysrootDuplicate\.cmake:[0-9]+ \(cmake_host_system_information\):
cmake_host_system_information FROM_SYSROOT may be given at most once\.$
@@ -0,0 +1,2 @@
# FROM_SYSROOT may be given at most once.
cmake_host_system_information(RESULT r QUERY FROM_SYSROOT ON FROM_SYSROOT OFF DISTRIB_ID)
@@ -0,0 +1,17 @@
# 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()
@@ -0,0 +1,10 @@
# Explicit target selection must read the CMAKE_SYSROOT os-release, even when
# the policy default is host.
cmake_policy(SET CMP0221 NEW)
set(CMAKE_SYSROOT "${CMAKE_CURRENT_LIST_DIR}/Sentinel")
cmake_host_system_information(RESULT tgt QUERY FROM_SYSROOT ON DISTRIB_ID)
if(NOT tgt STREQUAL "sentineltarget")
message(FATAL_ERROR "FROM_SYSROOT ON read '${tgt}', expected target 'sentineltarget'")
endif()
@@ -1,11 +1,11 @@
cmake_host_system_information(RESULT TEST1 QUERY DISTRIB_INFO)
cmake_host_system_information(RESULT TEST1 QUERY FROM_SYSROOT ON DISTRIB_INFO)
foreach(VAR IN LISTS TEST1)
message(STATUS "${VAR}=`${${VAR}}`")
endforeach()
# Query individual variables
cmake_host_system_information(RESULT TEST2 QUERY DISTRIB_ID DISTRIB_VERSION)
cmake_host_system_information(RESULT TEST2 QUERY FROM_SYSROOT ON DISTRIB_ID DISTRIB_VERSION)
list(POP_FRONT TEST2 TEST2_ID TEST2_VERSION)
message(STATUS "TEST2_ID=`${TEST2_ID}`")
message(STATUS "TEST2_VERSION=`${TEST2_VERSION}`")
@@ -30,6 +30,19 @@ run_cmake(Ubuntu)
run_cmake(CentOS6)
run_cmake(Debian6)
# DISTRIB_* host/target selection (CMP0221) and the FROM_SYSROOT option.
run_cmake_script(DistribHost)
run_cmake_script(DistribTarget)
run_cmake_script(DistribPolicyOld)
run_cmake_script(DistribPolicyNew)
run_cmake_script(DistribPolicyWarn)
run_cmake_script(DistribPolicyNonDistrib)
run_cmake_script(DistribSysrootBadValue)
run_cmake_script(DistribSysrootDuplicate)
run_cmake_script(DistribSysrootPosition)
run_cmake_script(DistribRegistrySelector)
run_cmake_script(DistribFallbackSelector)
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
run_cmake(MacOS)
endif()
@@ -0,0 +1,4 @@
NAME="Sentinel Target"
PRETTY_NAME="Sentinel Target 9.9"
ID=sentineltarget
VERSION_ID="9.9"
@@ -1,11 +1,11 @@
cmake_host_system_information(RESULT TEST1 QUERY DISTRIB_INFO)
cmake_host_system_information(RESULT TEST1 QUERY FROM_SYSROOT ON DISTRIB_INFO)
foreach(VAR IN LISTS TEST1)
message(STATUS "${VAR}=`${${VAR}}`")
endforeach()
# Query individual variables
cmake_host_system_information(RESULT TEST2 QUERY DISTRIB_ID DISTRIB_VERSION)
cmake_host_system_information(RESULT TEST2 QUERY FROM_SYSROOT ON DISTRIB_ID DISTRIB_VERSION)
list(POP_FRONT TEST2 TEST2_ID TEST2_VERSION)
message(STATUS "TEST2_ID=`${TEST2_ID}`")
message(STATUS "TEST2_VERSION=`${TEST2_VERSION}`")
@@ -1,4 +1,4 @@
cmake_host_system_information(RESULT UNIT_TEST QUERY DISTRIB_INFO)
cmake_host_system_information(RESULT UNIT_TEST QUERY FROM_SYSROOT ON DISTRIB_INFO)
foreach(VAR IN LISTS UNIT_TEST)
message(STATUS "${VAR}=`${${VAR}}`")
@@ -5,7 +5,7 @@ list(
${CMAKE_CURRENT_SOURCE_DIR}/999-LastFallbackScript.cmake
)
cmake_host_system_information(RESULT UFS QUERY DISTRIB_INFO)
cmake_host_system_information(RESULT UFS QUERY FROM_SYSROOT ON DISTRIB_INFO)
foreach(VAR IN LISTS UFS)
message(STATUS "${VAR}=`${${VAR}}`")