QCMake.cxx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  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& expandedPreset =
  138. this->CMakePresetsFile.Presets[presetName].Expanded;
  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 const& p = this->CMakePresetsFile.Presets.at(presetName).Expanded;
  364. if (p) {
  365. for (auto const& v : p->CacheVariables) {
  366. if (!v.second) {
  367. continue;
  368. }
  369. QCMakeProperty prop;
  370. prop.Key = QString::fromLocal8Bit(v.first.data());
  371. prop.Value = QString::fromLocal8Bit(v.second->Value.data());
  372. prop.Type = QCMakeProperty::STRING;
  373. if (!v.second->Type.empty()) {
  374. auto type = cmState::StringToCacheEntryType(v.second->Type);
  375. switch (type) {
  376. case cmStateEnums::BOOL:
  377. prop.Type = QCMakeProperty::BOOL;
  378. prop.Value = cmIsOn(v.second->Value);
  379. break;
  380. case cmStateEnums::PATH:
  381. prop.Type = QCMakeProperty::PATH;
  382. break;
  383. case cmStateEnums::FILEPATH:
  384. prop.Type = QCMakeProperty::FILEPATH;
  385. break;
  386. default:
  387. prop.Type = QCMakeProperty::STRING;
  388. break;
  389. }
  390. }
  391. // QCMakeCacheModel prefers variables earlier in the list rather than
  392. // later, so overwrite them if they already exist rather than simply
  393. // appending
  394. bool found = false;
  395. for (auto& orig : ret) {
  396. if (orig.Key == prop.Key) {
  397. orig = prop;
  398. found = true;
  399. break;
  400. }
  401. }
  402. if (!found) {
  403. ret.append(prop);
  404. }
  405. }
  406. }
  407. }
  408. return ret;
  409. }
  410. void QCMake::interrupt()
  411. {
  412. this->InterruptFlag.ref();
  413. }
  414. bool QCMake::interruptCallback()
  415. {
  416. #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
  417. return this->InterruptFlag.load();
  418. #else
  419. return this->InterruptFlag.loadRelaxed();
  420. #endif
  421. }
  422. void QCMake::progressCallback(const std::string& msg, float percent)
  423. {
  424. if (percent >= 0) {
  425. emit this->progressChanged(QString::fromStdString(msg), percent);
  426. } else {
  427. emit this->outputMessage(QString::fromStdString(msg));
  428. }
  429. QCoreApplication::processEvents();
  430. }
  431. void QCMake::messageCallback(std::string const& msg, const char* /*title*/)
  432. {
  433. emit this->errorMessage(QString::fromStdString(msg));
  434. QCoreApplication::processEvents();
  435. }
  436. void QCMake::stdoutCallback(std::string const& msg)
  437. {
  438. emit this->outputMessage(QString::fromStdString(msg));
  439. QCoreApplication::processEvents();
  440. }
  441. void QCMake::stderrCallback(std::string const& msg)
  442. {
  443. emit this->outputMessage(QString::fromStdString(msg));
  444. QCoreApplication::processEvents();
  445. }
  446. void QCMake::setUpEnvironment() const
  447. {
  448. auto env = QProcessEnvironment::systemEnvironment();
  449. for (auto const& key : env.keys()) {
  450. cmSystemTools::UnsetEnv(key.toLocal8Bit().data());
  451. }
  452. for (auto const& var : this->Environment.toStringList()) {
  453. cmSystemTools::PutEnv(var.toLocal8Bit().data());
  454. }
  455. }
  456. void QCMake::loadPresets()
  457. {
  458. auto result = this->CMakePresetsFile.ReadProjectPresets(
  459. this->SourceDirectory.toLocal8Bit().data(), true);
  460. if (result != this->LastLoadPresetsResult &&
  461. result != cmCMakePresetsFile::ReadFileResult::READ_OK) {
  462. emit this->presetLoadError(this->SourceDirectory, result);
  463. }
  464. this->LastLoadPresetsResult = result;
  465. QVector<QCMakePreset> presets;
  466. for (auto const& name : this->CMakePresetsFile.PresetOrder) {
  467. auto const& it = this->CMakePresetsFile.Presets[name];
  468. auto const& p = it.Unexpanded;
  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.setArchitecture = !p.ArchitectureStrategy ||
  482. p.ArchitectureStrategy == cmCMakePresetsFile::ArchToolsetStrategy::Set;
  483. preset.toolset = std::move(QString::fromLocal8Bit(p.Toolset.data()));
  484. preset.setToolset = !p.ToolsetStrategy ||
  485. p.ToolsetStrategy == cmCMakePresetsFile::ArchToolsetStrategy::Set;
  486. preset.enabled = it.Expanded &&
  487. std::find_if(this->AvailableGenerators.begin(),
  488. this->AvailableGenerators.end(),
  489. [&p](const cmake::GeneratorInfo& g) {
  490. return g.name == p.Generator;
  491. }) != this->AvailableGenerators.end();
  492. presets.push_back(preset);
  493. }
  494. emit this->presetsChanged(presets);
  495. }
  496. QString QCMake::binaryDirectory() const
  497. {
  498. return this->BinaryDirectory;
  499. }
  500. QString QCMake::sourceDirectory() const
  501. {
  502. return this->SourceDirectory;
  503. }
  504. QString QCMake::generator() const
  505. {
  506. return this->Generator;
  507. }
  508. QProcessEnvironment QCMake::environment() const
  509. {
  510. return this->Environment;
  511. }
  512. std::vector<cmake::GeneratorInfo> const& QCMake::availableGenerators() const
  513. {
  514. return AvailableGenerators;
  515. }
  516. void QCMake::deleteCache()
  517. {
  518. // delete cache
  519. this->CMakeInstance->DeleteCache(this->BinaryDirectory.toLocal8Bit().data());
  520. // reload to make our cache empty
  521. this->CMakeInstance->LoadCache(this->BinaryDirectory.toLocal8Bit().data());
  522. // emit no generator and no properties
  523. this->setGenerator(QString());
  524. this->setToolset(QString());
  525. QCMakePropertyList props = this->properties();
  526. emit this->propertiesChanged(props);
  527. }
  528. void QCMake::reloadCache()
  529. {
  530. // emit that the cache was cleaned out
  531. QCMakePropertyList props;
  532. emit this->propertiesChanged(props);
  533. // reload
  534. this->CMakeInstance->LoadCache(this->BinaryDirectory.toLocal8Bit().data());
  535. // emit new cache properties
  536. props = this->properties();
  537. emit this->propertiesChanged(props);
  538. }
  539. void QCMake::setDebugOutput(bool flag)
  540. {
  541. if (flag != this->CMakeInstance->GetDebugOutput()) {
  542. this->CMakeInstance->SetDebugOutputOn(flag);
  543. emit this->debugOutputChanged(flag);
  544. }
  545. }
  546. bool QCMake::getDebugOutput() const
  547. {
  548. return this->CMakeInstance->GetDebugOutput();
  549. }
  550. bool QCMake::getSuppressDevWarnings()
  551. {
  552. return this->CMakeInstance->GetSuppressDevWarnings();
  553. }
  554. void QCMake::setSuppressDevWarnings(bool value)
  555. {
  556. this->CMakeInstance->SetSuppressDevWarnings(value);
  557. }
  558. bool QCMake::getSuppressDeprecatedWarnings()
  559. {
  560. return this->CMakeInstance->GetSuppressDeprecatedWarnings();
  561. }
  562. void QCMake::setSuppressDeprecatedWarnings(bool value)
  563. {
  564. this->CMakeInstance->SetSuppressDeprecatedWarnings(value);
  565. }
  566. bool QCMake::getDevWarningsAsErrors()
  567. {
  568. return this->CMakeInstance->GetDevWarningsAsErrors();
  569. }
  570. void QCMake::setDevWarningsAsErrors(bool value)
  571. {
  572. this->CMakeInstance->SetDevWarningsAsErrors(value);
  573. }
  574. bool QCMake::getDeprecatedWarningsAsErrors()
  575. {
  576. return this->CMakeInstance->GetDeprecatedWarningsAsErrors();
  577. }
  578. void QCMake::setDeprecatedWarningsAsErrors(bool value)
  579. {
  580. this->CMakeInstance->SetDeprecatedWarningsAsErrors(value);
  581. }
  582. void QCMake::setWarnUninitializedMode(bool value)
  583. {
  584. this->WarnUninitializedMode = value;
  585. }
  586. void QCMake::checkOpenPossible()
  587. {
  588. std::string data = this->BinaryDirectory.toLocal8Bit().data();
  589. auto possible = this->CMakeInstance->Open(data, true);
  590. emit openPossible(possible);
  591. }