forked from qt-creator/qt-creator
CMake: Handle files being in multiple targets when parsing cbp files
Change-Id: Ic85a7318e91e8a10a48c8433f22947fb71071832 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -97,8 +97,10 @@ void CMakeCbpParser::sortFiles()
|
||||
|
||||
foreach (const FileName &fileName, fileNames) {
|
||||
qCDebug(log) << fileName;
|
||||
const QString unitTarget = m_unitTargetMap[fileName];
|
||||
if (!unitTarget.isEmpty()) { // target was explicitly specified for that file
|
||||
const QStringList unitTargets = m_unitTargetMap[fileName];
|
||||
if (!unitTargets.isEmpty()) {
|
||||
// cmake >= 3.3:
|
||||
foreach (const QString &unitTarget, unitTargets) {
|
||||
int index = Utils::indexOf(m_buildTargets, Utils::equal(&CMakeBuildTarget::title, unitTarget));
|
||||
if (index != -1) {
|
||||
m_buildTargets[index].files.append(fileName.toString());
|
||||
@@ -106,6 +108,10 @@ void CMakeCbpParser::sortFiles()
|
||||
continue;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// fallback for cmake < 3.3:
|
||||
if (fileName.parentDir() == parentDirectory && last) {
|
||||
// easy case, same parent directory as last file
|
||||
last->files.append(fileName.toString());
|
||||
@@ -447,7 +453,7 @@ void CMakeCbpParser::parseUnit()
|
||||
}
|
||||
|
||||
m_parsingCMakeUnit = false;
|
||||
m_unitTarget.clear();
|
||||
m_unitTargets.clear();
|
||||
while (!atEnd()) {
|
||||
readNext();
|
||||
if (isEndElement()) {
|
||||
@@ -468,8 +474,7 @@ void CMakeCbpParser::parseUnit()
|
||||
else
|
||||
m_fileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::SourceType, generated));
|
||||
}
|
||||
if (!m_unitTarget.isEmpty())
|
||||
m_unitTargetMap.insert(fileName, m_unitTarget);
|
||||
m_unitTargetMap.insert(fileName, m_unitTargets);
|
||||
m_processedUnits.insert(fileName);
|
||||
}
|
||||
return;
|
||||
@@ -485,7 +490,9 @@ void CMakeCbpParser::parseUnitOption()
|
||||
{
|
||||
const QXmlStreamAttributes optionAttributes = attributes();
|
||||
m_parsingCMakeUnit = optionAttributes.hasAttribute(QLatin1String("virtualFolder"));
|
||||
m_unitTarget = optionAttributes.value(QLatin1String("target")).toString();
|
||||
const QString target = optionAttributes.value(QLatin1String("target")).toString();
|
||||
if (!target.isEmpty())
|
||||
m_unitTargets.append(target);
|
||||
|
||||
while (!atEnd()) {
|
||||
readNext();
|
||||
|
||||
@@ -72,7 +72,7 @@ private:
|
||||
void parseUnknownElement();
|
||||
void sortFiles();
|
||||
|
||||
QMap<Utils::FileName, QString> m_unitTargetMap;
|
||||
QMap<Utils::FileName, QStringList> m_unitTargetMap;
|
||||
const ProjectExplorer::Kit *m_kit = 0;
|
||||
QList<ProjectExplorer::FileNode *> m_fileList;
|
||||
QList<ProjectExplorer::FileNode *> m_cmakeFileList;
|
||||
@@ -85,7 +85,7 @@ private:
|
||||
QString m_compiler;
|
||||
QString m_sourceDirectory;
|
||||
QString m_buildDirectory;
|
||||
QString m_unitTarget;
|
||||
QStringList m_unitTargets;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user