cmake-server: Report server mode availablitily in Capabilities

Report the availability of the server-mode in the output of
cmake -E capabilities.
This commit is contained in:
Tobias Hunger 2016-09-13 11:05:39 +02:00 committed by Brad King
parent 419ad05101
commit cd049f012e
3 changed files with 11 additions and 11 deletions

View File

@ -234,7 +234,7 @@ cmake::~cmake()
} }
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
Json::Value cmake::ReportCapabilitiesJson() const Json::Value cmake::ReportCapabilitiesJson(bool haveServerMode) const
{ {
Json::Value obj = Json::objectValue; Json::Value obj = Json::objectValue;
// Version information: // Version information:
@ -280,22 +280,18 @@ Json::Value cmake::ReportCapabilitiesJson() const
generators.append(i->second); generators.append(i->second);
} }
obj["generators"] = generators; obj["generators"] = generators;
obj["serverMode"] = haveServerMode;
#if defined(HAVE_SERVER_MODE) && HAVE_SERVER_MODE
obj["serverMode"] = true;
#else
obj["serverMode"] = false;
#endif
return obj; return obj;
} }
#endif #endif
std::string cmake::ReportCapabilities() const std::string cmake::ReportCapabilities(bool haveServerMode) const
{ {
std::string result; std::string result;
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
Json::FastWriter writer; Json::FastWriter writer;
result = writer.write(this->ReportCapabilitiesJson()); result = writer.write(this->ReportCapabilitiesJson(haveServerMode));
#else #else
result = "Not supported"; result = "Not supported";
#endif #endif

View File

@ -123,9 +123,9 @@ public:
~cmake(); ~cmake();
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
Json::Value ReportCapabilitiesJson() const; Json::Value ReportCapabilitiesJson(bool haveServerMode) const;
#endif #endif
std::string ReportCapabilities() const; std::string ReportCapabilities(bool haveServerMode) const;
static const char* GetCMakeFilesDirectory() { return "/CMakeFiles"; } static const char* GetCMakeFilesDirectory() { return "/CMakeFiles"; }
static const char* GetCMakeFilesDirectoryPostSlash() static const char* GetCMakeFilesDirectoryPostSlash()

View File

@ -527,7 +527,11 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
return 1; return 1;
} }
cmake cm; cmake cm;
std::cout << cm.ReportCapabilities(); #if defined(HAVE_SERVER_MODE) && HAVE_SERVER_MODE
std::cout << cm.ReportCapabilities(true);
#else
std::cout << cm.ReportCapabilities(false);
#endif
return 0; return 0;
} }