Commit 99a88405 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

CMake: Export internal cmake cache values



Those are useful for the cmake internal classes, but need to be filtered
out when they are going to get displayed to the users.

Change-Id: I0bb62fa840fa8cb9e6f3b47300ba85a2b186bad0
Reviewed-by: default avatarAlexander Drozdov <adrozdoff@gmail.com>
Reviewed-by: default avatarTim Jenssen <tim.jenssen@theqtcompany.com>
Reviewed-by: default avatarNiels Weber <niels.weber@theqtcompany.com>
parent de9eeb23
......@@ -273,9 +273,11 @@ CMakeConfig BuildDirManager::parsedConfiguration() const
Utils::FileName cacheFile = workDirectory();
cacheFile.appendPath(QLatin1String("CMakeCache.txt"));
QString errorMessage;
CMakeConfig result = parseConfiguration(cacheFile, sourceDirectory(), &errorMessage);
CMakeConfig result = parseConfiguration(cacheFile, &errorMessage);
if (!errorMessage.isEmpty())
emit errorOccured(errorMessage);
if (CMakeConfigItem::valueOf("CMAKE_HOME_DIRECTORY", result) != sourceDirectory().toString().toUtf8())
emit errorOccured(tr("The build directory is not for %1").arg(sourceDirectory().toUserOutput()));
return result;
}
......@@ -542,7 +544,6 @@ static CMakeConfigItem::Type fromByteArray(const QByteArray &type) {
}
CMakeConfig BuildDirManager::parseConfiguration(const Utils::FileName &cacheFile,
const Utils::FileName &sourceDir,
QString *errorMessage)
{
CMakeConfig result;
......@@ -579,19 +580,7 @@ CMakeConfig BuildDirManager::parseConfiguration(const Utils::FileName &cacheFile
advancedSet.insert(key.left(key.count() - 9 /* "-ADVANCED" */));
} else {
CMakeConfigItem::Type t = fromByteArray(type);
if (t != CMakeConfigItem::INTERNAL)
result << CMakeConfigItem(key, t, documentation, value);
// Sanity checks:
if (key == "CMAKE_HOME_DIRECTORY") {
const Utils::FileName actualSourceDir = Utils::FileName::fromUserInput(QString::fromUtf8(value));
if (actualSourceDir != sourceDir) {
if (errorMessage)
*errorMessage = tr("Build directory contains a build of the wrong project (%1).")
.arg(actualSourceDir.toUserOutput());
return CMakeConfig();
}
}
}
}
......
......@@ -88,7 +88,6 @@ public:
CMakeConfig parsedConfiguration() const;
static CMakeConfig parseConfiguration(const Utils::FileName &cacheFile,
const Utils::FileName &sourceDir,
QString *errorMessage);
signals:
......
......@@ -197,7 +197,9 @@ QList<ConfigModel::DataItem> CMakeBuildConfiguration::completeCMakeConfiguration
if (m_completeConfigurationCache.isEmpty())
m_completeConfigurationCache = m_buildDirManager->parsedConfiguration();
return Utils::transform(m_completeConfigurationCache, [](const CMakeConfigItem &i) {
CMakeConfig cache = Utils::filtered(m_completeConfigurationCache,
[](const CMakeConfigItem &i) { return i.type != CMakeConfigItem::INTERNAL; });
return Utils::transform(cache, [](const CMakeConfigItem &i) {
ConfigModel::DataItem j;
j.key = QString::fromUtf8(i.key);
j.value = QString::fromUtf8(i.value);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment