CMake: Add logging category for generic cmake stuff

Use the category in CMakeProject.

Change-Id: Idb19a92080884f1feff082d8e9db3ca5336b9249
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Tobias Hunger
2019-06-17 12:30:33 +02:00
parent 0679671547
commit 67186c761f

View File

@@ -66,6 +66,8 @@ using namespace Utils;
namespace CMakeProjectManager {
Q_LOGGING_CATEGORY(cmakeProjectLog, "qtc.cmake.project", QtWarningMsg);
using namespace Internal;
static CMakeBuildConfiguration *activeBc(const CMakeProject *p)
@@ -267,6 +269,7 @@ CMakeProject::~CMakeProject()
void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
{
qCDebug(cmakeProjectLog) << "Updating CMake project data";
const CMakeBuildConfiguration *aBc = activeBc(this);
QString errorMessage;
@@ -277,9 +280,11 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
const QList<CMakeBuildTarget> buildTargets = m_buildDirManager.takeBuildTargets(errorMessage);
checkAndReportError(errorMessage);
bc->setBuildTargets(buildTargets);
qCDebug(cmakeProjectLog) << "Build target data set.";
const CMakeConfig cmakeConfig = m_buildDirManager.takeCMakeConfiguration(errorMessage);
checkAndReportError(errorMessage);
bc->setConfigurationFromCMake(cmakeConfig);
qCDebug(cmakeProjectLog) << "CMake configuration data set.";
CMakeConfig patchedConfig = cmakeConfig;
{
@@ -313,7 +318,7 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
appsPaths.values = apps;
patchedConfig.append(appsPaths);
}
qCDebug(cmakeProjectLog) << "Application data regenerated.";
auto newRoot = generateProjectTree(m_allFiles);
if (newRoot) {
@@ -329,6 +334,7 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
}
}
}
qCDebug(cmakeProjectLog) << "Project tree updated.";
Target *t = bc->target();
t->setApplicationTargets(bc->appTargets());
@@ -339,12 +345,14 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
qDeleteAll(m_extraCompilers);
m_extraCompilers = findExtraCompilers();
CppTools::GeneratedCodeModelSupport::update(m_extraCompilers);
qCDebug(cmakeProjectLog) << "Extra compilers updated.";
QtSupport::CppKitInfo kitInfo(this);
QTC_ASSERT(kitInfo.isValid(), return);
CppTools::RawProjectParts rpps = m_buildDirManager.createRawProjectParts(errorMessage);
checkAndReportError(errorMessage);
qCDebug(cmakeProjectLog) << "Raw project parts created.";
for (CppTools::RawProjectPart &rpp : rpps) {
rpp.setQtVersion(kitInfo.projectPartQtVersion); // TODO: Check if project actually uses Qt.
@@ -355,14 +363,18 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
}
m_cppCodeModelUpdater->update({this, kitInfo, rpps});
qCDebug(cmakeProjectLog) << "C++ codemodel updated.";
updateQmlJSCodeModel();
qCDebug(cmakeProjectLog) << "QML codemodel updated.";
m_buildDirManager.resetData();
qCDebug(cmakeProjectLog) << "CMake specific data was reset.";
emit fileListChanged();
bc->emitBuildTypeChanged();
qCDebug(cmakeProjectLog) << "All CMake project data up to date.";
}
void CMakeProject::updateQmlJSCodeModel()
@@ -673,12 +685,17 @@ void CMakeProject::checkAndReportError(QString &errorMessage) const
QList<ProjectExplorer::ExtraCompiler *> CMakeProject::findExtraCompilers() const
{
QList<ProjectExplorer::ExtraCompiler *> extraCompilers;
const QList<ExtraCompilerFactory *> factories =
ExtraCompilerFactory::extraCompilerFactories();
qCDebug(cmakeProjectLog) << "Finding Extra Compilers: start.";
const QSet<QString> fileExtensions
= Utils::transform<QSet>(factories, &ExtraCompilerFactory::sourceTag);
QList<ProjectExplorer::ExtraCompiler *> extraCompilers;
const QList<ExtraCompilerFactory *> factories = ExtraCompilerFactory::extraCompilerFactories();
qCDebug(cmakeProjectLog) << "Finding Extra Compilers: Got factories.";
const QSet<QString> fileExtensions = Utils::transform<QSet>(factories,
&ExtraCompilerFactory::sourceTag);
qCDebug(cmakeProjectLog) << "Finding Extra Compilers: Got file extensions:" << fileExtensions;
// Find all files generated by any of the extra compilers, in a rather crude way.
const FilePathList fileList = files([&fileExtensions](const Node *n) {
@@ -689,14 +706,20 @@ QList<ProjectExplorer::ExtraCompiler *> CMakeProject::findExtraCompilers() const
return pos >= 0 && fileExtensions.contains(fp.mid(pos + 1));
});
qCDebug(cmakeProjectLog) << "Finding Extra Compilers: Got list of files to check.";
// Generate the necessary information:
for (const FilePath &file : fileList) {
ExtraCompilerFactory *factory = Utils::findOrDefault(factories, [&file](const ExtraCompilerFactory *f) {
return file.endsWith('.' + f->sourceTag());
qCDebug(cmakeProjectLog) << "Finding Extra Compilers: Processing" << file.toUserOutput();
ExtraCompilerFactory *factory = Utils::findOrDefault(factories,
[&file](const ExtraCompilerFactory *f) {
return file.endsWith(
'.' + f->sourceTag());
});
QTC_ASSERT(factory, continue);
QStringList generated = filesGeneratedFrom(file.toString());
qCDebug(cmakeProjectLog) << "Finding Extra Compilers: generated files:" << generated;
if (generated.isEmpty())
continue;
@@ -704,8 +727,11 @@ QList<ProjectExplorer::ExtraCompiler *> CMakeProject::findExtraCompilers() const
= transform(generated,
[](const QString &s) { return FilePath::fromString(s); });
extraCompilers.append(factory->create(this, file, fileNames));
qCDebug(cmakeProjectLog) << "Finding Extra Compilers: done with" << file.toUserOutput();
}
qCDebug(cmakeProjectLog) << "Finding Extra Compilers: done.";
return extraCompilers;
}