forked from qt-creator/qt-creator
CMake: Reimplement CMakeCache.txt parsing in BuildDirManager
The CMakeProjectImporter will need that in addition to the tealeafreader. Change-Id: I453a7a124b5303e163e9c85bc3fc215215617119 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -337,6 +337,19 @@ CMakeConfig BuildDirManager::parsedConfiguration() const
|
||||
return m_cmakeCache;
|
||||
}
|
||||
|
||||
CMakeConfig BuildDirManager::parseConfiguration(const Utils::FileName &cacheFile, QString *errorMessage)
|
||||
{
|
||||
if (!cacheFile.exists()) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("CMakeCache.txt file not found.");
|
||||
return { };
|
||||
}
|
||||
CMakeConfig result = CMakeConfigItem::itemsFromFile(cacheFile, errorMessage);
|
||||
if (!errorMessage->isEmpty())
|
||||
return { };
|
||||
return result;
|
||||
}
|
||||
|
||||
void BuildDirManager::checkConfiguration()
|
||||
{
|
||||
if (m_tempDir) // always throw away changes in the tmpdir!
|
||||
|
@@ -78,15 +78,15 @@ public:
|
||||
QList<CMakeBuildTarget> buildTargets() const;
|
||||
CMakeConfig parsedConfiguration() const;
|
||||
|
||||
static CMakeConfig parseConfiguration(const Utils::FileName &cacheFile,
|
||||
QString *errorMessage);
|
||||
|
||||
signals:
|
||||
void configurationStarted() const;
|
||||
void dataAvailable() const;
|
||||
void errorOccured(const QString &err) const;
|
||||
|
||||
protected:
|
||||
static CMakeConfig parseConfiguration(const Utils::FileName &cacheFile,
|
||||
QString *errorMessage);
|
||||
|
||||
const Utils::FileName workDirectory() const;
|
||||
|
||||
private:
|
||||
|
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "tealeafreader.h"
|
||||
|
||||
#include "builddirmanager.h"
|
||||
#include "cmakebuildconfiguration.h"
|
||||
#include "cmakecbpparser.h"
|
||||
#include "cmakekitinformation.h"
|
||||
@@ -222,15 +223,16 @@ QList<CMakeBuildTarget> TeaLeafReader::buildTargets() const
|
||||
|
||||
CMakeConfig TeaLeafReader::takeParsedConfiguration()
|
||||
{
|
||||
CMakeConfig result;
|
||||
FileName cacheFile = m_parameters.buildDirectory;
|
||||
cacheFile.appendPath(QLatin1String("CMakeCache.txt"));
|
||||
if (!cacheFile.exists())
|
||||
return result;
|
||||
QString errorMessage;
|
||||
result = CMakeConfigItem::itemsFromFile(cacheFile, &errorMessage);
|
||||
if (!errorMessage.isEmpty())
|
||||
CMakeConfig result = BuildDirManager::parseConfiguration(cacheFile, &errorMessage);
|
||||
|
||||
if (!errorMessage.isEmpty()) {
|
||||
emit errorOccured(errorMessage);
|
||||
return { };
|
||||
}
|
||||
|
||||
const FileName sourceOfBuildDir
|
||||
= FileName::fromUtf8(CMakeConfigItem::valueOf("CMAKE_HOME_DIRECTORY", result));
|
||||
const FileName canonicalSourceOfBuildDir = FileUtils::canonicalPath(sourceOfBuildDir);
|
||||
@@ -239,6 +241,7 @@ CMakeConfig TeaLeafReader::takeParsedConfiguration()
|
||||
emit errorOccured(tr("The build directory is not for %1 but for %2")
|
||||
.arg(canonicalSourceOfBuildDir.toUserOutput(),
|
||||
canonicalSourceDirectory.toUserOutput()));
|
||||
return { };
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user