QCMake.cxx 20 KB

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