1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-23 09:37:51 +08:00

cmake_host_system_information: Make it available for all systems

Before it was Linux only.
This commit is contained in:
Alex Turbov
2021-08-03 20:24:59 +03:00
committed by Brad King
parent 5469c71a82
commit b9698f89df
4 changed files with 9 additions and 19 deletions

View File

@@ -132,9 +132,6 @@ queried. The list of queried values is stored in ``<variable>``.
See :variable:`CMAKE_HOST_SYSTEM_PROCESSOR` See :variable:`CMAKE_HOST_SYSTEM_PROCESSOR`
For Linux distributions additional ``<key>`` values are available to get operating
system identification as described in the `man 5 os-release`_.
``DISTRIB_INFO`` ``DISTRIB_INFO``
.. versionadded:: 3.22 .. versionadded:: 3.22
@@ -144,7 +141,8 @@ system identification as described in the `man 5 os-release`_.
``DISTRIB_<name>`` ``DISTRIB_<name>``
.. versionadded:: 3.22 .. versionadded:: 3.22
Get the ``<name>`` variable if it exists in the :file:`/etc/os-release` file Get the ``<name>`` variable (see `man 5 os-release`_) if it exists in the
:file:`/etc/os-release` file
Example: Example:

View File

@@ -149,7 +149,6 @@ cm::optional<std::string> GetValue(cmsys::SystemInformation& info,
return {}; return {};
} }
#ifdef __linux__
cm::optional<std::pair<std::string, std::string>> ParseOSReleaseLine( cm::optional<std::pair<std::string, std::string>> ParseOSReleaseLine(
std::string const& line) std::string const& line)
{ {
@@ -407,7 +406,6 @@ cm::optional<std::string> GetValue(cmExecutionStatus& status,
// NOTE Empty string means requested variable not set // NOTE Empty string means requested variable not set
return std::string{}; return std::string{};
} }
#endif
#ifdef HAVE_VS_SETUP_HELPER #ifdef HAVE_VS_SETUP_HELPER
cm::optional<std::string> GetValue(cmExecutionStatus& status, cm::optional<std::string> GetValue(cmExecutionStatus& status,
@@ -494,9 +492,7 @@ bool cmCMakeHostSystemInformationCommand(std::vector<std::string> const& args,
auto value = auto value =
GetValueChained( GetValueChained(
[&]() { return GetValue(info, key); } [&]() { return GetValue(info, key); }
#ifdef __linux__
, [&]() { return GetValue(status, key, variable); } , [&]() { return GetValue(status, key, variable); }
#endif
#ifdef HAVE_VS_SETUP_HELPER #ifdef HAVE_VS_SETUP_HELPER
, [&]() { return GetValue(status, key); } , [&]() { return GetValue(status, key); }
#endif #endif

View File

@@ -349,7 +349,7 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE)
endif() endif()
add_RunCMake_test(execute_process) add_RunCMake_test(execute_process)
add_RunCMake_test(export) add_RunCMake_test(export)
add_RunCMake_test(cmake_host_system_information -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) add_RunCMake_test(cmake_host_system_information)
add_RunCMake_test(cmake_language) add_RunCMake_test(cmake_language)
add_RunCMake_test(cmake_minimum_required) add_RunCMake_test(cmake_minimum_required)
add_RunCMake_test(cmake_parse_arguments) add_RunCMake_test(cmake_parse_arguments)

View File

@@ -7,15 +7,11 @@ run_cmake(BadArg3)
run_cmake(QueryList) run_cmake(QueryList)
run_cmake(QueryKeys) run_cmake(QueryKeys)
if (CMAKE_SYSTEM_NAME MATCHES "Linux") run_cmake(UnitTest)
run_cmake(Exherbo)
run_cmake(Ubuntu)
run_cmake_with_options(UnitTest) run_cmake(CentOS6)
run_cmake_with_options(Exherbo) run_cmake(Debian6)
run_cmake_with_options(Ubuntu)
run_cmake_with_options(CentOS6) run_cmake(UserFallbackScript)
run_cmake_with_options(Debian6)
run_cmake_with_options(UserFallbackScript)
endif()