Add includes to the codemodel specified via PKGCONFIG in .pro files

We run pkg-config --cflags-only-I $$PKGCONFIG in the background to find
those includes.

Task-Nr: 250195
This commit is contained in:
dt
2009-05-13 18:09:47 +02:00
parent 5321950d40
commit 286325ceb6
3 changed files with 18 additions and 2 deletions

View File

@@ -719,6 +719,7 @@ void Qt4ProFileNode::update()
newVarValues[IncludePathVar] = includePaths(reader); newVarValues[IncludePathVar] = includePaths(reader);
newVarValues[UiDirVar] = uiDirPaths(reader); newVarValues[UiDirVar] = uiDirPaths(reader);
newVarValues[MocDirVar] = mocDirPaths(reader); newVarValues[MocDirVar] = mocDirPaths(reader);
newVarValues[PkgConfigVar] = reader->values(QLatin1String("PKGCONFIG"));
if (m_varValues != newVarValues) { if (m_varValues != newVarValues) {
m_varValues = newVarValues; m_varValues = newVarValues;

View File

@@ -99,7 +99,8 @@ enum Qt4Variable {
IncludePathVar, IncludePathVar,
CxxCompilerVar, CxxCompilerVar,
UiDirVar, UiDirVar,
MocDirVar MocDirVar,
PkgConfigVar
}; };
class Qt4PriFileNode; class Qt4PriFileNode;

View File

@@ -527,13 +527,27 @@ void Qt4Project::updateCodeModel()
} }
const QStringList proIncludePaths = pro->variableValue(IncludePathVar); const QStringList proIncludePaths = pro->variableValue(IncludePathVar);
foreach (QString includePath, proIncludePaths) { foreach (const QString &includePath, proIncludePaths) {
if (!allIncludePaths.contains(includePath)) if (!allIncludePaths.contains(includePath))
allIncludePaths.append(includePath); allIncludePaths.append(includePath);
if (!info.includes.contains(includePath)) if (!info.includes.contains(includePath))
info.includes.append(includePath); info.includes.append(includePath);
} }
{ // Pkg Config support
QStringList pkgConfig = pro->variableValue(PkgConfigVar);
if (!pkgConfig.isEmpty()) {
pkgConfig.prepend("--cflags-only-I");
QProcess process;
process.start("pkg-config", pkgConfig);
process.waitForFinished();
QString result = process.readAllStandardOutput();
foreach(const QString &part, result.trimmed().split(' ', QString::SkipEmptyParts)) {
info.includes.append(part.mid(2)); // Chop off "-I"
}
}
}
// Add mkspec directory // Add mkspec directory
info.includes.append(qtVersion(activeBuildConfiguration())->mkspecPath()); info.includes.append(qtVersion(activeBuildConfiguration())->mkspecPath());