From c1aaf8a61defe3e01e8526b99d8919b9618d1ba9 Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Mon, 27 Feb 2017 10:30:20 -0500
Subject: [PATCH] Fix CMAKE_HOST_SYSTEM_NAME on SunOS

In commit 0bbd993f (Make CMAKE_HOST_SYSTEM_NAME available in scripting
context, 2016-12-26) we added a call to `uname` that checks for a zero
return value.  However, on Solaris the `uname(2)` manual [1] says that
on success a non-negative value is returned.  Fix our return code check
so that we detect the `SunOS` name correctly.

[1] https://docs.oracle.com/cd/E53394_01/html/E54765/uname-2.html
---
 Source/cmStateSnapshot.cxx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx
index 80e494b686..d2c9d737f9 100644
--- a/Source/cmStateSnapshot.cxx
+++ b/Source/cmStateSnapshot.cxx
@@ -308,7 +308,7 @@ void cmStateSnapshot::SetDefaultDefinitions()
   this->SetDefinition("CMAKE_HOST_UNIX", "1");
 
   struct utsname uts_name;
-  if (uname(&uts_name) == 0) {
+  if (uname(&uts_name) >= 0) {
     this->SetDefinition("CMAKE_HOST_SYSTEM_NAME", uts_name.sysname);
   }
 #endif
-- 
GitLab