summaryrefslogtreecommitdiffstats
path: root/Source/cmCMakeHostSystemInformationCommand.cxx
diff options
context:
space:
mode:
authorAlex Turbov <i.zaufi@gmail.com>2021-07-28 01:38:26 (GMT)
committerAlex Turbov <i.zaufi@gmail.com>2021-07-28 01:38:26 (GMT)
commitd6b4982697d74a0077f7f3c57f5078449b41e8ef (patch)
treef8680115e2b33b9ead7a69a3ac3bfebd5f246040 /Source/cmCMakeHostSystemInformationCommand.cxx
parentd6299d9941644e1bb36d274597e53a4c9e12f3bf (diff)
downloadCMake-d6b4982697d74a0077f7f3c57f5078449b41e8ef.zip
CMake-d6b4982697d74a0077f7f3c57f5078449b41e8ef.tar.gz
CMake-d6b4982697d74a0077f7f3c57f5078449b41e8ef.tar.bz2
Refactor: Move module private functions on top
Diffstat (limited to 'Source/cmCMakeHostSystemInformationCommand.cxx')
-rw-r--r--Source/cmCMakeHostSystemInformationCommand.cxx116
1 files changed, 54 insertions, 62 deletions
diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx
index 10c0714..2a0b0b8 100644
--- a/Source/cmCMakeHostSystemInformationCommand.cxx
+++ b/Source/cmCMakeHostSystemInformationCommand.cxx
@@ -9,7 +9,7 @@
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
-#if defined(_WIN32)
+#ifdef _WIN32
# include "cmAlgorithms.h"
# include "cmGlobalGenerator.h"
# include "cmGlobalVisualStudioVersionedGenerator.h"
@@ -19,60 +19,21 @@
#endif
namespace {
-bool GetValue(cmExecutionStatus& status, cmsys::SystemInformation& info,
- std::string const& key, std::string& value);
-std::string ValueToString(size_t value);
-std::string ValueToString(const char* value);
-std::string ValueToString(std::string const& value);
+// BEGIN Private functions
+std::string ValueToString(std::size_t const value)
+{
+ return std::to_string(value);
}
-// cmCMakeHostSystemInformation
-bool cmCMakeHostSystemInformationCommand(std::vector<std::string> const& args,
- cmExecutionStatus& status)
+std::string ValueToString(const char* const value)
{
- size_t current_index = 0;
-
- if (args.size() < (current_index + 2) || args[current_index] != "RESULT") {
- status.SetError("missing RESULT specification.");
- return false;
- }
-
- std::string const& variable = args[current_index + 1];
- current_index += 2;
-
- if (args.size() < (current_index + 2) || args[current_index] != "QUERY") {
- status.SetError("missing QUERY specification");
- return false;
- }
-
- static cmsys::SystemInformation info;
- static auto initialized = false;
- if (!initialized) {
- info.RunCPUCheck();
- info.RunOSCheck();
- info.RunMemoryCheck();
- initialized = true;
- }
-
- std::string result_list;
- for (size_t i = current_index + 1; i < args.size(); ++i) {
- std::string const& key = args[i];
- if (i != current_index + 1) {
- result_list += ";";
- }
- std::string value;
- if (!GetValue(status, info, key, value)) {
- return false;
- }
- result_list += value;
- }
-
- status.GetMakefile().AddDefinition(variable, result_list);
-
- return true;
+ return value ? value : std::string{};
}
-namespace {
+std::string ValueToString(std::string const& value)
+{
+ return value;
+}
bool GetValue(cmExecutionStatus& status, cmsys::SystemInformation& info,
std::string const& key, std::string& value)
@@ -200,20 +161,51 @@ bool GetValue(cmExecutionStatus& status, cmsys::SystemInformation& info,
return true;
}
+// END Private functions
+} // anonymous namespace
-std::string ValueToString(size_t value)
+// cmCMakeHostSystemInformation
+bool cmCMakeHostSystemInformationCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- return std::to_string(value);
-}
+ std::size_t current_index = 0;
-std::string ValueToString(const char* value)
-{
- std::string safe_string = value ? value : "";
- return safe_string;
-}
+ if (args.size() < (current_index + 2) || args[current_index] != "RESULT") {
+ status.SetError("missing RESULT specification.");
+ return false;
+ }
-std::string ValueToString(std::string const& value)
-{
- return value;
-}
+ std::string const& variable = args[current_index + 1];
+ current_index += 2;
+
+ if (args.size() < (current_index + 2) || args[current_index] != "QUERY") {
+ status.SetError("missing QUERY specification");
+ return false;
+ }
+
+ static cmsys::SystemInformation info;
+ static auto initialized = false;
+ if (!initialized) {
+ info.RunCPUCheck();
+ info.RunOSCheck();
+ info.RunMemoryCheck();
+ initialized = true;
+ }
+
+ std::string result_list;
+ for (auto i = current_index + 1; i < args.size(); ++i) {
+ std::string const& key = args[i];
+ if (i != current_index + 1) {
+ result_list += ";";
+ }
+ std::string value;
+ if (!GetValue(status, info, key, value)) {
+ return false;
+ }
+ result_list += value;
+ }
+
+ status.GetMakefile().AddDefinition(variable, result_list);
+
+ return true;
}