forked from qt-creator/qt-creator
CMakePM: Treat .h files as compile group language header types
CMake splits sources files into groups "Source Files" and "Header Files". CMake also has compiler groups when source files are compiled differently. Qt Creator is mapping the compiler groups as RawProjectParts. In order to get the header files as part of a RawProjectPart the target sources (which contains all sources) is mapping the header files that match the mime type of the compiler group language type. .h header files were considered ambigous headers, and in this commit we treat them as the compile group language header. Fixes: QTCREATORBUG-27117 Change-Id: If68e847846cc270f06fc2231ec44a29ea6a987c1 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -402,18 +402,18 @@ RawProjectParts generateRawProjectParts(const PreprocessedData &input,
|
||||
const bool hasPchSource = anyOf(sources, [buildDirectory](const QString &path) {
|
||||
return isPchFile(buildDirectory, FilePath::fromString(path));
|
||||
});
|
||||
if (!hasPchSource) {
|
||||
QString headerMimeType;
|
||||
if (ci.language == "C")
|
||||
headerMimeType = CppEditor::Constants::C_HEADER_MIMETYPE;
|
||||
else if (ci.language == "CXX")
|
||||
headerMimeType = CppEditor::Constants::CPP_HEADER_MIMETYPE;
|
||||
|
||||
QString headerMimeType;
|
||||
if (ci.language == "C")
|
||||
headerMimeType = CppEditor::Constants::C_HEADER_MIMETYPE;
|
||||
else if (ci.language == "CXX")
|
||||
headerMimeType = CppEditor::Constants::CPP_HEADER_MIMETYPE;
|
||||
if (!hasPchSource) {
|
||||
for (const SourceInfo &si : t.sources) {
|
||||
if (si.isGenerated)
|
||||
continue;
|
||||
const auto mimeTypes = Utils::mimeTypesForFileName(si.path);
|
||||
for (auto mime : mimeTypes)
|
||||
for (const auto &mime : mimeTypes)
|
||||
if (mime.name() == headerMimeType)
|
||||
sources.push_back(sourceDir.absoluteFilePath(si.path));
|
||||
}
|
||||
@@ -421,8 +421,14 @@ RawProjectParts generateRawProjectParts(const PreprocessedData &input,
|
||||
|
||||
// Set project files except pch files
|
||||
rpp.setFiles(Utils::filtered(sources, [buildDirectory](const QString &path) {
|
||||
return !isPchFile(buildDirectory, FilePath::fromString(path));
|
||||
}));
|
||||
return !isPchFile(buildDirectory, FilePath::fromString(path));
|
||||
}), {}, [headerMimeType](const QString &path) {
|
||||
// Similar to ProjectFile::classify but classify headers with language
|
||||
// of compile group instead of ambiguous header
|
||||
if (path.endsWith(".h"))
|
||||
return headerMimeType;
|
||||
return Utils::mimeTypeForFile(path).name();
|
||||
});
|
||||
|
||||
FilePath precompiled_header
|
||||
= FilePath::fromString(findOrDefault(t.sources, [&ending](const SourceInfo &si) {
|
||||
|
||||
Reference in New Issue
Block a user