forked from qt-creator/qt-creator
CppEditor: Tell clangd about path to CUDA
At the very least, this fixes an ugly warning message for .cu files. May or may not improve other things as well. Task-number: QTCREATORBUG-23113 Change-Id: If389fd67a153f7da13e5d4d465189aaef352c976 Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <QTextStream>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace CppEditor {
|
||||
|
||||
@@ -115,6 +116,32 @@ static QStringList getIncludedFiles(const RawProjectPart &rpp, const RawProjectP
|
||||
return !rpp.includedFiles.isEmpty() ? rpp.includedFiles : flags.includedFiles;
|
||||
}
|
||||
|
||||
static QStringList getExtraCodeModelFlags(const RawProjectPart &rpp, const ProjectFiles &files)
|
||||
{
|
||||
if (!Utils::anyOf(files, [](const ProjectFile &f) { return f.kind == ProjectFile::CudaSource; }))
|
||||
return {};
|
||||
|
||||
Utils::FilePath cudaPath;
|
||||
for (const HeaderPath &hp : rpp.headerPaths) {
|
||||
if (hp.type == HeaderPathType::BuiltIn)
|
||||
continue;
|
||||
if (!hp.path.endsWith("/include"))
|
||||
continue;
|
||||
const Utils::FilePath includeDir = Utils::FilePath::fromString(hp.path);
|
||||
if (!includeDir.pathAppended("cuda.h").exists())
|
||||
continue;
|
||||
for (FilePath dir = includeDir.parentDir(); cudaPath.isEmpty() && !dir.isRootPath();
|
||||
dir = dir.parentDir()) {
|
||||
if (dir.pathAppended("nvvm").exists())
|
||||
cudaPath = dir;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!cudaPath.isEmpty())
|
||||
return {"--cuda-path=" + cudaPath.toUserOutput()};
|
||||
return {};
|
||||
}
|
||||
|
||||
ProjectPart::ProjectPart(const Utils::FilePath &topLevelProject,
|
||||
const RawProjectPart &rpp,
|
||||
const QString &displayName,
|
||||
@@ -149,7 +176,7 @@ ProjectPart::ProjectPart(const Utils::FilePath &topLevelProject,
|
||||
toolchainInstallDir(tcInfo.installDir),
|
||||
compilerFilePath(tcInfo.compilerFilePath),
|
||||
warningFlags(flags.warningFlags),
|
||||
extraCodeModelFlags(tcInfo.extraCodeModelFlags),
|
||||
extraCodeModelFlags(tcInfo.extraCodeModelFlags + getExtraCodeModelFlags(rpp, files)),
|
||||
compilerFlags(flags.commandLineFlags),
|
||||
m_macroReport(getToolchainMacros(flags, tcInfo, language)),
|
||||
languageFeatures(deriveLanguageFeatures())
|
||||
|
Reference in New Issue
Block a user