forked from qt-creator/qt-creator
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: Alexander Drozdov <adrozdoff@gmail.com> Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com> Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
This commit is contained in:
@@ -273,9 +273,11 @@ CMakeConfig BuildDirManager::parsedConfiguration() const
|
|||||||
Utils::FileName cacheFile = workDirectory();
|
Utils::FileName cacheFile = workDirectory();
|
||||||
cacheFile.appendPath(QLatin1String("CMakeCache.txt"));
|
cacheFile.appendPath(QLatin1String("CMakeCache.txt"));
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
CMakeConfig result = parseConfiguration(cacheFile, sourceDirectory(), &errorMessage);
|
CMakeConfig result = parseConfiguration(cacheFile, &errorMessage);
|
||||||
if (!errorMessage.isEmpty())
|
if (!errorMessage.isEmpty())
|
||||||
emit errorOccured(errorMessage);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -542,7 +544,6 @@ static CMakeConfigItem::Type fromByteArray(const QByteArray &type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CMakeConfig BuildDirManager::parseConfiguration(const Utils::FileName &cacheFile,
|
CMakeConfig BuildDirManager::parseConfiguration(const Utils::FileName &cacheFile,
|
||||||
const Utils::FileName &sourceDir,
|
|
||||||
QString *errorMessage)
|
QString *errorMessage)
|
||||||
{
|
{
|
||||||
CMakeConfig result;
|
CMakeConfig result;
|
||||||
@@ -579,19 +580,7 @@ CMakeConfig BuildDirManager::parseConfiguration(const Utils::FileName &cacheFile
|
|||||||
advancedSet.insert(key.left(key.count() - 9 /* "-ADVANCED" */));
|
advancedSet.insert(key.left(key.count() - 9 /* "-ADVANCED" */));
|
||||||
} else {
|
} else {
|
||||||
CMakeConfigItem::Type t = fromByteArray(type);
|
CMakeConfigItem::Type t = fromByteArray(type);
|
||||||
if (t != CMakeConfigItem::INTERNAL)
|
|
||||||
result << CMakeConfigItem(key, t, documentation, value);
|
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;
|
CMakeConfig parsedConfiguration() const;
|
||||||
|
|
||||||
static CMakeConfig parseConfiguration(const Utils::FileName &cacheFile,
|
static CMakeConfig parseConfiguration(const Utils::FileName &cacheFile,
|
||||||
const Utils::FileName &sourceDir,
|
|
||||||
QString *errorMessage);
|
QString *errorMessage);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
@@ -197,7 +197,9 @@ QList<ConfigModel::DataItem> CMakeBuildConfiguration::completeCMakeConfiguration
|
|||||||
if (m_completeConfigurationCache.isEmpty())
|
if (m_completeConfigurationCache.isEmpty())
|
||||||
m_completeConfigurationCache = m_buildDirManager->parsedConfiguration();
|
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;
|
ConfigModel::DataItem j;
|
||||||
j.key = QString::fromUtf8(i.key);
|
j.key = QString::fromUtf8(i.key);
|
||||||
j.value = QString::fromUtf8(i.value);
|
j.value = QString::fromUtf8(i.value);
|
||||||
|
|||||||
Reference in New Issue
Block a user