forked from qt-creator/qt-creator
CMake: Remember file location of CMake target definitions
Make fileapi remember where CMake targets were defined in the CMakeBuildTarget struct. The other readers will just guess at the location based on the source directory of the target. Change-Id: Ia8fa226c548800992ccea64b1d5981d2f3013408 Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -357,13 +357,22 @@ QList<CMakeBuildTarget> BuildDirManager::takeBuildTargets(QString &errorMessage)
|
||||
QTC_ASSERT(!m_isHandlingError, return result);
|
||||
|
||||
if (m_reader) {
|
||||
result.append(Utils::filtered(m_reader->takeBuildTargets(errorMessage),
|
||||
QList<CMakeBuildTarget> readerTargets
|
||||
= Utils::filtered(m_reader->takeBuildTargets(errorMessage),
|
||||
[](const CMakeBuildTarget &bt) {
|
||||
return bt.title != CMakeBuildStep::allTarget()
|
||||
&& bt.title != CMakeBuildStep::cleanTarget()
|
||||
&& bt.title != CMakeBuildStep::installTarget()
|
||||
&& bt.title != CMakeBuildStep::testTarget();
|
||||
}));
|
||||
});
|
||||
|
||||
// Guess at the target definition position when no details are known
|
||||
for (CMakeBuildTarget &t : readerTargets) {
|
||||
if (t.definitionFile.isEmpty()) {
|
||||
t.definitionFile = t.sourceDirectory.pathAppended("CMakeLists.txt");
|
||||
}
|
||||
}
|
||||
result.append(readerTargets);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@@ -53,6 +53,9 @@ public:
|
||||
Utils::FilePath sourceDirectory;
|
||||
Utils::FilePath makeCommand;
|
||||
|
||||
Utils::FilePath definitionFile;
|
||||
int definitionLine = -1;
|
||||
|
||||
// code model
|
||||
QList<Utils::FilePath> includeFiles;
|
||||
QStringList compilerOptions;
|
||||
|
@@ -194,6 +194,17 @@ QList<CMakeBuildTarget> generateBuildTargets(const PreprocessedData &input,
|
||||
}
|
||||
ct.sourceDirectory = FilePath::fromString(
|
||||
QDir::cleanPath(sourceDir.absoluteFilePath(t.sourceDir.toString())));
|
||||
|
||||
if (t.backtrace >= 0) {
|
||||
const BacktraceNode &node = t.backtraceGraph.nodes[static_cast<size_t>(t.backtrace)];
|
||||
const int fileIndex = node.file;
|
||||
if (fileIndex >= 0) {
|
||||
ct.definitionFile = FilePath::fromString(QDir::cleanPath(sourceDir.absoluteFilePath(
|
||||
t.backtraceGraph.files[static_cast<size_t>(fileIndex)])));
|
||||
ct.definitionLine = node.line;
|
||||
}
|
||||
}
|
||||
|
||||
return ct;
|
||||
});
|
||||
return result;
|
||||
|
Reference in New Issue
Block a user