| 487 | } |
| 488 | |
| 489 | void updateConfig( KDevelop::IProject* project, int buildDirIndex) |
| 490 | { |
| 491 | if (buildDirIndex < 0) |
| 492 | return; |
| 493 | |
| 494 | KConfigGroup buildDirGrp = buildDirGroup( project, buildDirIndex ); |
| 495 | const KDevelop::Path builddir(buildDirGrp.readEntry( Config::Specific::buildDirPathKey, QString() )); |
| 496 | const KDevelop::Path cacheFilePath( builddir, QStringLiteral("CMakeCache.txt")); |
| 497 | |
| 498 | const QMap<QString, const char*> keys = { |
| 499 | { QStringLiteral("CMAKE_COMMAND"), Config::Specific::cmakeExecutableKey }, |
| 500 | { QStringLiteral("CMAKE_INSTALL_PREFIX"), Config::Specific::cmakeInstallDirKey }, |
| 501 | { QStringLiteral("CMAKE_BUILD_TYPE"), Config::Specific::cmakeBuildTypeKey } |
| 502 | }; |
| 503 | |
| 504 | const QSet<QString> variables(keys.keyBegin(), keys.keyEnd()); |
| 505 | const QHash<QString, QString> cacheValues = readCacheValues(cacheFilePath, variables); |
| 506 | for(auto it = cacheValues.constBegin(), itEnd = cacheValues.constEnd(); it!=itEnd; ++it) { |
| 507 | const char* const key = keys.value(it.key()); |
| 508 | Q_ASSERT(key); |
| 509 | |
| 510 | // Use cache only when the config value is not set. Without this check we will always |
| 511 | // overwrite values provided by the user in config dialog. |
| 512 | if (buildDirGrp.readEntry(key).isEmpty() && !it.value().isEmpty()) |
| 513 | { |
| 514 | buildDirGrp.writeEntry( key, it.value() ); |
| 515 | } |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | void setOverrideBuildDirIndex( KDevelop::IProject* project, int overrideBuildDirIndex ) |
| 520 | { |
no test coverage detected