summaryrefslogtreecommitdiffstats
path: root/Source/cmServerProtocol.cxx
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2016-09-09 08:01:45 (GMT)
committerBrad King <brad.king@kitware.com>2016-09-26 18:25:20 (GMT)
commit544f65f44de0bb63a0b427150eb5e2bc90f58396 (patch)
tree0d5e4fbbd3a13cd1df30c68cf1293bca01801f20 /Source/cmServerProtocol.cxx
parent82104cc7a8e831ad20cb87d126c2ff00a851bedc (diff)
downloadCMake-544f65f44de0bb63a0b427150eb5e2bc90f58396.zip
CMake-544f65f44de0bb63a0b427150eb5e2bc90f58396.tar.gz
CMake-544f65f44de0bb63a0b427150eb5e2bc90f58396.tar.bz2
server-mode: Set global configuration of cmake via a command
"setGlobalSettings" can be used to change settings reported by "globalSettings" command.
Diffstat (limited to 'Source/cmServerProtocol.cxx')
-rw-r--r--Source/cmServerProtocol.cxx44
1 files changed, 44 insertions, 0 deletions
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index 49f03cd..55ae24e 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -283,6 +283,9 @@ const cmServerResponse cmServerProtocol1_0::Process(
if (request.Type == kGLOBAL_SETTINGS_TYPE) {
return this->ProcessGlobalSettings(request);
}
+ if (request.Type == kSET_GLOBAL_SETTINGS_TYPE) {
+ return this->ProcessSetGlobalSettings(request);
+ }
return request.ReportError("Unknown command!");
}
@@ -320,3 +323,44 @@ cmServerResponse cmServerProtocol1_0::ProcessGlobalSettings(
return request.Reply(obj);
}
+
+static void setBool(const cmServerRequest& request, const std::string& key,
+ std::function<void(bool)> setter)
+{
+ if (request.Data[key].isNull()) {
+ return;
+ }
+ setter(request.Data[key].asBool());
+}
+
+cmServerResponse cmServerProtocol1_0::ProcessSetGlobalSettings(
+ const cmServerRequest& request)
+{
+ const std::vector<std::string> boolValues = {
+ kDEBUG_OUTPUT_KEY, kTRACE_KEY, kTRACE_EXPAND_KEY,
+ kWARN_UNINITIALIZED_KEY, kWARN_UNUSED_KEY, kWARN_UNUSED_CLI_KEY,
+ kCHECK_SYSTEM_VARS_KEY
+ };
+ for (auto i : boolValues) {
+ if (!request.Data[i].isNull() && !request.Data[i].isBool()) {
+ return request.ReportError("\"" + i +
+ "\" must be unset or a bool value.");
+ }
+ }
+
+ cmake* cm = this->CMakeInstance();
+
+ setBool(request, kDEBUG_OUTPUT_KEY,
+ [cm](bool e) { cm->SetDebugOutputOn(e); });
+ setBool(request, kTRACE_KEY, [cm](bool e) { cm->SetTrace(e); });
+ setBool(request, kTRACE_EXPAND_KEY, [cm](bool e) { cm->SetTraceExpand(e); });
+ setBool(request, kWARN_UNINITIALIZED_KEY,
+ [cm](bool e) { cm->SetWarnUninitialized(e); });
+ setBool(request, kWARN_UNUSED_KEY, [cm](bool e) { cm->SetWarnUnused(e); });
+ setBool(request, kWARN_UNUSED_CLI_KEY,
+ [cm](bool e) { cm->SetWarnUnusedCli(e); });
+ setBool(request, kCHECK_SYSTEM_VARS_KEY,
+ [cm](bool e) { cm->SetCheckSystemVars(e); });
+
+ return request.Reply(Json::Value());
+}