summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCristian Adam <cristian.adam@gmail.com>2022-09-06 01:15:44 +0200
committerCristian Adam <cristian.adam@gmail.com>2022-09-06 01:15:44 +0200
commit1ea8b8ed86628ecaa6a6e47231cefb2d68ac9e73 (patch)
treef5ef2c28a216fa326cfe39335eb309b66b0d62c5
parent288f72efea0636c498755a9cec6d5ddcbfed5c8c (diff)
downloadcmake-1ea8b8ed86628ecaa6a6e47231cefb2d68ac9e73.tar.gz
BSD: Set CMAKE_HOST_BSD variable on a BSD host
Also the BSD variable will be set in CMake scripting mode (-P). Relates: #23853
-rw-r--r--Help/manual/cmake-variables.7.rst1
-rw-r--r--Help/release/dev/BSD.rst3
-rw-r--r--Help/variable/CMAKE_HOST_BSD.rst7
-rw-r--r--Modules/CMakeSystemSpecificInformation.cmake1
-rw-r--r--Source/cmStateSnapshot.cxx14
5 files changed, 26 insertions, 0 deletions
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index bb72c1410f..22fae08bf6 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -309,6 +309,7 @@ Variables that Describe the System
/variable/CMAKE_CL_64
/variable/CMAKE_COMPILER_2005
/variable/CMAKE_HOST_APPLE
+ /variable/CMAKE_HOST_BSD
/variable/CMAKE_HOST_SOLARIS
/variable/CMAKE_HOST_SYSTEM
/variable/CMAKE_HOST_SYSTEM_NAME
diff --git a/Help/release/dev/BSD.rst b/Help/release/dev/BSD.rst
index fab2015cca..cd2352bb0d 100644
--- a/Help/release/dev/BSD.rst
+++ b/Help/release/dev/BSD.rst
@@ -3,3 +3,6 @@ Variables
* The :variable:`BSD` variable is set to a string value when the target system is BSD.
This value can be one of the following: DragonFlyBSD, FreeBSD, OpenBSD, or NetBSD.
+
+* The :variable:`CMAKE_HOST_BSD` variable is set to a string value when the host system is BSD.
+ This value can be one of the following: DragonFlyBSD, FreeBSD, OpenBSD, or NetBSD.
diff --git a/Help/variable/CMAKE_HOST_BSD.rst b/Help/variable/CMAKE_HOST_BSD.rst
new file mode 100644
index 0000000000..d3554f94f6
--- /dev/null
+++ b/Help/variable/CMAKE_HOST_BSD.rst
@@ -0,0 +1,7 @@
+CMAKE_HOST_BSD
+--------------
+
+.. versionadded:: 3.25
+
+Set to a string value when the host system is BSD. This value can be one of
+the following: DragonFlyBSD, FreeBSD, OpenBSD, or NetBSD.
diff --git a/Modules/CMakeSystemSpecificInformation.cmake b/Modules/CMakeSystemSpecificInformation.cmake
index e0459321cb..319b0bbe28 100644
--- a/Modules/CMakeSystemSpecificInformation.cmake
+++ b/Modules/CMakeSystemSpecificInformation.cmake
@@ -16,6 +16,7 @@ set(UNIX )
set(CYGWIN )
set(MSYS )
set(WIN32 )
+set(BSD )
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 f73df8f08a..102d1ceff6 100644
--- a/Source/cmStateSnapshot.cxx
+++ b/Source/cmStateSnapshot.cxx
@@ -317,6 +317,20 @@ void cmStateSnapshot::SetDefaultDefinitions()
this->SetDefinition("CMAKE_HOST_SOLARIS", "1");
#endif
+#if defined(__OpenBSD__)
+ this->SetDefinition("BSD", "OpenBSD");
+ this->SetDefinition("CMAKE_HOST_BSD", "OpenBSD");
+#elif defined(__FreeBSD__)
+ this->SetDefinition("BSD", "FreeBSD");
+ this->SetDefinition("CMAKE_HOST_BSD", "FreeBSD");
+#elif defined(__NetBSD__)
+ this->SetDefinition("BSD", "NetBSD");
+ this->SetDefinition("CMAKE_HOST_BSD", "NetBSD");
+#elif defined(__DragonFly__)
+ this->SetDefinition("BSD", "DragonFlyBSD");
+ this->SetDefinition("CMAKE_HOST_BSD", "DragonFlyBSD");
+#endif
+
this->SetDefinition("CMAKE_MAJOR_VERSION",
std::to_string(cmVersion::GetMajorVersion()));
this->SetDefinition("CMAKE_MINOR_VERSION",