CMakePM: Handle include(CMakeFileWithoutSuffix) navigation

Check that the function operating upon is "include" and then match the
word under cursor with a file from the project.

Change-Id: Ia0131f08515c56582a1fb02a59d6b2e41ac04288
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Cristian Adam
2023-09-29 22:39:01 +02:00
parent 44836247ca
commit 762b0518a2
3 changed files with 70 additions and 9 deletions

View File

@@ -1379,12 +1379,25 @@ void CMakeBuildSystem::setupCMakeSymbolsHash()
}
};
// Prepare a hash with all .cmake files
m_dotCMakeFilesHash.clear();
auto handleDotCMakeFiles = [&](const CMakeFileInfo &cmakeFile) {
if (cmakeFile.path.suffix() == "cmake") {
Utils::Link link;
link.targetFilePath = cmakeFile.path;
link.targetLine = 1;
link.targetColumn = 0;
m_dotCMakeFilesHash.insert(cmakeFile.path.completeBaseName(), link);
}
};
for (const auto &cmakeFile : std::as_const(m_cmakeFiles)) {
for (const auto &func : cmakeFile.cmakeListFile.Functions) {
handleFunctionMacroOption(cmakeFile, func);
handleImportedTargets(cmakeFile, func);
handleProjectTargets(cmakeFile, func);
handleFindPackageVariables(cmakeFile, func);
handleDotCMakeFiles(cmakeFile);
}
}