QCMake.cxx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  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 "QCMake.h"
  4. #include <algorithm>
  5. #include <cm/memory>
  6. #include <QCoreApplication>
  7. #include <QDir>
  8. #include <QString>
  9. #include <QVector>
  10. #include "cmExternalMakefileProjectGenerator.h"
  11. #include "cmGlobalGenerator.h"
  12. #include "cmMessageMetadata.h"
  13. #include "cmState.h"
  14. #include "cmStringAlgorithms.h"
  15. #include "cmSystemTools.h"
  16. #ifdef Q_OS_WIN
  17. # include "qt_windows.h" // For SetErrorMode
  18. #endif
  19. QCMake::QCMake(QObject* p)
  20. : QObject(p)
  21. , StartEnvironment(QProcessEnvironment::systemEnvironment())
  22. , Environment(QProcessEnvironment::systemEnvironment())
  23. {
  24. this->WarnUninitializedMode = false;
  25. qRegisterMetaType<QCMakeProperty>();
  26. qRegisterMetaType<QCMakePropertyList>();
  27. qRegisterMetaType<QProcessEnvironment>();
  28. qRegisterMetaType<QVector<QCMakePreset>>();
  29. qRegisterMetaType<cmCMakePresetsFile::ReadFileResult>();
  30. cmSystemTools::DisableRunCommandOutput();
  31. cmSystemTools::SetRunCommandHideConsole(true);
  32. cmSystemTools::SetMessageCallback(
  33. [this](std::string const& msg, const cmMessageMetadata& md) {
  34. this->messageCallback(msg, md.title);
  35. });
  36. cmSystemTools::SetStdoutCallback(
  37. [this](std::string const& msg) { this->stdoutCallback(msg); });
  38. cmSystemTools::SetStderrCallback(
  39. [this](std::string const& msg) { this->stderrCallback(msg); });
  40. this->CMakeInstance =
  41. cm::make_unique<cmake>(cmake::RoleProject, cmState::Project);
  42. this->CMakeInstance->SetCMakeEditCommand(
  43. cmSystemTools::GetCMakeGUICommand());
  44. this->CMakeInstance->SetProgressCallback(
  45. [this](const std::string& msg, float percent) {
  46. this->progressCallback(msg, percent);
  47. });
  48. cmSystemTools::SetInterruptCallback(
  49. [this] { return this->interruptCallback(); });
  50. std::vector<cmake::GeneratorInfo> generators;
  51. this->CMakeInstance->GetRegisteredGenerators(
  52. generators, /*includeNamesWithPlatform=*/false);
  53. for (cmake::GeneratorInfo const& gen : generators) {
  54. this->AvailableGenerators.push_back(gen);
  55. }
  56. connect(&this->LoadPresetsTimer, &QTimer::timeout, this, [this]() {
  57. this->loadPresets();
  58. if (!this->PresetName.isEmpty() &&
  59. this->CMakePresetsFile.ConfigurePresets.find(
  60. std::string(this->PresetName.toLocal8Bit())) ==
  61. this->CMakePresetsFile.ConfigurePresets.end()) {
  62. this->setPreset(QString{});
  63. }
  64. });
  65. this->LoadPresetsTimer.start(1000);
  66. }
  67. QCMake::~QCMake() = default;
  68. void QCMake::loadCache(const QString& dir)
  69. {
  70. this->setBinaryDirectory(dir);
  71. }
  72. void QCMake::setSourceDirectory(const QString& _dir)
  73. {
  74. QString dir = QString::fromLocal8Bit(
  75. cmSystemTools::GetActualCaseForPath(_dir.toLocal8Bit().data()).c_str());
  76. if (this->SourceDirectory != dir) {
  77. this->SourceDirectory = QDir::fromNativeSeparators(dir);
  78. emit this->sourceDirChanged(this->SourceDirectory);
  79. this->loadPresets();
  80. this->setPreset(QString{});
  81. }
  82. }
  83. void QCMake::setBinaryDirectory(const QString& _dir)
  84. {
  85. QString dir = QString::fromLocal8Bit(
  86. cmSystemTools::GetActualCaseForPath(_dir.toLocal8Bit().data()).c_str());
  87. if (this->BinaryDirectory != dir) {
  88. this->BinaryDirectory = QDir::fromNativeSeparators(dir);
  89. emit this->binaryDirChanged(this->BinaryDirectory);
  90. cmState* state = this->CMakeInstance->GetState();
  91. this->setGenerator(QString());
  92. this->setToolset(QString());
  93. this->setPlatform(QString());
  94. if (!this->CMakeInstance->LoadCache(
  95. this->BinaryDirectory.toLocal8Bit().data())) {
  96. QDir testDir(this->BinaryDirectory);
  97. if (testDir.exists("CMakeCache.txt")) {
  98. cmSystemTools::Error(
  99. "There is a CMakeCache.txt file for the current binary "
  100. "tree but cmake does not have permission to read it. "
  101. "Please check the permissions of the directory you are trying to "
  102. "run CMake on.");
  103. }
  104. }
  105. QCMakePropertyList props = this->properties();
  106. emit this->propertiesChanged(props);
  107. cmProp homeDir = state->GetCacheEntryValue("CMAKE_HOME_DIRECTORY");
  108. if (homeDir) {
  109. setSourceDirectory(QString::fromLocal8Bit(homeDir->c_str()));
  110. }
  111. cmProp gen = state->GetCacheEntryValue("CMAKE_GENERATOR");
  112. if (gen) {
  113. const std::string* extraGen =
  114. state->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR");
  115. std::string curGen =
  116. cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
  117. *gen, extraGen ? *extraGen : "");
  118. this->setGenerator(QString::fromLocal8Bit(curGen.c_str()));
  119. }
  120. cmProp platform = state->GetCacheEntryValue("CMAKE_GENERATOR_PLATFORM");
  121. if (platform) {
  122. this->setPlatform(QString::fromLocal8Bit(platform->c_str()));
  123. }
  124. cmProp toolset = state->GetCacheEntryValue("CMAKE_GENERATOR_TOOLSET");
  125. if (toolset) {
  126. this->setToolset(QString::fromLocal8Bit(toolset->c_str()));
  127. }
  128. checkOpenPossible();
  129. }
  130. }
  131. void QCMake::setPreset(const QString& name, bool setBinary)
  132. {
  133. if (this->PresetName != name) {
  134. this->PresetName = name;
  135. emit this->presetChanged(this->PresetName);
  136. if (!name.isNull()) {
  137. std::string presetName(name.toLocal8Bit());
  138. auto const& expandedPreset =
  139. this->CMakePresetsFile.ConfigurePresets[presetName].Expanded;
  140. if (expandedPreset) {
  141. if (setBinary && !expandedPreset->BinaryDir.empty()) {
  142. QString binaryDir =
  143. QString::fromLocal8Bit(expandedPreset->BinaryDir.data());
  144. this->setBinaryDirectory(binaryDir);
  145. }
  146. if (expandedPreset->WarnDev) {
  147. this->CMakeInstance->SetSuppressDevWarnings(
  148. !*expandedPreset->WarnDev);
  149. }
  150. if (expandedPreset->ErrorDev) {
  151. this->CMakeInstance->SetDevWarningsAsErrors(
  152. *expandedPreset->ErrorDev);
  153. }
  154. if (expandedPreset->WarnDeprecated) {
  155. this->CMakeInstance->SetSuppressDeprecatedWarnings(
  156. !*expandedPreset->WarnDeprecated);
  157. }
  158. if (expandedPreset->ErrorDeprecated) {
  159. this->CMakeInstance->SetDeprecatedWarningsAsErrors(
  160. *expandedPreset->ErrorDeprecated);
  161. }
  162. if (expandedPreset->WarnUninitialized) {
  163. this->WarnUninitializedMode = *expandedPreset->WarnUninitialized;
  164. emit this->warnUninitializedModeChanged(
  165. *expandedPreset->WarnUninitialized);
  166. }
  167. this->Environment = this->StartEnvironment;
  168. for (auto const& v : expandedPreset->Environment) {
  169. if (v.second) {
  170. this->Environment.insert(QString::fromLocal8Bit(v.first.data()),
  171. QString::fromLocal8Bit(v.second->data()));
  172. }
  173. }
  174. }
  175. }
  176. emit this->propertiesChanged(this->properties());
  177. }
  178. }
  179. void QCMake::setGenerator(const QString& gen)
  180. {
  181. if (this->Generator != gen) {
  182. this->Generator = gen;
  183. emit this->generatorChanged(this->Generator);
  184. }
  185. }
  186. void QCMake::setPlatform(const QString& platform)
  187. {
  188. if (this->Platform != platform) {
  189. this->Platform = platform;
  190. emit this->platformChanged(this->Platform);
  191. }
  192. }
  193. void QCMake::setToolset(const QString& toolset)
  194. {
  195. if (this->Toolset != toolset) {
  196. this->Toolset = toolset;
  197. emit this->toolsetChanged(this->Toolset);
  198. }
  199. }
  200. void QCMake::setEnvironment(const QProcessEnvironment& environment)
  201. {
  202. this->Environment = environment;
  203. }
  204. void QCMake::configure()
  205. {
  206. int err;
  207. {
  208. cmSystemTools::SaveRestoreEnvironment restoreEnv;
  209. this->setUpEnvironment();
  210. #ifdef Q_OS_WIN
  211. UINT lastErrorMode = SetErrorMode(0);
  212. #endif
  213. this->CMakeInstance->SetHomeDirectory(
  214. this->SourceDirectory.toLocal8Bit().data());
  215. this->CMakeInstance->SetHomeOutputDirectory(
  216. this->BinaryDirectory.toLocal8Bit().data());
  217. this->CMakeInstance->SetGlobalGenerator(
  218. this->CMakeInstance->CreateGlobalGenerator(
  219. this->Generator.toLocal8Bit().data()));
  220. this->CMakeInstance->SetGeneratorPlatform(
  221. this->Platform.toLocal8Bit().data());
  222. this->CMakeInstance->SetGeneratorToolset(
  223. this->Toolset.toLocal8Bit().data());
  224. this->CMakeInstance->LoadCache();
  225. this->CMakeInstance->SetWarnUninitialized(this->WarnUninitializedMode);
  226. this->CMakeInstance->PreLoadCMakeFiles();
  227. InterruptFlag = 0;
  228. cmSystemTools::ResetErrorOccuredFlag();
  229. err = this->CMakeInstance->Configure();
  230. #ifdef Q_OS_WIN
  231. SetErrorMode(lastErrorMode);
  232. #endif
  233. }
  234. emit this->propertiesChanged(this->properties());
  235. emit this->configureDone(err);
  236. }
  237. void QCMake::generate()
  238. {
  239. int err;
  240. {
  241. cmSystemTools::SaveRestoreEnvironment restoreEnv;
  242. this->setUpEnvironment();
  243. #ifdef Q_OS_WIN
  244. UINT lastErrorMode = SetErrorMode(0);
  245. #endif
  246. InterruptFlag = 0;
  247. cmSystemTools::ResetErrorOccuredFlag();
  248. err = this->CMakeInstance->Generate();
  249. #ifdef Q_OS_WIN
  250. SetErrorMode(lastErrorMode);
  251. #endif
  252. }
  253. emit this->generateDone(err);
  254. checkOpenPossible();
  255. }
  256. void QCMake::open()
  257. {
  258. #ifdef Q_OS_WIN
  259. UINT lastErrorMode = SetErrorMode(0);
  260. #endif
  261. InterruptFlag = 0;
  262. cmSystemTools::ResetErrorOccuredFlag();
  263. auto successful = this->CMakeInstance->Open(
  264. this->BinaryDirectory.toLocal8Bit().data(), false);
  265. #ifdef Q_OS_WIN
  266. SetErrorMode(lastErrorMode);
  267. #endif
  268. emit this->openDone(successful);
  269. }
  270. void QCMake::setProperties(const QCMakePropertyList& newProps)
  271. {
  272. QCMakePropertyList props = newProps;
  273. QStringList toremove;
  274. // set the value of properties
  275. cmState* state = this->CMakeInstance->GetState();
  276. std::vector<std::string> cacheKeys = state->GetCacheEntryKeys();
  277. for (std::string const& key : cacheKeys) {
  278. cmStateEnums::CacheEntryType t = state->GetCacheEntryType(key);
  279. if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC) {
  280. continue;
  281. }
  282. QCMakeProperty prop;
  283. prop.Key = QString::fromLocal8Bit(key.c_str());
  284. int idx = props.indexOf(prop);
  285. if (idx == -1) {
  286. toremove.append(QString::fromLocal8Bit(key.c_str()));
  287. } else {
  288. prop = props[idx];
  289. #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
  290. const bool isBool = prop.Value.type() == QVariant::Bool;
  291. #else
  292. const bool isBool = prop.Value.metaType() == QMetaType::fromType<bool>();
  293. #endif
  294. if (isBool) {
  295. state->SetCacheEntryValue(key, prop.Value.toBool() ? "ON" : "OFF");
  296. } else {
  297. state->SetCacheEntryValue(key,
  298. prop.Value.toString().toLocal8Bit().data());
  299. }
  300. props.removeAt(idx);
  301. }
  302. }
  303. // remove some properties
  304. foreach (QString const& s, toremove) {
  305. this->CMakeInstance->UnwatchUnusedCli(s.toLocal8Bit().data());
  306. state->RemoveCacheEntry(s.toLocal8Bit().data());
  307. }
  308. // add some new properties
  309. foreach (QCMakeProperty const& s, props) {
  310. this->CMakeInstance->WatchUnusedCli(s.Key.toLocal8Bit().data());
  311. if (s.Type == QCMakeProperty::BOOL) {
  312. this->CMakeInstance->AddCacheEntry(
  313. s.Key.toLocal8Bit().data(), s.Value.toBool() ? "ON" : "OFF",
  314. s.Help.toLocal8Bit().data(), cmStateEnums::BOOL);
  315. } else if (s.Type == QCMakeProperty::STRING) {
  316. this->CMakeInstance->AddCacheEntry(
  317. s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(),
  318. s.Help.toLocal8Bit().data(), cmStateEnums::STRING);
  319. } else if (s.Type == QCMakeProperty::PATH) {
  320. this->CMakeInstance->AddCacheEntry(
  321. s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(),
  322. s.Help.toLocal8Bit().data(), cmStateEnums::PATH);
  323. } else if (s.Type == QCMakeProperty::FILEPATH) {
  324. this->CMakeInstance->AddCacheEntry(
  325. s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(),
  326. s.Help.toLocal8Bit().data(), cmStateEnums::FILEPATH);
  327. }
  328. }
  329. this->CMakeInstance->SaveCache(this->BinaryDirectory.toLocal8Bit().data());
  330. }
  331. QCMakePropertyList QCMake::properties() const
  332. {
  333. QCMakePropertyList ret;
  334. cmState* state = this->CMakeInstance->GetState();
  335. std::vector<std::string> cacheKeys = state->GetCacheEntryKeys();
  336. for (std::string const& key : cacheKeys) {
  337. cmStateEnums::CacheEntryType t = state->GetCacheEntryType(key);
  338. if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC ||
  339. t == cmStateEnums::UNINITIALIZED) {
  340. continue;
  341. }
  342. cmProp cachedValue = state->GetCacheEntryValue(key);
  343. QCMakeProperty prop;
  344. prop.Key = QString::fromLocal8Bit(key.c_str());
  345. if (cmProp hs = state->GetCacheEntryProperty(key, "HELPSTRING")) {
  346. prop.Help = QString::fromLocal8Bit(hs->c_str());
  347. }
  348. prop.Value = QString::fromLocal8Bit(cachedValue->c_str());
  349. prop.Advanced = state->GetCacheEntryPropertyAsBool(key, "ADVANCED");
  350. if (t == cmStateEnums::BOOL) {
  351. prop.Type = QCMakeProperty::BOOL;
  352. prop.Value = cmIsOn(*cachedValue);
  353. } else if (t == cmStateEnums::PATH) {
  354. prop.Type = QCMakeProperty::PATH;
  355. } else if (t == cmStateEnums::FILEPATH) {
  356. prop.Type = QCMakeProperty::FILEPATH;
  357. } else if (t == cmStateEnums::STRING) {
  358. prop.Type = QCMakeProperty::STRING;
  359. cmProp stringsProperty = state->GetCacheEntryProperty(key, "STRINGS");
  360. if (stringsProperty) {
  361. prop.Strings =
  362. QString::fromLocal8Bit(stringsProperty->c_str()).split(";");
  363. }
  364. }
  365. ret.append(prop);
  366. }
  367. if (!this->PresetName.isNull()) {
  368. std::string presetName(this->PresetName.toLocal8Bit());
  369. auto const& p =
  370. this->CMakePresetsFile.ConfigurePresets.at(presetName).Expanded;
  371. if (p) {
  372. for (auto const& v : p->CacheVariables) {
  373. if (!v.second) {
  374. continue;
  375. }
  376. QCMakeProperty prop;
  377. prop.Key = QString::fromLocal8Bit(v.first.data());
  378. prop.Value = QString::fromLocal8Bit(v.second->Value.data());
  379. prop.Type = QCMakeProperty::STRING;
  380. if (!v.second->Type.empty()) {
  381. auto type = cmState::StringToCacheEntryType(v.second->Type);
  382. switch (type) {
  383. case cmStateEnums::BOOL:
  384. prop.Type = QCMakeProperty::BOOL;
  385. prop.Value = cmIsOn(v.second->Value);
  386. break;
  387. case cmStateEnums::PATH:
  388. prop.Type = QCMakeProperty::PATH;
  389. break;
  390. case cmStateEnums::FILEPATH:
  391. prop.Type = QCMakeProperty::FILEPATH;
  392. break;
  393. default:
  394. prop.Type = QCMakeProperty::STRING;
  395. break;
  396. }
  397. }
  398. // QCMakeCacheModel prefers variables earlier in the list rather than
  399. // later, so overwrite them if they already exist rather than simply
  400. // appending
  401. bool found = false;
  402. for (auto& orig : ret) {
  403. if (orig.Key == prop.Key) {
  404. orig = prop;
  405. found = true;
  406. break;
  407. }
  408. }
  409. if (!found) {
  410. ret.append(prop);
  411. }
  412. }
  413. }
  414. }
  415. return ret;
  416. }
  417. void QCMake::interrupt()
  418. {
  419. this->InterruptFlag.ref();
  420. }
  421. bool QCMake::interruptCallback()
  422. {
  423. #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
  424. return this->InterruptFlag.load();
  425. #else
  426. return this->InterruptFlag.loadRelaxed();
  427. #endif
  428. }
  429. void QCMake::progressCallback(const std::string& msg, float percent)
  430. {
  431. if (percent >= 0) {
  432. emit this->progressChanged(QString::fromStdString(msg), percent);
  433. } else {
  434. emit this->outputMessage(QString::fromStdString(msg));
  435. }
  436. QCoreApplication::processEvents();
  437. }
  438. void QCMake::messageCallback(std::string const& msg, const char* /*title*/)
  439. {
  440. emit this->errorMessage(QString::fromStdString(msg));
  441. QCoreApplication::processEvents();
  442. }
  443. void QCMake::stdoutCallback(std::string const& msg)
  444. {
  445. emit this->outputMessage(QString::fromStdString(msg));
  446. QCoreApplication::processEvents();
  447. }
  448. void QCMake::stderrCallback(std::string const& msg)
  449. {
  450. emit this->outputMessage(QString::fromStdString(msg));
  451. QCoreApplication::processEvents();
  452. }
  453. void QCMake::setUpEnvironment() const
  454. {
  455. auto env = QProcessEnvironment::systemEnvironment();
  456. for (auto const& key : env.keys()) {
  457. cmSystemTools::UnsetEnv(key.toLocal8Bit().data());
  458. }
  459. for (auto const& var : this->Environment.toStringList()) {
  460. cmSystemTools::PutEnv(var.toLocal8Bit().data());
  461. }
  462. }
  463. void QCMake::loadPresets()
  464. {
  465. auto result = this->CMakePresetsFile.ReadProjectPresets(
  466. this->SourceDirectory.toLocal8Bit().data(), true);
  467. if (result != this->LastLoadPresetsResult &&
  468. result != cmCMakePresetsFile::ReadFileResult::READ_OK) {
  469. emit this->presetLoadError(this->SourceDirectory, result);
  470. }
  471. this->LastLoadPresetsResult = result;
  472. QVector<QCMakePreset> presets;
  473. for (auto const& name : this->CMakePresetsFile.ConfigurePresetOrder) {
  474. auto const& it = this->CMakePresetsFile.ConfigurePresets[name];
  475. auto const& p = it.Unexpanded;
  476. if (p.Hidden) {
  477. continue;
  478. }
  479. QCMakePreset preset;
  480. preset.name = std::move(QString::fromLocal8Bit(p.Name.data()));
  481. preset.displayName =
  482. std::move(QString::fromLocal8Bit(p.DisplayName.data()));
  483. preset.description =
  484. std::move(QString::fromLocal8Bit(p.Description.data()));
  485. preset.generator = std::move(QString::fromLocal8Bit(p.Generator.data()));
  486. preset.architecture =
  487. std::move(QString::fromLocal8Bit(p.Architecture.data()));
  488. preset.setArchitecture = !p.ArchitectureStrategy ||
  489. p.ArchitectureStrategy == cmCMakePresetsFile::ArchToolsetStrategy::Set;
  490. preset.toolset = std::move(QString::fromLocal8Bit(p.Toolset.data()));
  491. preset.setToolset = !p.ToolsetStrategy ||
  492. p.ToolsetStrategy == cmCMakePresetsFile::ArchToolsetStrategy::Set;
  493. preset.enabled = it.Expanded && it.Expanded->ConditionResult &&
  494. std::find_if(this->AvailableGenerators.begin(),
  495. this->AvailableGenerators.end(),
  496. [&p](const cmake::GeneratorInfo& g) {
  497. return g.name == p.Generator;
  498. }) != this->AvailableGenerators.end();
  499. presets.push_back(preset);
  500. }
  501. emit this->presetsChanged(presets);
  502. }
  503. QString QCMake::binaryDirectory() const
  504. {
  505. return this->BinaryDirectory;
  506. }
  507. QString QCMake::sourceDirectory() const
  508. {
  509. return this->SourceDirectory;
  510. }
  511. QString QCMake::generator() const
  512. {
  513. return this->Generator;
  514. }
  515. QProcessEnvironment QCMake::environment() const
  516. {
  517. return this->Environment;
  518. }
  519. std::vector<cmake::GeneratorInfo> const& QCMake::availableGenerators() const
  520. {
  521. return AvailableGenerators;
  522. }
  523. void QCMake::deleteCache()
  524. {
  525. // delete cache
  526. this->CMakeInstance->DeleteCache(this->BinaryDirectory.toLocal8Bit().data());
  527. // reload to make our cache empty
  528. this->CMakeInstance->LoadCache(this->BinaryDirectory.toLocal8Bit().data());
  529. // emit no generator and no properties
  530. this->setGenerator(QString());
  531. this->setToolset(QString());
  532. QCMakePropertyList props = this->properties();
  533. emit this->propertiesChanged(props);
  534. }
  535. void QCMake::reloadCache()
  536. {
  537. // emit that the cache was cleaned out
  538. QCMakePropertyList props;
  539. emit this->propertiesChanged(props);
  540. // reload
  541. this->CMakeInstance->LoadCache(this->BinaryDirectory.toLocal8Bit().data());
  542. // emit new cache properties
  543. props = this->properties();
  544. emit this->propertiesChanged(props);
  545. }
  546. void QCMake::setDebugOutput(bool flag)
  547. {
  548. if (flag != this->CMakeInstance->GetDebugOutput()) {
  549. this->CMakeInstance->SetDebugOutputOn(flag);
  550. emit this->debugOutputChanged(flag);
  551. }
  552. }
  553. bool QCMake::getDebugOutput() const
  554. {
  555. return this->CMakeInstance->GetDebugOutput();
  556. }
  557. bool QCMake::getSuppressDevWarnings()
  558. {
  559. return this->CMakeInstance->GetSuppressDevWarnings();
  560. }
  561. void QCMake::setSuppressDevWarnings(bool value)
  562. {
  563. this->CMakeInstance->SetSuppressDevWarnings(value);
  564. }
  565. bool QCMake::getSuppressDeprecatedWarnings()
  566. {
  567. return this->CMakeInstance->GetSuppressDeprecatedWarnings();
  568. }
  569. void QCMake::setSuppressDeprecatedWarnings(bool value)
  570. {
  571. this->CMakeInstance->SetSuppressDeprecatedWarnings(value);
  572. }
  573. bool QCMake::getDevWarningsAsErrors()
  574. {
  575. return this->CMakeInstance->GetDevWarningsAsErrors();
  576. }
  577. void QCMake::setDevWarningsAsErrors(bool value)
  578. {
  579. this->CMakeInstance->SetDevWarningsAsErrors(value);
  580. }
  581. bool QCMake::getDeprecatedWarningsAsErrors()
  582. {
  583. return this->CMakeInstance->GetDeprecatedWarningsAsErrors();
  584. }
  585. void QCMake::setDeprecatedWarningsAsErrors(bool value)
  586. {
  587. this->CMakeInstance->SetDeprecatedWarningsAsErrors(value);
  588. }
  589. void QCMake::setWarnUninitializedMode(bool value)
  590. {
  591. this->WarnUninitializedMode = value;
  592. }
  593. void QCMake::checkOpenPossible()
  594. {
  595. std::string data = this->BinaryDirectory.toLocal8Bit().data();
  596. auto possible = this->CMakeInstance->Open(data, true);
  597. emit openPossible(possible);
  598. }