From bdc74ea2a0047186f0b3e9240fa8cd894c306a55 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 19 Nov 2020 09:45:55 +0100 Subject: [PATCH] cmake: Show errors for unsupported CMake versions Show an error icon in the CMake settings, and instead running CMake with unsupported parameters show an error in the Issues pane. Arguably it should not be possible to select an unsupported CMake version in the kit settings at all (neither manually nor automatically when setting up kits), but this is the less intrusive change for now. Fixes: QTCREATORBUG-24553 Change-Id: I32caa2ce93d28cbd9db90e2004d60da93d32c68c Reviewed-by: Cristian Adam --- src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp | 6 ++++++ .../cmakeprojectmanager/cmakekitinformation.cpp | 12 ++++++++---- .../cmakeprojectmanager/cmakekitinformation.h | 2 ++ .../cmakeprojectmanager/cmakesettingspage.cpp | 3 ++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index 7d1d6cf5f56..c77f7855100 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -390,6 +390,12 @@ void CMakeBuildSystem::setParametersAndRequestParse(const BuildDirParameters &pa tr("The kit needs to define a CMake tool to parse this project."))); return; } + if (!parameters.cmakeTool()->hasFileApi()) { + TaskHub::addTask(BuildSystemTask(Task::Error, + CMakeKitAspect::msgUnsupportedVersion( + parameters.cmakeTool()->version().fullVersion))); + return; + } QTC_ASSERT(parameters.isValid(), return ); m_parameters = parameters; diff --git a/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp b/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp index bfafbd42ac0..1343e331b29 100644 --- a/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp +++ b/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp @@ -255,10 +255,7 @@ Tasks CMakeKitAspect::validate(const Kit *k) const if (tool) { CMakeTool::Version version = tool->version(); if (version.major < 3 || (version.major == 3 && version.minor < 14)) { - result << BuildSystemTask(Task::Warning, - tr("CMake version %1 is unsupported. Please update to " - "version 3.14 (with file-api) or later.") - .arg(QString::fromUtf8(version.fullVersion))); + result << BuildSystemTask(Task::Warning, msgUnsupportedVersion(version.fullVersion)); } } return result; @@ -305,6 +302,13 @@ QSet CMakeKitAspect::availableFeatures(const Kit *k) const return {}; } +QString CMakeKitAspect::msgUnsupportedVersion(const QByteArray &versionString) +{ + return tr("CMake version %1 is unsupported. Please update to " + "version 3.14 (with file-api) or later.") + .arg(QString::fromUtf8(versionString)); +} + // -------------------------------------------------------------------- // CMakeGeneratorKitAspect: // -------------------------------------------------------------------- diff --git a/src/plugins/cmakeprojectmanager/cmakekitinformation.h b/src/plugins/cmakeprojectmanager/cmakekitinformation.h index 8edfba91e6c..71444463a45 100644 --- a/src/plugins/cmakeprojectmanager/cmakekitinformation.h +++ b/src/plugins/cmakeprojectmanager/cmakekitinformation.h @@ -56,6 +56,8 @@ public: void addToMacroExpander(ProjectExplorer::Kit *k, Utils::MacroExpander *expander) const final; QSet availableFeatures(const ProjectExplorer::Kit *k) const final; + + static QString msgUnsupportedVersion(const QByteArray &versionString); }; class CMAKE_EXPORT CMakeGeneratorKitAspect : public ProjectExplorer::KitAspect diff --git a/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp b/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp index e26a0cb9706..30e1a50dd38 100644 --- a/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp +++ b/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp @@ -204,7 +204,8 @@ public: if (column != 0) return QVariant(); - const bool hasError = !m_pathExists || !m_pathIsFile || !m_pathIsExecutable; + const bool hasError = !m_isSupported || !m_pathExists || !m_pathIsFile + || !m_pathIsExecutable; if (hasError) return Utils::Icons::CRITICAL.icon(); return QVariant();