From caffb15d096116f45597c9c51c23041ff9b39de3 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Fri, 9 Sep 2022 20:10:43 +0200 Subject: LINUX: Set CMAKE_HOST_LINUX variable when running on a Linux host Relates: #23840 --- Help/manual/cmake-variables.7.rst | 1 + Help/release/dev/LINUX.rst | 2 ++ Help/variable/CMAKE_HOST_LINUX.rst | 6 ++++++ Modules/CMakeSystemSpecificInformation.cmake | 1 + Source/cmStateSnapshot.cxx | 5 +++++ 5 files changed, 15 insertions(+) create mode 100644 Help/variable/CMAKE_HOST_LINUX.rst diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 22fae08..6533ca5 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -310,6 +310,7 @@ Variables that Describe the System /variable/CMAKE_COMPILER_2005 /variable/CMAKE_HOST_APPLE /variable/CMAKE_HOST_BSD + /variable/CMAKE_HOST_LINUX /variable/CMAKE_HOST_SOLARIS /variable/CMAKE_HOST_SYSTEM /variable/CMAKE_HOST_SYSTEM_NAME diff --git a/Help/release/dev/LINUX.rst b/Help/release/dev/LINUX.rst index 45b7029..b837a1f 100644 --- a/Help/release/dev/LINUX.rst +++ b/Help/release/dev/LINUX.rst @@ -2,3 +2,5 @@ Variables --------- * The :variable:`LINUX` variable is set to true when the target system is Linux. + +* The :variable:`CMAKE_HOST_LINUX` variable is set to true when the host system is Linux. diff --git a/Help/variable/CMAKE_HOST_LINUX.rst b/Help/variable/CMAKE_HOST_LINUX.rst new file mode 100644 index 0000000..e2361bd --- /dev/null +++ b/Help/variable/CMAKE_HOST_LINUX.rst @@ -0,0 +1,6 @@ +CMAKE_HOST_LINUX +---------------- + +.. versionadded:: 3.25 + +Set to true when the host system is Linux. diff --git a/Modules/CMakeSystemSpecificInformation.cmake b/Modules/CMakeSystemSpecificInformation.cmake index 319b0bb..b5dc8d3 100644 --- a/Modules/CMakeSystemSpecificInformation.cmake +++ b/Modules/CMakeSystemSpecificInformation.cmake @@ -17,6 +17,7 @@ set(CYGWIN ) set(MSYS ) set(WIN32 ) set(BSD ) +set(LINUX ) function(_cmake_record_install_prefix ) set(_CMAKE_SYSTEM_PREFIX_PATH_INSTALL_PREFIX_VALUE "${CMAKE_INSTALL_PREFIX}" PARENT_SCOPE) diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index 102d1ce..c51650a 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -331,6 +331,11 @@ void cmStateSnapshot::SetDefaultDefinitions() this->SetDefinition("CMAKE_HOST_BSD", "DragonFlyBSD"); #endif +#if defined(__linux__) + this->SetDefinition("LINUX", "1"); + this->SetDefinition("CMAKE_HOST_LINUX", "1"); +#endif + this->SetDefinition("CMAKE_MAJOR_VERSION", std::to_string(cmVersion::GetMajorVersion())); this->SetDefinition("CMAKE_MINOR_VERSION", -- cgit v0.12