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 <cristian.adam@qt.io>
This commit is contained in:
Eike Ziller
2020-11-19 09:45:55 +01:00
parent 36d5e328e4
commit bdc74ea2a0
4 changed files with 18 additions and 5 deletions

View File

@@ -390,6 +390,12 @@ void CMakeBuildSystem::setParametersAndRequestParse(const BuildDirParameters &pa
tr("The kit needs to define a CMake tool to parse this project."))); tr("The kit needs to define a CMake tool to parse this project.")));
return; return;
} }
if (!parameters.cmakeTool()->hasFileApi()) {
TaskHub::addTask(BuildSystemTask(Task::Error,
CMakeKitAspect::msgUnsupportedVersion(
parameters.cmakeTool()->version().fullVersion)));
return;
}
QTC_ASSERT(parameters.isValid(), return ); QTC_ASSERT(parameters.isValid(), return );
m_parameters = parameters; m_parameters = parameters;

View File

@@ -255,10 +255,7 @@ Tasks CMakeKitAspect::validate(const Kit *k) const
if (tool) { if (tool) {
CMakeTool::Version version = tool->version(); CMakeTool::Version version = tool->version();
if (version.major < 3 || (version.major == 3 && version.minor < 14)) { if (version.major < 3 || (version.major == 3 && version.minor < 14)) {
result << BuildSystemTask(Task::Warning, result << BuildSystemTask(Task::Warning, msgUnsupportedVersion(version.fullVersion));
tr("CMake version %1 is unsupported. Please update to "
"version 3.14 (with file-api) or later.")
.arg(QString::fromUtf8(version.fullVersion)));
} }
} }
return result; return result;
@@ -305,6 +302,13 @@ QSet<Utils::Id> CMakeKitAspect::availableFeatures(const Kit *k) const
return {}; 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: // CMakeGeneratorKitAspect:
// -------------------------------------------------------------------- // --------------------------------------------------------------------

View File

@@ -56,6 +56,8 @@ public:
void addToMacroExpander(ProjectExplorer::Kit *k, Utils::MacroExpander *expander) const final; void addToMacroExpander(ProjectExplorer::Kit *k, Utils::MacroExpander *expander) const final;
QSet<Utils::Id> availableFeatures(const ProjectExplorer::Kit *k) const final; QSet<Utils::Id> availableFeatures(const ProjectExplorer::Kit *k) const final;
static QString msgUnsupportedVersion(const QByteArray &versionString);
}; };
class CMAKE_EXPORT CMakeGeneratorKitAspect : public ProjectExplorer::KitAspect class CMAKE_EXPORT CMakeGeneratorKitAspect : public ProjectExplorer::KitAspect

View File

@@ -204,7 +204,8 @@ public:
if (column != 0) if (column != 0)
return QVariant(); return QVariant();
const bool hasError = !m_pathExists || !m_pathIsFile || !m_pathIsExecutable; const bool hasError = !m_isSupported || !m_pathExists || !m_pathIsFile
|| !m_pathIsExecutable;
if (hasError) if (hasError)
return Utils::Icons::CRITICAL.icon(); return Utils::Icons::CRITICAL.icon();
return QVariant(); return QVariant();