cmServerProtocol.cxx 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmServerProtocol.h"
  4. #include "cmAlgorithms.h"
  5. #include "cmExternalMakefileProjectGenerator.h"
  6. #include "cmFileMonitor.h"
  7. #include "cmGeneratorExpression.h"
  8. #include "cmGeneratorTarget.h"
  9. #include "cmGlobalGenerator.h"
  10. #include "cmLinkLineComputer.h"
  11. #include "cmListFileCache.h"
  12. #include "cmLocalGenerator.h"
  13. #include "cmMakefile.h"
  14. #include "cmServer.h"
  15. #include "cmServerDictionary.h"
  16. #include "cmSourceFile.h"
  17. #include "cmState.h"
  18. #include "cmStateDirectory.h"
  19. #include "cmStateSnapshot.h"
  20. #include "cmStateTypes.h"
  21. #include "cmSystemTools.h"
  22. #include "cmTarget.h"
  23. #include "cm_uv.h"
  24. #include "cmake.h"
  25. #include <algorithm>
  26. #include <cassert>
  27. #include <cstddef>
  28. #include <functional>
  29. #include <limits>
  30. #include <map>
  31. #include <set>
  32. #include <string>
  33. #include <unordered_map>
  34. #include <vector>
  35. // Get rid of some windows macros:
  36. #undef max
  37. namespace {
  38. std::vector<std::string> getConfigurations(const cmake* cm)
  39. {
  40. std::vector<std::string> configurations;
  41. auto makefiles = cm->GetGlobalGenerator()->GetMakefiles();
  42. if (makefiles.empty()) {
  43. return configurations;
  44. }
  45. makefiles[0]->GetConfigurations(configurations);
  46. if (configurations.empty()) {
  47. configurations.push_back("");
  48. }
  49. return configurations;
  50. }
  51. bool hasString(const Json::Value& v, const std::string& s)
  52. {
  53. return !v.isNull() &&
  54. std::any_of(v.begin(), v.end(),
  55. [s](const Json::Value& i) { return i.asString() == s; });
  56. }
  57. template <class T>
  58. Json::Value fromStringList(const T& in)
  59. {
  60. Json::Value result = Json::arrayValue;
  61. for (const std::string& i : in) {
  62. result.append(i);
  63. }
  64. return result;
  65. }
  66. std::vector<std::string> toStringList(const Json::Value& in)
  67. {
  68. std::vector<std::string> result;
  69. for (const auto& it : in) {
  70. result.push_back(it.asString());
  71. }
  72. return result;
  73. }
  74. void getCMakeInputs(const cmGlobalGenerator* gg, const std::string& sourceDir,
  75. const std::string& buildDir,
  76. std::vector<std::string>* internalFiles,
  77. std::vector<std::string>* explicitFiles,
  78. std::vector<std::string>* tmpFiles)
  79. {
  80. const std::string cmakeRootDir = cmSystemTools::GetCMakeRoot() + '/';
  81. std::vector<cmMakefile*> const& makefiles = gg->GetMakefiles();
  82. for (auto it = makefiles.begin(); it != makefiles.end(); ++it) {
  83. const std::vector<std::string> listFiles = (*it)->GetListFiles();
  84. for (auto jt = listFiles.begin(); jt != listFiles.end(); ++jt) {
  85. const std::string startOfFile = jt->substr(0, cmakeRootDir.size());
  86. const bool isInternal = (startOfFile == cmakeRootDir);
  87. const bool isTemporary = !isInternal && (jt->find(buildDir + '/') == 0);
  88. std::string toAdd = *jt;
  89. if (!sourceDir.empty()) {
  90. const std::string& relative =
  91. cmSystemTools::RelativePath(sourceDir.c_str(), jt->c_str());
  92. if (toAdd.size() > relative.size()) {
  93. toAdd = relative;
  94. }
  95. }
  96. if (isInternal) {
  97. if (internalFiles) {
  98. internalFiles->push_back(toAdd);
  99. }
  100. } else {
  101. if (isTemporary) {
  102. if (tmpFiles) {
  103. tmpFiles->push_back(toAdd);
  104. }
  105. } else {
  106. if (explicitFiles) {
  107. explicitFiles->push_back(toAdd);
  108. }
  109. }
  110. }
  111. }
  112. }
  113. }
  114. } // namespace
  115. cmServerRequest::cmServerRequest(cmServer* server, cmConnection* connection,
  116. const std::string& t, const std::string& c,
  117. const Json::Value& d)
  118. : Type(t)
  119. , Cookie(c)
  120. , Data(d)
  121. , Connection(connection)
  122. , m_Server(server)
  123. {
  124. }
  125. void cmServerRequest::ReportProgress(int min, int current, int max,
  126. const std::string& message) const
  127. {
  128. this->m_Server->WriteProgress(*this, min, current, max, message);
  129. }
  130. void cmServerRequest::ReportMessage(const std::string& message,
  131. const std::string& title) const
  132. {
  133. m_Server->WriteMessage(*this, message, title);
  134. }
  135. cmServerResponse cmServerRequest::Reply(const Json::Value& data) const
  136. {
  137. cmServerResponse response(*this);
  138. response.SetData(data);
  139. return response;
  140. }
  141. cmServerResponse cmServerRequest::ReportError(const std::string& message) const
  142. {
  143. cmServerResponse response(*this);
  144. response.SetError(message);
  145. return response;
  146. }
  147. cmServerResponse::cmServerResponse(const cmServerRequest& request)
  148. : Type(request.Type)
  149. , Cookie(request.Cookie)
  150. {
  151. }
  152. void cmServerResponse::SetData(const Json::Value& data)
  153. {
  154. assert(this->m_Payload == PAYLOAD_UNKNOWN);
  155. if (!data[kCOOKIE_KEY].isNull() || !data[kTYPE_KEY].isNull()) {
  156. this->SetError("Response contains cookie or type field.");
  157. return;
  158. }
  159. this->m_Payload = PAYLOAD_DATA;
  160. this->m_Data = data;
  161. }
  162. void cmServerResponse::SetError(const std::string& message)
  163. {
  164. assert(this->m_Payload == PAYLOAD_UNKNOWN);
  165. this->m_Payload = PAYLOAD_ERROR;
  166. this->m_ErrorMessage = message;
  167. }
  168. bool cmServerResponse::IsComplete() const
  169. {
  170. return this->m_Payload != PAYLOAD_UNKNOWN;
  171. }
  172. bool cmServerResponse::IsError() const
  173. {
  174. assert(this->m_Payload != PAYLOAD_UNKNOWN);
  175. return this->m_Payload == PAYLOAD_ERROR;
  176. }
  177. std::string cmServerResponse::ErrorMessage() const
  178. {
  179. if (this->m_Payload == PAYLOAD_ERROR) {
  180. return this->m_ErrorMessage;
  181. }
  182. return std::string();
  183. }
  184. Json::Value cmServerResponse::Data() const
  185. {
  186. assert(this->m_Payload != PAYLOAD_UNKNOWN);
  187. return this->m_Data;
  188. }
  189. bool cmServerProtocol::Activate(cmServer* server,
  190. const cmServerRequest& request,
  191. std::string* errorMessage)
  192. {
  193. assert(server);
  194. this->m_Server = server;
  195. this->m_CMakeInstance = cm::make_unique<cmake>(cmake::RoleProject);
  196. const bool result = this->DoActivate(request, errorMessage);
  197. if (!result) {
  198. this->m_CMakeInstance = nullptr;
  199. }
  200. return result;
  201. }
  202. cmFileMonitor* cmServerProtocol::FileMonitor() const
  203. {
  204. return this->m_Server ? this->m_Server->FileMonitor() : nullptr;
  205. }
  206. void cmServerProtocol::SendSignal(const std::string& name,
  207. const Json::Value& data) const
  208. {
  209. if (this->m_Server) {
  210. this->m_Server->WriteSignal(name, data);
  211. }
  212. }
  213. cmake* cmServerProtocol::CMakeInstance() const
  214. {
  215. return this->m_CMakeInstance.get();
  216. }
  217. bool cmServerProtocol::DoActivate(const cmServerRequest& /*request*/,
  218. std::string* /*errorMessage*/)
  219. {
  220. return true;
  221. }
  222. std::pair<int, int> cmServerProtocol1::ProtocolVersion() const
  223. {
  224. return std::make_pair(1, 1);
  225. }
  226. static void setErrorMessage(std::string* errorMessage, const std::string& text)
  227. {
  228. if (errorMessage) {
  229. *errorMessage = text;
  230. }
  231. }
  232. static bool testHomeDirectory(cmState* state, std::string& value,
  233. std::string* errorMessage)
  234. {
  235. const std::string cachedValue =
  236. std::string(state->GetCacheEntryValue("CMAKE_HOME_DIRECTORY"));
  237. if (value.empty()) {
  238. value = cachedValue;
  239. return true;
  240. }
  241. const std::string suffix = "/CMakeLists.txt";
  242. const std::string cachedValueCML = cachedValue + suffix;
  243. const std::string valueCML = value + suffix;
  244. if (!cmSystemTools::SameFile(valueCML, cachedValueCML)) {
  245. setErrorMessage(errorMessage,
  246. std::string("\"CMAKE_HOME_DIRECTORY\" is set but "
  247. "incompatible with configured "
  248. "source directory value."));
  249. return false;
  250. }
  251. return true;
  252. }
  253. static bool testValue(cmState* state, const std::string& key,
  254. std::string& value, const std::string& keyDescription,
  255. std::string* errorMessage)
  256. {
  257. const char* entry = state->GetCacheEntryValue(key);
  258. const std::string cachedValue =
  259. entry == nullptr ? std::string() : std::string(entry);
  260. if (value.empty()) {
  261. value = cachedValue;
  262. }
  263. if (!cachedValue.empty() && cachedValue != value) {
  264. setErrorMessage(errorMessage, std::string("\"") + key +
  265. "\" is set but incompatible with configured " +
  266. keyDescription + " value.");
  267. return false;
  268. }
  269. return true;
  270. }
  271. bool cmServerProtocol1::DoActivate(const cmServerRequest& request,
  272. std::string* errorMessage)
  273. {
  274. std::string sourceDirectory = request.Data[kSOURCE_DIRECTORY_KEY].asString();
  275. const std::string buildDirectory =
  276. request.Data[kBUILD_DIRECTORY_KEY].asString();
  277. std::string generator = request.Data[kGENERATOR_KEY].asString();
  278. std::string extraGenerator = request.Data[kEXTRA_GENERATOR_KEY].asString();
  279. std::string toolset = request.Data[kTOOLSET_KEY].asString();
  280. std::string platform = request.Data[kPLATFORM_KEY].asString();
  281. if (buildDirectory.empty()) {
  282. setErrorMessage(errorMessage, std::string("\"") + kBUILD_DIRECTORY_KEY +
  283. "\" is missing.");
  284. return false;
  285. }
  286. cmake* cm = CMakeInstance();
  287. if (cmSystemTools::PathExists(buildDirectory)) {
  288. if (!cmSystemTools::FileIsDirectory(buildDirectory)) {
  289. setErrorMessage(errorMessage, std::string("\"") + kBUILD_DIRECTORY_KEY +
  290. "\" exists but is not a directory.");
  291. return false;
  292. }
  293. const std::string cachePath = cm->FindCacheFile(buildDirectory);
  294. if (cm->LoadCache(cachePath)) {
  295. cmState* state = cm->GetState();
  296. // Check generator:
  297. if (!testValue(state, "CMAKE_GENERATOR", generator, "generator",
  298. errorMessage)) {
  299. return false;
  300. }
  301. // check extra generator:
  302. if (!testValue(state, "CMAKE_EXTRA_GENERATOR", extraGenerator,
  303. "extra generator", errorMessage)) {
  304. return false;
  305. }
  306. // check sourcedir:
  307. if (!testHomeDirectory(state, sourceDirectory, errorMessage)) {
  308. return false;
  309. }
  310. // check toolset:
  311. if (!testValue(state, "CMAKE_GENERATOR_TOOLSET", toolset, "toolset",
  312. errorMessage)) {
  313. return false;
  314. }
  315. // check platform:
  316. if (!testValue(state, "CMAKE_GENERATOR_PLATFORM", platform, "platform",
  317. errorMessage)) {
  318. return false;
  319. }
  320. }
  321. }
  322. if (sourceDirectory.empty()) {
  323. setErrorMessage(errorMessage, std::string("\"") + kSOURCE_DIRECTORY_KEY +
  324. "\" is unset but required.");
  325. return false;
  326. }
  327. if (!cmSystemTools::FileIsDirectory(sourceDirectory)) {
  328. setErrorMessage(errorMessage, std::string("\"") + kSOURCE_DIRECTORY_KEY +
  329. "\" is not a directory.");
  330. return false;
  331. }
  332. if (generator.empty()) {
  333. setErrorMessage(errorMessage, std::string("\"") + kGENERATOR_KEY +
  334. "\" is unset but required.");
  335. return false;
  336. }
  337. std::vector<cmake::GeneratorInfo> generators;
  338. cm->GetRegisteredGenerators(generators);
  339. auto baseIt = std::find_if(generators.begin(), generators.end(),
  340. [&generator](const cmake::GeneratorInfo& info) {
  341. return info.name == generator;
  342. });
  343. if (baseIt == generators.end()) {
  344. setErrorMessage(errorMessage, std::string("Generator \"") + generator +
  345. "\" not supported.");
  346. return false;
  347. }
  348. auto extraIt = std::find_if(
  349. generators.begin(), generators.end(),
  350. [&generator, &extraGenerator](const cmake::GeneratorInfo& info) {
  351. return info.baseName == generator && info.extraName == extraGenerator;
  352. });
  353. if (extraIt == generators.end()) {
  354. setErrorMessage(errorMessage,
  355. std::string("The combination of generator \"" + generator +
  356. "\" and extra generator \"" + extraGenerator +
  357. "\" is not supported."));
  358. return false;
  359. }
  360. if (!extraIt->supportsToolset && !toolset.empty()) {
  361. setErrorMessage(errorMessage,
  362. std::string("Toolset was provided but is not supported by "
  363. "the requested generator."));
  364. return false;
  365. }
  366. if (!extraIt->supportsPlatform && !platform.empty()) {
  367. setErrorMessage(errorMessage,
  368. std::string("Platform was provided but is not supported "
  369. "by the requested generator."));
  370. return false;
  371. }
  372. this->GeneratorInfo =
  373. GeneratorInformation(generator, extraGenerator, toolset, platform,
  374. sourceDirectory, buildDirectory);
  375. this->m_State = STATE_ACTIVE;
  376. return true;
  377. }
  378. void cmServerProtocol1::HandleCMakeFileChanges(const std::string& path,
  379. int event, int status)
  380. {
  381. assert(status == 0);
  382. static_cast<void>(status);
  383. if (!m_isDirty) {
  384. m_isDirty = true;
  385. SendSignal(kDIRTY_SIGNAL, Json::objectValue);
  386. }
  387. Json::Value obj = Json::objectValue;
  388. obj[kPATH_KEY] = path;
  389. Json::Value properties = Json::arrayValue;
  390. if (event & UV_RENAME) {
  391. properties.append(kRENAME_PROPERTY_VALUE);
  392. }
  393. if (event & UV_CHANGE) {
  394. properties.append(kCHANGE_PROPERTY_VALUE);
  395. }
  396. obj[kPROPERTIES_KEY] = properties;
  397. SendSignal(kFILE_CHANGE_SIGNAL, obj);
  398. }
  399. const cmServerResponse cmServerProtocol1::Process(
  400. const cmServerRequest& request)
  401. {
  402. assert(this->m_State >= STATE_ACTIVE);
  403. if (request.Type == kCACHE_TYPE) {
  404. return this->ProcessCache(request);
  405. }
  406. if (request.Type == kCMAKE_INPUTS_TYPE) {
  407. return this->ProcessCMakeInputs(request);
  408. }
  409. if (request.Type == kCODE_MODEL_TYPE) {
  410. return this->ProcessCodeModel(request);
  411. }
  412. if (request.Type == kCOMPUTE_TYPE) {
  413. return this->ProcessCompute(request);
  414. }
  415. if (request.Type == kCONFIGURE_TYPE) {
  416. return this->ProcessConfigure(request);
  417. }
  418. if (request.Type == kFILESYSTEM_WATCHERS_TYPE) {
  419. return this->ProcessFileSystemWatchers(request);
  420. }
  421. if (request.Type == kGLOBAL_SETTINGS_TYPE) {
  422. return this->ProcessGlobalSettings(request);
  423. }
  424. if (request.Type == kSET_GLOBAL_SETTINGS_TYPE) {
  425. return this->ProcessSetGlobalSettings(request);
  426. }
  427. return request.ReportError("Unknown command!");
  428. }
  429. bool cmServerProtocol1::IsExperimental() const
  430. {
  431. return true;
  432. }
  433. cmServerResponse cmServerProtocol1::ProcessCache(
  434. const cmServerRequest& request)
  435. {
  436. cmState* state = this->CMakeInstance()->GetState();
  437. Json::Value result = Json::objectValue;
  438. std::vector<std::string> allKeys = state->GetCacheEntryKeys();
  439. Json::Value list = Json::arrayValue;
  440. std::vector<std::string> keys = toStringList(request.Data[kKEYS_KEY]);
  441. if (keys.empty()) {
  442. keys = allKeys;
  443. } else {
  444. for (const auto& i : keys) {
  445. if (std::find(allKeys.begin(), allKeys.end(), i) == allKeys.end()) {
  446. return request.ReportError("Key \"" + i + "\" not found in cache.");
  447. }
  448. }
  449. }
  450. std::sort(keys.begin(), keys.end());
  451. for (const auto& key : keys) {
  452. Json::Value entry = Json::objectValue;
  453. entry[kKEY_KEY] = key;
  454. entry[kTYPE_KEY] =
  455. cmState::CacheEntryTypeToString(state->GetCacheEntryType(key));
  456. entry[kVALUE_KEY] = state->GetCacheEntryValue(key);
  457. Json::Value props = Json::objectValue;
  458. bool haveProperties = false;
  459. for (const auto& prop : state->GetCacheEntryPropertyList(key)) {
  460. haveProperties = true;
  461. props[prop] = state->GetCacheEntryProperty(key, prop);
  462. }
  463. if (haveProperties) {
  464. entry[kPROPERTIES_KEY] = props;
  465. }
  466. list.append(entry);
  467. }
  468. result[kCACHE_KEY] = list;
  469. return request.Reply(result);
  470. }
  471. cmServerResponse cmServerProtocol1::ProcessCMakeInputs(
  472. const cmServerRequest& request)
  473. {
  474. if (this->m_State < STATE_CONFIGURED) {
  475. return request.ReportError("This instance was not yet configured.");
  476. }
  477. const cmake* cm = this->CMakeInstance();
  478. const cmGlobalGenerator* gg = cm->GetGlobalGenerator();
  479. const std::string cmakeRootDir = cmSystemTools::GetCMakeRoot();
  480. const std::string buildDir = cm->GetHomeOutputDirectory();
  481. const std::string sourceDir = cm->GetHomeDirectory();
  482. Json::Value result = Json::objectValue;
  483. result[kSOURCE_DIRECTORY_KEY] = sourceDir;
  484. result[kCMAKE_ROOT_DIRECTORY_KEY] = cmakeRootDir;
  485. std::vector<std::string> internalFiles;
  486. std::vector<std::string> explicitFiles;
  487. std::vector<std::string> tmpFiles;
  488. getCMakeInputs(gg, sourceDir, buildDir, &internalFiles, &explicitFiles,
  489. &tmpFiles);
  490. Json::Value array = Json::arrayValue;
  491. Json::Value tmp = Json::objectValue;
  492. tmp[kIS_CMAKE_KEY] = true;
  493. tmp[kIS_TEMPORARY_KEY] = false;
  494. tmp[kSOURCES_KEY] = fromStringList(internalFiles);
  495. array.append(tmp);
  496. tmp = Json::objectValue;
  497. tmp[kIS_CMAKE_KEY] = false;
  498. tmp[kIS_TEMPORARY_KEY] = false;
  499. tmp[kSOURCES_KEY] = fromStringList(explicitFiles);
  500. array.append(tmp);
  501. tmp = Json::objectValue;
  502. tmp[kIS_CMAKE_KEY] = false;
  503. tmp[kIS_TEMPORARY_KEY] = true;
  504. tmp[kSOURCES_KEY] = fromStringList(tmpFiles);
  505. array.append(tmp);
  506. result[kBUILD_FILES_KEY] = array;
  507. return request.Reply(result);
  508. }
  509. class LanguageData
  510. {
  511. public:
  512. bool operator==(const LanguageData& other) const;
  513. void SetDefines(const std::set<std::string>& defines);
  514. bool IsGenerated = false;
  515. std::string Language;
  516. std::string Flags;
  517. std::vector<std::string> Defines;
  518. std::vector<std::pair<std::string, bool>> IncludePathList;
  519. };
  520. bool LanguageData::operator==(const LanguageData& other) const
  521. {
  522. return Language == other.Language && Defines == other.Defines &&
  523. Flags == other.Flags && IncludePathList == other.IncludePathList &&
  524. IsGenerated == other.IsGenerated;
  525. }
  526. void LanguageData::SetDefines(const std::set<std::string>& defines)
  527. {
  528. std::vector<std::string> result;
  529. for (const auto& i : defines) {
  530. result.push_back(i);
  531. }
  532. std::sort(result.begin(), result.end());
  533. Defines = result;
  534. }
  535. namespace std {
  536. template <>
  537. struct hash<LanguageData>
  538. {
  539. std::size_t operator()(const LanguageData& in) const
  540. {
  541. using std::hash;
  542. size_t result =
  543. hash<std::string>()(in.Language) ^ hash<std::string>()(in.Flags);
  544. for (const auto& i : in.IncludePathList) {
  545. result = result ^ (hash<std::string>()(i.first) ^
  546. (i.second ? std::numeric_limits<size_t>::max() : 0));
  547. }
  548. for (const auto& i : in.Defines) {
  549. result = result ^ hash<std::string>()(i);
  550. }
  551. result =
  552. result ^ (in.IsGenerated ? std::numeric_limits<size_t>::max() : 0);
  553. return result;
  554. }
  555. };
  556. } // namespace std
  557. static Json::Value DumpSourceFileGroup(const LanguageData& data,
  558. const std::vector<std::string>& files,
  559. const std::string& baseDir)
  560. {
  561. Json::Value result = Json::objectValue;
  562. if (!data.Language.empty()) {
  563. result[kLANGUAGE_KEY] = data.Language;
  564. if (!data.Flags.empty()) {
  565. result[kCOMPILE_FLAGS_KEY] = data.Flags;
  566. }
  567. if (!data.IncludePathList.empty()) {
  568. Json::Value includes = Json::arrayValue;
  569. for (const auto& i : data.IncludePathList) {
  570. Json::Value tmp = Json::objectValue;
  571. tmp[kPATH_KEY] = i.first;
  572. if (i.second) {
  573. tmp[kIS_SYSTEM_KEY] = i.second;
  574. }
  575. includes.append(tmp);
  576. }
  577. result[kINCLUDE_PATH_KEY] = includes;
  578. }
  579. if (!data.Defines.empty()) {
  580. result[kDEFINES_KEY] = fromStringList(data.Defines);
  581. }
  582. }
  583. result[kIS_GENERATED_KEY] = data.IsGenerated;
  584. Json::Value sourcesValue = Json::arrayValue;
  585. for (const auto& i : files) {
  586. const std::string relPath =
  587. cmSystemTools::RelativePath(baseDir.c_str(), i.c_str());
  588. sourcesValue.append(relPath.size() < i.size() ? relPath : i);
  589. }
  590. result[kSOURCES_KEY] = sourcesValue;
  591. return result;
  592. }
  593. static Json::Value DumpSourceFilesList(
  594. cmGeneratorTarget* target, const std::string& config,
  595. const std::map<std::string, LanguageData>& languageDataMap)
  596. {
  597. // Collect sourcefile groups:
  598. std::vector<cmSourceFile*> files;
  599. target->GetSourceFiles(files, config);
  600. std::unordered_map<LanguageData, std::vector<std::string>> fileGroups;
  601. for (cmSourceFile* file : files) {
  602. LanguageData fileData;
  603. fileData.Language = file->GetLanguage();
  604. if (!fileData.Language.empty()) {
  605. const LanguageData& ld = languageDataMap.at(fileData.Language);
  606. cmLocalGenerator* lg = target->GetLocalGenerator();
  607. std::string compileFlags = ld.Flags;
  608. if (const char* cflags = file->GetProperty("COMPILE_FLAGS")) {
  609. cmGeneratorExpression ge;
  610. auto cge = ge.Parse(cflags);
  611. const char* processed =
  612. cge->Evaluate(target->GetLocalGenerator(), config);
  613. lg->AppendFlags(compileFlags, processed);
  614. }
  615. fileData.Flags = compileFlags;
  616. fileData.IncludePathList = ld.IncludePathList;
  617. std::set<std::string> defines;
  618. lg->AppendDefines(defines, file->GetProperty("COMPILE_DEFINITIONS"));
  619. const std::string defPropName =
  620. "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config);
  621. lg->AppendDefines(defines, file->GetProperty(defPropName));
  622. defines.insert(ld.Defines.begin(), ld.Defines.end());
  623. fileData.SetDefines(defines);
  624. }
  625. fileData.IsGenerated = file->GetPropertyAsBool("GENERATED");
  626. std::vector<std::string>& groupFileList = fileGroups[fileData];
  627. groupFileList.push_back(file->GetFullPath());
  628. }
  629. const std::string baseDir = target->Makefile->GetCurrentSourceDirectory();
  630. Json::Value result = Json::arrayValue;
  631. for (auto it = fileGroups.begin(); it != fileGroups.end(); ++it) {
  632. Json::Value group = DumpSourceFileGroup(it->first, it->second, baseDir);
  633. if (!group.isNull()) {
  634. result.append(group);
  635. }
  636. }
  637. return result;
  638. }
  639. static Json::Value DumpBacktrace(const cmListFileBacktrace& backtrace)
  640. {
  641. Json::Value result = Json::arrayValue;
  642. cmListFileBacktrace backtraceCopy = backtrace;
  643. while (!backtraceCopy.Top().FilePath.empty()) {
  644. Json::Value entry = Json::objectValue;
  645. entry[kPATH_KEY] = backtraceCopy.Top().FilePath;
  646. if (backtraceCopy.Top().Line) {
  647. entry[kLINE_NUMBER_KEY] = static_cast<int>(backtraceCopy.Top().Line);
  648. }
  649. if (!backtraceCopy.Top().Name.empty()) {
  650. entry[kNAME_KEY] = backtraceCopy.Top().Name;
  651. }
  652. result.append(entry);
  653. backtraceCopy = backtraceCopy.Pop();
  654. }
  655. return result;
  656. }
  657. static void DumpBacktraceRange(Json::Value& result, const std::string& type,
  658. cmBacktraceRange range)
  659. {
  660. for (const auto& bt : range) {
  661. Json::Value obj = Json::objectValue;
  662. obj[kTYPE_KEY] = type;
  663. obj[kBACKTRACE_KEY] = DumpBacktrace(bt);
  664. result.append(obj);
  665. }
  666. }
  667. static Json::Value DumpTarget(cmGeneratorTarget* target,
  668. const std::string& config)
  669. {
  670. cmLocalGenerator* lg = target->GetLocalGenerator();
  671. const cmState* state = lg->GetState();
  672. const cmStateEnums::TargetType type = target->GetType();
  673. const std::string typeName = state->GetTargetTypeName(type);
  674. Json::Value ttl = Json::arrayValue;
  675. ttl.append("EXECUTABLE");
  676. ttl.append("STATIC_LIBRARY");
  677. ttl.append("SHARED_LIBRARY");
  678. ttl.append("MODULE_LIBRARY");
  679. ttl.append("OBJECT_LIBRARY");
  680. ttl.append("UTILITY");
  681. ttl.append("INTERFACE_LIBRARY");
  682. if (!hasString(ttl, typeName) || target->IsImported()) {
  683. return Json::Value();
  684. }
  685. Json::Value result = Json::objectValue;
  686. result[kNAME_KEY] = target->GetName();
  687. result[kTYPE_KEY] = typeName;
  688. result[kSOURCE_DIRECTORY_KEY] = lg->GetCurrentSourceDirectory();
  689. result[kBUILD_DIRECTORY_KEY] = lg->GetCurrentBinaryDirectory();
  690. if (type == cmStateEnums::INTERFACE_LIBRARY) {
  691. return result;
  692. }
  693. result[kFULL_NAME_KEY] = target->GetFullName(config);
  694. Json::Value crossRefs = Json::objectValue;
  695. crossRefs[kBACKTRACE_KEY] = DumpBacktrace(target->Target->GetBacktrace());
  696. Json::Value statements = Json::arrayValue;
  697. DumpBacktraceRange(statements, "target_compile_definitions",
  698. target->Target->GetCompileDefinitionsBacktraces());
  699. DumpBacktraceRange(statements, "target_include_directories",
  700. target->Target->GetIncludeDirectoriesBacktraces());
  701. DumpBacktraceRange(statements, "target_compile_options",
  702. target->Target->GetCompileOptionsBacktraces());
  703. DumpBacktraceRange(statements, "target_link_libraries",
  704. target->Target->GetLinkImplementationBacktraces());
  705. crossRefs[kRELATED_STATEMENTS_KEY] = std::move(statements);
  706. result[kTARGET_CROSS_REFERENCES_KEY] = std::move(crossRefs);
  707. if (target->HaveWellDefinedOutputFiles()) {
  708. Json::Value artifacts = Json::arrayValue;
  709. artifacts.append(
  710. target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact));
  711. if (target->IsDLLPlatform()) {
  712. artifacts.append(
  713. target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact));
  714. const cmGeneratorTarget::OutputInfo* output =
  715. target->GetOutputInfo(config);
  716. if (output && !output->PdbDir.empty()) {
  717. artifacts.append(output->PdbDir + '/' + target->GetPDBName(config));
  718. }
  719. }
  720. result[kARTIFACTS_KEY] = artifacts;
  721. result[kLINKER_LANGUAGE_KEY] = target->GetLinkerLanguage(config);
  722. std::string linkLibs;
  723. std::string linkFlags;
  724. std::string linkLanguageFlags;
  725. std::string frameworkPath;
  726. std::string linkPath;
  727. cmLinkLineComputer linkLineComputer(lg,
  728. lg->GetStateSnapshot().GetDirectory());
  729. lg->GetTargetFlags(&linkLineComputer, config, linkLibs, linkLanguageFlags,
  730. linkFlags, frameworkPath, linkPath, target);
  731. linkLibs = cmSystemTools::TrimWhitespace(linkLibs);
  732. linkFlags = cmSystemTools::TrimWhitespace(linkFlags);
  733. linkLanguageFlags = cmSystemTools::TrimWhitespace(linkLanguageFlags);
  734. frameworkPath = cmSystemTools::TrimWhitespace(frameworkPath);
  735. linkPath = cmSystemTools::TrimWhitespace(linkPath);
  736. if (!cmSystemTools::TrimWhitespace(linkLibs).empty()) {
  737. result[kLINK_LIBRARIES_KEY] = linkLibs;
  738. }
  739. if (!cmSystemTools::TrimWhitespace(linkFlags).empty()) {
  740. result[kLINK_FLAGS_KEY] = linkFlags;
  741. }
  742. if (!cmSystemTools::TrimWhitespace(linkLanguageFlags).empty()) {
  743. result[kLINK_LANGUAGE_FLAGS_KEY] = linkLanguageFlags;
  744. }
  745. if (!frameworkPath.empty()) {
  746. result[kFRAMEWORK_PATH_KEY] = frameworkPath;
  747. }
  748. if (!linkPath.empty()) {
  749. result[kLINK_PATH_KEY] = linkPath;
  750. }
  751. const std::string sysroot =
  752. lg->GetMakefile()->GetSafeDefinition("CMAKE_SYSROOT");
  753. if (!sysroot.empty()) {
  754. result[kSYSROOT_KEY] = sysroot;
  755. }
  756. }
  757. std::set<std::string> languages;
  758. target->GetLanguages(languages, config);
  759. std::map<std::string, LanguageData> languageDataMap;
  760. for (const auto& lang : languages) {
  761. LanguageData& ld = languageDataMap[lang];
  762. ld.Language = lang;
  763. lg->GetTargetCompileFlags(target, config, lang, ld.Flags);
  764. std::set<std::string> defines;
  765. lg->GetTargetDefines(target, config, lang, defines);
  766. ld.SetDefines(defines);
  767. std::vector<std::string> includePathList;
  768. lg->GetIncludeDirectories(includePathList, target, lang, config, true);
  769. for (auto i : includePathList) {
  770. ld.IncludePathList.push_back(
  771. std::make_pair(i, target->IsSystemIncludeDirectory(i, config)));
  772. }
  773. }
  774. Json::Value sourceGroupsValue =
  775. DumpSourceFilesList(target, config, languageDataMap);
  776. if (!sourceGroupsValue.empty()) {
  777. result[kFILE_GROUPS_KEY] = sourceGroupsValue;
  778. }
  779. return result;
  780. }
  781. static Json::Value DumpTargetsList(
  782. const std::vector<cmLocalGenerator*>& generators, const std::string& config)
  783. {
  784. Json::Value result = Json::arrayValue;
  785. std::vector<cmGeneratorTarget*> targetList;
  786. for (const auto& lgIt : generators) {
  787. const auto& list = lgIt->GetGeneratorTargets();
  788. targetList.insert(targetList.end(), list.begin(), list.end());
  789. }
  790. std::sort(targetList.begin(), targetList.end());
  791. for (cmGeneratorTarget* target : targetList) {
  792. Json::Value tmp = DumpTarget(target, config);
  793. if (!tmp.isNull()) {
  794. result.append(tmp);
  795. }
  796. }
  797. return result;
  798. }
  799. static Json::Value DumpProjectList(const cmake* cm, std::string const& config)
  800. {
  801. Json::Value result = Json::arrayValue;
  802. auto globalGen = cm->GetGlobalGenerator();
  803. for (const auto& projectIt : globalGen->GetProjectMap()) {
  804. Json::Value pObj = Json::objectValue;
  805. pObj[kNAME_KEY] = projectIt.first;
  806. // All Projects must have at least one local generator
  807. assert(!projectIt.second.empty());
  808. const cmLocalGenerator* lg = projectIt.second.at(0);
  809. // Project structure information:
  810. const cmMakefile* mf = lg->GetMakefile();
  811. pObj[kSOURCE_DIRECTORY_KEY] = mf->GetCurrentSourceDirectory();
  812. pObj[kBUILD_DIRECTORY_KEY] = mf->GetCurrentBinaryDirectory();
  813. pObj[kTARGETS_KEY] = DumpTargetsList(projectIt.second, config);
  814. result.append(pObj);
  815. }
  816. return result;
  817. }
  818. static Json::Value DumpConfiguration(const cmake* cm,
  819. const std::string& config)
  820. {
  821. Json::Value result = Json::objectValue;
  822. result[kNAME_KEY] = config;
  823. result[kPROJECTS_KEY] = DumpProjectList(cm, config);
  824. return result;
  825. }
  826. static Json::Value DumpConfigurationsList(const cmake* cm)
  827. {
  828. Json::Value result = Json::arrayValue;
  829. for (const std::string& c : getConfigurations(cm)) {
  830. result.append(DumpConfiguration(cm, c));
  831. }
  832. return result;
  833. }
  834. cmServerResponse cmServerProtocol1::ProcessCodeModel(
  835. const cmServerRequest& request)
  836. {
  837. if (this->m_State != STATE_COMPUTED) {
  838. return request.ReportError("No build system was generated yet.");
  839. }
  840. Json::Value result = Json::objectValue;
  841. result[kCONFIGURATIONS_KEY] = DumpConfigurationsList(this->CMakeInstance());
  842. return request.Reply(result);
  843. }
  844. cmServerResponse cmServerProtocol1::ProcessCompute(
  845. const cmServerRequest& request)
  846. {
  847. if (this->m_State > STATE_CONFIGURED) {
  848. return request.ReportError("This build system was already generated.");
  849. }
  850. if (this->m_State < STATE_CONFIGURED) {
  851. return request.ReportError("This project was not configured yet.");
  852. }
  853. cmake* cm = this->CMakeInstance();
  854. int ret = cm->Generate();
  855. if (ret < 0) {
  856. return request.ReportError("Failed to compute build system.");
  857. }
  858. m_State = STATE_COMPUTED;
  859. return request.Reply(Json::Value());
  860. }
  861. cmServerResponse cmServerProtocol1::ProcessConfigure(
  862. const cmServerRequest& request)
  863. {
  864. if (this->m_State == STATE_INACTIVE) {
  865. return request.ReportError("This instance is inactive.");
  866. }
  867. FileMonitor()->StopMonitoring();
  868. std::string errorMessage;
  869. cmake* cm = this->CMakeInstance();
  870. this->GeneratorInfo.SetupGenerator(cm, &errorMessage);
  871. if (!errorMessage.empty()) {
  872. return request.ReportError(errorMessage);
  873. }
  874. // Make sure the types of cacheArguments matches (if given):
  875. std::vector<std::string> cacheArgs = { "unused" };
  876. bool cacheArgumentsError = false;
  877. const Json::Value passedArgs = request.Data[kCACHE_ARGUMENTS_KEY];
  878. if (!passedArgs.isNull()) {
  879. if (passedArgs.isString()) {
  880. cacheArgs.push_back(passedArgs.asString());
  881. } else if (passedArgs.isArray()) {
  882. for (auto i = passedArgs.begin(); i != passedArgs.end(); ++i) {
  883. if (!i->isString()) {
  884. cacheArgumentsError = true;
  885. break;
  886. }
  887. cacheArgs.push_back(i->asString());
  888. }
  889. } else {
  890. cacheArgumentsError = true;
  891. }
  892. }
  893. if (cacheArgumentsError) {
  894. request.ReportError(
  895. "cacheArguments must be unset, a string or an array of strings.");
  896. }
  897. std::string sourceDir = cm->GetHomeDirectory();
  898. const std::string buildDir = cm->GetHomeOutputDirectory();
  899. cmGlobalGenerator* gg = cm->GetGlobalGenerator();
  900. if (buildDir.empty()) {
  901. return request.ReportError("No build directory set via Handshake.");
  902. }
  903. if (cm->LoadCache(buildDir)) {
  904. // build directory has been set up before
  905. const char* cachedSourceDir =
  906. cm->GetState()->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY");
  907. if (!cachedSourceDir) {
  908. return request.ReportError("No CMAKE_HOME_DIRECTORY found in cache.");
  909. }
  910. if (sourceDir.empty()) {
  911. sourceDir = std::string(cachedSourceDir);
  912. cm->SetHomeDirectory(sourceDir);
  913. }
  914. const char* cachedGenerator =
  915. cm->GetState()->GetInitializedCacheValue("CMAKE_GENERATOR");
  916. if (cachedGenerator) {
  917. if (gg && gg->GetName() != cachedGenerator) {
  918. return request.ReportError("Configured generator does not match with "
  919. "CMAKE_GENERATOR found in cache.");
  920. }
  921. }
  922. } else {
  923. // build directory has not been set up before
  924. if (sourceDir.empty()) {
  925. return request.ReportError("No sourceDirectory set via "
  926. "setGlobalSettings and no cache found in "
  927. "buildDirectory.");
  928. }
  929. }
  930. cmSystemTools::ResetErrorOccuredFlag(); // Reset error state
  931. if (cm->AddCMakePaths() != 1) {
  932. return request.ReportError("Failed to set CMake paths.");
  933. }
  934. if (!cm->SetCacheArgs(cacheArgs)) {
  935. return request.ReportError("cacheArguments could not be set.");
  936. }
  937. int ret = cm->Configure();
  938. if (ret < 0) {
  939. return request.ReportError("Configuration failed.");
  940. }
  941. std::vector<std::string> toWatchList;
  942. getCMakeInputs(gg, std::string(), buildDir, nullptr, &toWatchList, nullptr);
  943. FileMonitor()->MonitorPaths(toWatchList,
  944. [this](const std::string& p, int e, int s) {
  945. this->HandleCMakeFileChanges(p, e, s);
  946. });
  947. m_State = STATE_CONFIGURED;
  948. m_isDirty = false;
  949. return request.Reply(Json::Value());
  950. }
  951. cmServerResponse cmServerProtocol1::ProcessGlobalSettings(
  952. const cmServerRequest& request)
  953. {
  954. cmake* cm = this->CMakeInstance();
  955. Json::Value obj = Json::objectValue;
  956. // Capabilities information:
  957. obj[kCAPABILITIES_KEY] = cm->ReportCapabilitiesJson(true);
  958. obj[kDEBUG_OUTPUT_KEY] = cm->GetDebugOutput();
  959. obj[kTRACE_KEY] = cm->GetTrace();
  960. obj[kTRACE_EXPAND_KEY] = cm->GetTraceExpand();
  961. obj[kWARN_UNINITIALIZED_KEY] = cm->GetWarnUninitialized();
  962. obj[kWARN_UNUSED_KEY] = cm->GetWarnUnused();
  963. obj[kWARN_UNUSED_CLI_KEY] = cm->GetWarnUnusedCli();
  964. obj[kCHECK_SYSTEM_VARS_KEY] = cm->GetCheckSystemVars();
  965. obj[kSOURCE_DIRECTORY_KEY] = this->GeneratorInfo.SourceDirectory;
  966. obj[kBUILD_DIRECTORY_KEY] = this->GeneratorInfo.BuildDirectory;
  967. // Currently used generator:
  968. obj[kGENERATOR_KEY] = this->GeneratorInfo.GeneratorName;
  969. obj[kEXTRA_GENERATOR_KEY] = this->GeneratorInfo.ExtraGeneratorName;
  970. return request.Reply(obj);
  971. }
  972. static void setBool(const cmServerRequest& request, const std::string& key,
  973. std::function<void(bool)> const& setter)
  974. {
  975. if (request.Data[key].isNull()) {
  976. return;
  977. }
  978. setter(request.Data[key].asBool());
  979. }
  980. cmServerResponse cmServerProtocol1::ProcessSetGlobalSettings(
  981. const cmServerRequest& request)
  982. {
  983. const std::vector<std::string> boolValues = {
  984. kDEBUG_OUTPUT_KEY, kTRACE_KEY, kTRACE_EXPAND_KEY,
  985. kWARN_UNINITIALIZED_KEY, kWARN_UNUSED_KEY, kWARN_UNUSED_CLI_KEY,
  986. kCHECK_SYSTEM_VARS_KEY
  987. };
  988. for (const auto& i : boolValues) {
  989. if (!request.Data[i].isNull() && !request.Data[i].isBool()) {
  990. return request.ReportError("\"" + i +
  991. "\" must be unset or a bool value.");
  992. }
  993. }
  994. cmake* cm = this->CMakeInstance();
  995. setBool(request, kDEBUG_OUTPUT_KEY,
  996. [cm](bool e) { cm->SetDebugOutputOn(e); });
  997. setBool(request, kTRACE_KEY, [cm](bool e) { cm->SetTrace(e); });
  998. setBool(request, kTRACE_EXPAND_KEY, [cm](bool e) { cm->SetTraceExpand(e); });
  999. setBool(request, kWARN_UNINITIALIZED_KEY,
  1000. [cm](bool e) { cm->SetWarnUninitialized(e); });
  1001. setBool(request, kWARN_UNUSED_KEY, [cm](bool e) { cm->SetWarnUnused(e); });
  1002. setBool(request, kWARN_UNUSED_CLI_KEY,
  1003. [cm](bool e) { cm->SetWarnUnusedCli(e); });
  1004. setBool(request, kCHECK_SYSTEM_VARS_KEY,
  1005. [cm](bool e) { cm->SetCheckSystemVars(e); });
  1006. return request.Reply(Json::Value());
  1007. }
  1008. cmServerResponse cmServerProtocol1::ProcessFileSystemWatchers(
  1009. const cmServerRequest& request)
  1010. {
  1011. const cmFileMonitor* const fm = FileMonitor();
  1012. Json::Value result = Json::objectValue;
  1013. Json::Value files = Json::arrayValue;
  1014. for (const auto& f : fm->WatchedFiles()) {
  1015. files.append(f);
  1016. }
  1017. Json::Value directories = Json::arrayValue;
  1018. for (const auto& d : fm->WatchedDirectories()) {
  1019. directories.append(d);
  1020. }
  1021. result[kWATCHED_FILES_KEY] = files;
  1022. result[kWATCHED_DIRECTORIES_KEY] = directories;
  1023. return request.Reply(result);
  1024. }
  1025. cmServerProtocol1::GeneratorInformation::GeneratorInformation(
  1026. const std::string& generatorName, const std::string& extraGeneratorName,
  1027. const std::string& toolset, const std::string& platform,
  1028. const std::string& sourceDirectory, const std::string& buildDirectory)
  1029. : GeneratorName(generatorName)
  1030. , ExtraGeneratorName(extraGeneratorName)
  1031. , Toolset(toolset)
  1032. , Platform(platform)
  1033. , SourceDirectory(sourceDirectory)
  1034. , BuildDirectory(buildDirectory)
  1035. {
  1036. }
  1037. void cmServerProtocol1::GeneratorInformation::SetupGenerator(
  1038. cmake* cm, std::string* errorMessage)
  1039. {
  1040. const std::string fullGeneratorName =
  1041. cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
  1042. GeneratorName, ExtraGeneratorName);
  1043. cm->SetHomeDirectory(SourceDirectory);
  1044. cm->SetHomeOutputDirectory(BuildDirectory);
  1045. cmGlobalGenerator* gg = cm->CreateGlobalGenerator(fullGeneratorName);
  1046. if (!gg) {
  1047. setErrorMessage(
  1048. errorMessage,
  1049. std::string("Could not set up the requested combination of \"") +
  1050. kGENERATOR_KEY + "\" and \"" + kEXTRA_GENERATOR_KEY + "\"");
  1051. return;
  1052. }
  1053. cm->SetGlobalGenerator(gg);
  1054. cm->SetGeneratorToolset(Toolset);
  1055. cm->SetGeneratorPlatform(Platform);
  1056. }