CMake: Register a feature for CMake-capable kits

This in theory enables to fix QTCREATORBUG-16204, but for that the wizard needs logic to adapt
the required features for the listed kits. That is still missing.

Task-number: QTCREATORBUG-16204
Change-Id: Ia01c11bb8c8567a9fc65b06912d6836b70a0195c
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Tobias Hunger
2017-04-03 14:31:32 +02:00
parent f8688a478e
commit 8b956868bb
3 changed files with 33 additions and 20 deletions

View File

@@ -25,6 +25,7 @@
#include "cmakekitinformation.h" #include "cmakekitinformation.h"
#include "cmakekitconfigwidget.h" #include "cmakekitconfigwidget.h"
#include "cmakeprojectconstants.h"
#include "cmaketoolmanager.h" #include "cmaketoolmanager.h"
#include "cmaketool.h" #include "cmaketool.h"
@@ -113,7 +114,7 @@ QList<Task> CMakeKitInformation::validate(const Kit *k) const
if (version.major < 3) { if (version.major < 3) {
result << Task(Task::Warning, tr("CMake version %1 is unsupported. Please update to " result << Task(Task::Warning, tr("CMake version %1 is unsupported. Please update to "
"version 3.0 or later.").arg(QString::fromUtf8(version.fullVersion)), "version 3.0 or later.").arg(QString::fromUtf8(version.fullVersion)),
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)); Utils::FileName(), -1, Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} }
} }
return result; return result;
@@ -152,6 +153,13 @@ void CMakeKitInformation::addToMacroExpander(Kit *k, Utils::MacroExpander *expan
}); });
} }
QSet<Core::Id> CMakeKitInformation::availableFeatures(const Kit *k) const
{
if (cmakeTool(k))
return { CMakeProjectManager::Constants::CMAKE_FEATURE_ID };
return {};
}
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// CMakeGeneratorKitInformation: // CMakeGeneratorKitInformation:
// -------------------------------------------------------------------- // --------------------------------------------------------------------
@@ -316,7 +324,7 @@ QVariant CMakeGeneratorKitInformation::defaultValue(const Kit *k) const
if (Utils::HostOsInfo::isWindowsHost()) { if (Utils::HostOsInfo::isWindowsHost()) {
// *sigh* Windows with its zoo of incompatible stuff again... // *sigh* Windows with its zoo of incompatible stuff again...
ToolChain *tc = ToolChainKitInformation::toolChain(k, Constants::CXX_LANGUAGE_ID); ToolChain *tc = ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID);
if (tc && tc->typeId() == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID) { if (tc && tc->typeId() == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID) {
it = std::find_if(known.constBegin(), known.constEnd(), it = std::find_if(known.constBegin(), known.constEnd(),
[extraGenerator](const CMakeTool::Generator &g) { [extraGenerator](const CMakeTool::Generator &g) {
@@ -353,7 +361,7 @@ QList<Task> CMakeGeneratorKitInformation::validate(const Kit *k) const
if (tool) { if (tool) {
if (!tool->isValid()) { if (!tool->isValid()) {
result << Task(Task::Warning, tr("CMake Tool is unconfigured, CMake generator will be ignored."), result << Task(Task::Warning, tr("CMake Tool is unconfigured, CMake generator will be ignored."),
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)); Utils::FileName(), -1, Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} else { } else {
QList<CMakeTool::Generator> known = tool->supportedGenerators(); QList<CMakeTool::Generator> known = tool->supportedGenerators();
auto it = std::find_if(known.constBegin(), known.constEnd(), [info](const CMakeTool::Generator &g) { auto it = std::find_if(known.constBegin(), known.constEnd(), [info](const CMakeTool::Generator &g) {
@@ -361,22 +369,22 @@ QList<Task> CMakeGeneratorKitInformation::validate(const Kit *k) const
}); });
if (it == known.constEnd()) { if (it == known.constEnd()) {
result << Task(Task::Warning, tr("CMake Tool does not support the configured generator."), result << Task(Task::Warning, tr("CMake Tool does not support the configured generator."),
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)); Utils::FileName(), -1, Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} else { } else {
if (!it->supportsPlatform && !info.platform.isEmpty()) { if (!it->supportsPlatform && !info.platform.isEmpty()) {
result << Task(Task::Warning, tr("Platform is not supported by the selected CMake generator."), result << Task(Task::Warning, tr("Platform is not supported by the selected CMake generator."),
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)); Utils::FileName(), -1, Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} }
if (!it->supportsToolset && !info.toolset.isEmpty()) { if (!it->supportsToolset && !info.toolset.isEmpty()) {
result << Task(Task::Warning, tr("Toolset is not supported by the selected CMake generator."), result << Task(Task::Warning, tr("Toolset is not supported by the selected CMake generator."),
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)); Utils::FileName(), -1, Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} }
} }
if (!tool->hasServerMode() && info.extraGenerator != "CodeBlocks") { if (!tool->hasServerMode() && info.extraGenerator != "CodeBlocks") {
result << Task(Task::Warning, tr("The selected CMake binary has no server-mode and the CMake " result << Task(Task::Warning, tr("The selected CMake binary has no server-mode and the CMake "
"generator does not generate a CodeBlocks file. " "generator does not generate a CodeBlocks file. "
"Qt Creator will not be able to parse CMake projects."), "Qt Creator will not be able to parse CMake projects."),
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)); Utils::FileName(), -1, Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} }
} }
} }
@@ -536,8 +544,8 @@ QVariant CMakeConfigurationKitInformation::defaultValue(const Kit *k) const
QList<Task> CMakeConfigurationKitInformation::validate(const Kit *k) const QList<Task> CMakeConfigurationKitInformation::validate(const Kit *k) const
{ {
const QtSupport::BaseQtVersion *const version = QtSupport::QtKitInformation::qtVersion(k); const QtSupport::BaseQtVersion *const version = QtSupport::QtKitInformation::qtVersion(k);
const ToolChain *const tcC = ToolChainKitInformation::toolChain(k, Constants::C_LANGUAGE_ID); const ToolChain *const tcC = ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::C_LANGUAGE_ID);
const ToolChain *const tcCxx = ToolChainKitInformation::toolChain(k, Constants::CXX_LANGUAGE_ID); const ToolChain *const tcCxx = ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID);
const CMakeConfig config = configuration(k); const CMakeConfig config = configuration(k);
const bool isQt4 = version && version->qtVersion() < QtSupport::QtVersionNumber(5, 0, 0); const bool isQt4 = version && version->qtVersion() < QtSupport::QtVersionNumber(5, 0, 0);
@@ -565,25 +573,25 @@ QList<Task> CMakeConfigurationKitInformation::validate(const Kit *k) const
if (version && version->isValid() && isQt4) { if (version && version->isValid() && isQt4) {
result << Task(Task::Warning, tr("CMake configuration has no path to qmake binary set, " result << Task(Task::Warning, tr("CMake configuration has no path to qmake binary set, "
"even though the kit has a valid Qt version."), "even though the kit has a valid Qt version."),
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)); Utils::FileName(), -1, Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} }
} else { } else {
if (!version || !version->isValid()) { if (!version || !version->isValid()) {
result << Task(Task::Warning, tr("CMake configuration has a path to a qmake binary set, " result << Task(Task::Warning, tr("CMake configuration has a path to a qmake binary set, "
"even though the kit has no valid Qt version."), "even though the kit has no valid Qt version."),
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)); Utils::FileName(), -1, Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} else if (qmakePath != version->qmakeCommand() && isQt4) { } else if (qmakePath != version->qmakeCommand() && isQt4) {
result << Task(Task::Warning, tr("CMake configuration has a path to a qmake binary set " result << Task(Task::Warning, tr("CMake configuration has a path to a qmake binary set "
"that does not match the qmake binary path " "that does not match the qmake binary path "
"configured in the Qt version."), "configured in the Qt version."),
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)); Utils::FileName(), -1, Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} }
} }
if (version && !qtInstallDirs.contains(version->qmakeProperty("QT_INSTALL_PREFIX")) && !isQt4) { if (version && !qtInstallDirs.contains(version->qmakeProperty("QT_INSTALL_PREFIX")) && !isQt4) {
if (version->isValid()) { if (version->isValid()) {
result << Task(Task::Warning, tr("CMake configuration has no CMAKE_PREFIX_PATH set " result << Task(Task::Warning, tr("CMake configuration has no CMAKE_PREFIX_PATH set "
"that points to the kit Qt version."), "that points to the kit Qt version."),
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)); Utils::FileName(), -1, Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} }
} }
@@ -592,18 +600,18 @@ QList<Task> CMakeConfigurationKitInformation::validate(const Kit *k) const
if (tcC && tcC->isValid()) { if (tcC && tcC->isValid()) {
result << Task(Task::Warning, tr("CMake configuration has no path to a C compiler set, " result << Task(Task::Warning, tr("CMake configuration has no path to a C compiler set, "
"even though the kit has a valid tool chain."), "even though the kit has a valid tool chain."),
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)); Utils::FileName(), -1, Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} }
} else { } else {
if (!tcC || !tcC->isValid()) { if (!tcC || !tcC->isValid()) {
result << Task(Task::Warning, tr("CMake configuration has a path to a C compiler set, " result << Task(Task::Warning, tr("CMake configuration has a path to a C compiler set, "
"even though the kit has no valid tool chain."), "even though the kit has no valid tool chain."),
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)); Utils::FileName(), -1, Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} else if (tcCPath != tcC->compilerCommand()) { } else if (tcCPath != tcC->compilerCommand()) {
result << Task(Task::Warning, tr("CMake configuration has a path to a C compiler set " result << Task(Task::Warning, tr("CMake configuration has a path to a C compiler set "
"that does not match the compiler path " "that does not match the compiler path "
"configured in the tool chain of the kit."), "configured in the tool chain of the kit."),
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)); Utils::FileName(), -1, Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} }
} }
@@ -611,18 +619,18 @@ QList<Task> CMakeConfigurationKitInformation::validate(const Kit *k) const
if (tcCxx && tcCxx->isValid()) { if (tcCxx && tcCxx->isValid()) {
result << Task(Task::Warning, tr("CMake configuration has no path to a C++ compiler set, " result << Task(Task::Warning, tr("CMake configuration has no path to a C++ compiler set, "
"even though the kit has a valid tool chain."), "even though the kit has a valid tool chain."),
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)); Utils::FileName(), -1, Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} }
} else { } else {
if (!tcCxx || !tcCxx->isValid()) { if (!tcCxx || !tcCxx->isValid()) {
result << Task(Task::Warning, tr("CMake configuration has a path to a C++ compiler set, " result << Task(Task::Warning, tr("CMake configuration has a path to a C++ compiler set, "
"even though the kit has no valid tool chain."), "even though the kit has no valid tool chain."),
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)); Utils::FileName(), -1, Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} else if (tcCxxPath != tcCxx->compilerCommand()) { } else if (tcCxxPath != tcCxx->compilerCommand()) {
result << Task(Task::Warning, tr("CMake configuration has a path to a C++ compiler set " result << Task(Task::Warning, tr("CMake configuration has a path to a C++ compiler set "
"that does not match the compiler path " "that does not match the compiler path "
"configured in the tool chain of the kit."), "configured in the tool chain of the kit."),
Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)); Utils::FileName(), -1, Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
} }
} }

View File

@@ -55,6 +55,8 @@ public:
ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const final; ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const final;
void addToMacroExpander(ProjectExplorer::Kit *k, Utils::MacroExpander *expander) const final; void addToMacroExpander(ProjectExplorer::Kit *k, Utils::MacroExpander *expander) const final;
QSet<Core::Id> availableFeatures(const ProjectExplorer::Kit *k) const final;
}; };
class CMAKE_EXPORT CMakeGeneratorKitInformation : public ProjectExplorer::KitInformation class CMAKE_EXPORT CMakeGeneratorKitInformation : public ProjectExplorer::KitInformation

View File

@@ -64,5 +64,8 @@ const char BUILD_TARGET_CONTEXTMENU[] = "CMake.BuildTargetContextMenu";
// Build Step // Build Step
const char CMAKE_BUILD_STEP_ID[] = "CMakeProjectManager.MakeStep"; const char CMAKE_BUILD_STEP_ID[] = "CMakeProjectManager.MakeStep";
// Features
const char CMAKE_FEATURE_ID[] = "CMakeProjectManager.Wizard.FeatureCMake";
} // namespace Constants } // namespace Constants
} // namespace CMakeProjectManager } // namespace CMakeProjectManager