diff options
author | Cristian Adam <cristian.adam@gmail.com> | 2022-09-09 18:10:43 (GMT) |
---|---|---|
committer | Cristian Adam <cristian.adam@gmail.com> | 2022-09-09 18:10:43 (GMT) |
commit | caffb15d096116f45597c9c51c23041ff9b39de3 (patch) | |
tree | bb662f2173713f17073ee64efe1648e0c81dc7d7 | |
parent | 12de4ea2e8efc00c57c731b4a42066ef6d20e099 (diff) | |
download | CMake-caffb15d096116f45597c9c51c23041ff9b39de3.zip CMake-caffb15d096116f45597c9c51c23041ff9b39de3.tar.gz CMake-caffb15d096116f45597c9c51c23041ff9b39de3.tar.bz2 |
LINUX: Set CMAKE_HOST_LINUX variable when running on a Linux host
Relates: #23840
-rw-r--r-- | Help/manual/cmake-variables.7.rst | 1 | ||||
-rw-r--r-- | Help/release/dev/LINUX.rst | 2 | ||||
-rw-r--r-- | Help/variable/CMAKE_HOST_LINUX.rst | 6 | ||||
-rw-r--r-- | Modules/CMakeSystemSpecificInformation.cmake | 1 | ||||
-rw-r--r-- | Source/cmStateSnapshot.cxx | 5 |
5 files changed, 15 insertions, 0 deletions
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", |