forked from qt-creator/qt-creator
CMake: Make parsing of CMakeCache.txt files available
Change-Id: I94876851dd4cf737418c4c00b589af1b3a9535ed Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -255,7 +255,14 @@ CMakeConfig BuildDirManager::configuration() const
|
|||||||
if (!m_hasData)
|
if (!m_hasData)
|
||||||
return CMakeConfig();
|
return CMakeConfig();
|
||||||
|
|
||||||
return parseConfiguration();
|
Utils::FileName cacheFile = workDirectory();
|
||||||
|
cacheFile.appendPath(QLatin1String("CMakeCache.txt"));
|
||||||
|
QString errorMessage;
|
||||||
|
CMakeConfig result = parseConfiguration(cacheFile, sourceDirectory(), &errorMessage);
|
||||||
|
if (!errorMessage.isEmpty())
|
||||||
|
emit errorOccured(errorMessage);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildDirManager::stopProcess()
|
void BuildDirManager::stopProcess()
|
||||||
@@ -517,13 +524,17 @@ static CMakeConfigItem::Type fromByteArray(const QByteArray &type) {
|
|||||||
return CMakeConfigItem::INTERNAL;
|
return CMakeConfigItem::INTERNAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMakeConfig BuildDirManager::parseConfiguration() const
|
CMakeConfig BuildDirManager::parseConfiguration(const Utils::FileName &cacheFile,
|
||||||
|
const Utils::FileName &sourceDir,
|
||||||
|
QString *errorMessage)
|
||||||
{
|
{
|
||||||
CMakeConfig result;
|
CMakeConfig result;
|
||||||
const QString cacheFile = QDir(workDirectory().toString()).absoluteFilePath(QLatin1String("CMakeCache.txt"));
|
QFile cache(cacheFile.toString());
|
||||||
QFile cache(cacheFile);
|
if (!cache.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
if (!cache.open(QIODevice::ReadOnly | QIODevice::Text))
|
if (errorMessage)
|
||||||
|
*errorMessage = tr("Failed to open %1 for reading.").arg(cacheFile.toUserOutput());
|
||||||
return CMakeConfig();
|
return CMakeConfig();
|
||||||
|
}
|
||||||
|
|
||||||
QSet<QByteArray> advancedSet;
|
QSet<QByteArray> advancedSet;
|
||||||
QByteArray documentation;
|
QByteArray documentation;
|
||||||
@@ -557,9 +568,12 @@ CMakeConfig BuildDirManager::parseConfiguration() const
|
|||||||
// Sanity checks:
|
// Sanity checks:
|
||||||
if (key == "CMAKE_HOME_DIRECTORY") {
|
if (key == "CMAKE_HOME_DIRECTORY") {
|
||||||
const Utils::FileName actualSourceDir = Utils::FileName::fromUserInput(QString::fromUtf8(value));
|
const Utils::FileName actualSourceDir = Utils::FileName::fromUserInput(QString::fromUtf8(value));
|
||||||
if (actualSourceDir != sourceDirectory())
|
if (actualSourceDir != sourceDir) {
|
||||||
emit errorOccured(tr("Build directory contains a build of the wrong project (%1).")
|
if (errorMessage)
|
||||||
.arg(actualSourceDir.toUserOutput()));
|
*errorMessage = tr("Build directory contains a build of the wrong project (%1).")
|
||||||
|
.arg(actualSourceDir.toUserOutput());
|
||||||
|
return CMakeConfig();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,10 @@ public:
|
|||||||
void clearFiles();
|
void clearFiles();
|
||||||
CMakeConfig configuration() const;
|
CMakeConfig configuration() const;
|
||||||
|
|
||||||
|
static CMakeConfig parseConfiguration(const Utils::FileName &cacheFile,
|
||||||
|
const Utils::FileName &sourceDir,
|
||||||
|
QString *errorMessage);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void configurationStarted() const;
|
void configurationStarted() const;
|
||||||
void dataAvailable() const;
|
void dataAvailable() const;
|
||||||
@@ -102,7 +106,6 @@ private:
|
|||||||
void processCMakeOutput();
|
void processCMakeOutput();
|
||||||
void processCMakeError();
|
void processCMakeError();
|
||||||
|
|
||||||
CMakeConfig parseConfiguration() const;
|
|
||||||
|
|
||||||
bool m_hasData = false;
|
bool m_hasData = false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user