diff options
author | Daniel Teske <daniel.teske@theqtcompany.com> | 2015-09-10 16:17:38 +0200 |
---|---|---|
committer | Daniel Teske <daniel.teske@theqtcompany.com> | 2015-09-16 10:08:52 +0000 |
commit | 014a7b332b1761a4fb8d05f034dd897c40145b31 (patch) | |
tree | baf2c810d1ff66307c1a03ba15725d02ef7b6c89 /src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp | |
parent | 798fa669bf0d42230d225493d20af00cc5c184c7 (diff) | |
download | qt-creator-014a7b332b1761a4fb8d05f034dd897c40145b31.tar.gz |
CMake: Rewrite logic for kit selection
Some time ago the all the wizards for the Plain C++ were coalesced into one wizard.
Since then the wizard asks first for the targets via a targetsetuppage and then
in the CMakeOpenProjectWizard asked for the kit again.
This patch clean thats up, by always using the TargetSetupPage for kit
selection and removing code from the CMakeOpenProjectWizard for kit selection.
It also adds more types of buildconfigurations
Offer: Debug, Release, ReleaseWithDebugInfo, MinSizeRelease with the
corresponding -DCMAKE_BUILD_TYPE parameters. That argument is saved
in the build configuration and used once for the first cmake run. (Subsequent
runs of cmake don't require passing that to cmake again.)
Also do not require running cmake on creating the buildconfiguraiton, instead
postpone that until the buildconfiguration is made active. With the current
cmake wizard, selecting multiple kits would show a dialog per buildconfiguration.
Change-Id: I3bb806113f4f529f8e291830647d2515a6c4df8a
Task-number: QTCREATORBUG-12219
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Diffstat (limited to 'src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp')
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp | 80 |
1 files changed, 62 insertions, 18 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp index 36a9c9eb06..b8cd3a10b3 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp @@ -59,6 +59,7 @@ namespace CMakeProjectManager { namespace Internal { const char USE_NINJA_KEY[] = "CMakeProjectManager.CMakeBuildConfiguration.UseNinja"; +const char INITIAL_ARGUMENTS[] = "CMakeProjectManager.CMakeBuildConfiguration.InitialArgument"; static FileName shadowBuildDirectory(const FileName &projectFilePath, const Kit *k, const QString &bcName) { @@ -85,7 +86,8 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent CMakeBuildConfiguration *source) : BuildConfiguration(parent, source), m_msvcVersion(source->m_msvcVersion), - m_useNinja(source->m_useNinja) + m_useNinja(source->m_useNinja), + m_initialArguments(source->m_initialArguments) { Q_ASSERT(parent); cloneSteps(source); @@ -95,6 +97,7 @@ QVariantMap CMakeBuildConfiguration::toMap() const { QVariantMap map(ProjectExplorer::BuildConfiguration::toMap()); map.insert(QLatin1String(USE_NINJA_KEY), m_useNinja); + map.insert(QLatin1String(INITIAL_ARGUMENTS), m_initialArguments); return map; } @@ -104,6 +107,7 @@ bool CMakeBuildConfiguration::fromMap(const QVariantMap &map) return false; m_useNinja = map.value(QLatin1String(USE_NINJA_KEY), false).toBool(); + m_initialArguments = map.value(QLatin1String(INITIAL_ARGUMENTS)).toString(); return true; } @@ -126,6 +130,16 @@ void CMakeBuildConfiguration::emitBuildTypeChanged() emit buildTypeChanged(); } +void CMakeBuildConfiguration::setInitialArguments(const QString &arguments) +{ + m_initialArguments = arguments; +} + +QString CMakeBuildConfiguration::initialArguments() const +{ + return m_initialArguments; +} + CMakeBuildConfiguration::~CMakeBuildConfiguration() { } @@ -156,9 +170,12 @@ QList<ProjectExplorer::BuildInfo *> CMakeBuildConfigurationFactory::availableBui { QList<ProjectExplorer::BuildInfo *> result; - CMakeBuildInfo *info = createBuildInfo(parent->kit(), - parent->project()->projectDirectory().toString()); - result << info; + for (int type = BuildTypeNone; type != BuildTypeLast; ++type) { + CMakeBuildInfo *info = createBuildInfo(parent->kit(), + parent->project()->projectDirectory().toString(), + BuildType(type)); + result << info; + } return result; } @@ -175,11 +192,19 @@ QList<ProjectExplorer::BuildInfo *> CMakeBuildConfigurationFactory::availableSet { QList<ProjectExplorer::BuildInfo *> result; const FileName projectPathName = FileName::fromString(projectPath); - CMakeBuildInfo *info = createBuildInfo(k, ProjectExplorer::Project::projectDirectory(projectPathName).toString()); - //: The name of the build configuration created by default for a cmake project. - info->displayName = tr("Default"); - info->buildDirectory = shadowBuildDirectory(projectPathName, k, info->displayName); - result << info; + for (int type = BuildTypeNone; type != BuildTypeLast; ++type) { + CMakeBuildInfo *info = createBuildInfo(k, + ProjectExplorer::Project::projectDirectory(projectPathName).toString(), + BuildType(type)); + if (type == BuildTypeNone) { + //: The name of the build configuration created by default for a cmake project. + info->displayName = tr("Default"); + } else { + info->displayName = info->typeName; + } + info->buildDirectory = shadowBuildDirectory(projectPathName, k, info->displayName); + result << info; + } return result; } @@ -192,17 +217,12 @@ ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(Proj CMakeBuildInfo copy(*static_cast<const CMakeBuildInfo *>(info)); CMakeProject *project = static_cast<CMakeProject *>(parent->project()); - CMakeManager *manager = static_cast<CMakeManager *>(project->projectManager()); if (copy.buildDirectory.isEmpty()) { copy.buildDirectory = shadowBuildDirectory(project->projectFilePath(), parent->kit(), copy.displayName); } - CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), manager, CMakeOpenProjectWizard::ChangeDirectory, ©); - if (copw.exec() != QDialog::Accepted) - return 0; - CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(parent); bc->setDisplayName(copy.displayName); bc->setDefaultDisplayName(copy.displayName); @@ -218,8 +238,8 @@ ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(Proj cleanMakeStep->setAdditionalArguments(QLatin1String("clean")); cleanMakeStep->setClean(true); - bc->setBuildDirectory(FileName::fromString(copw.buildDirectory())); - bc->setUseNinja(copw.useNinja()); + bc->setBuildDirectory(copy.buildDirectory); + bc->setInitialArguments(copy.arguments); // Default to all if (project->hasBuildTarget(QLatin1String("all"))) @@ -270,15 +290,39 @@ bool CMakeBuildConfigurationFactory::canHandle(const ProjectExplorer::Target *t) } CMakeBuildInfo *CMakeBuildConfigurationFactory::createBuildInfo(const ProjectExplorer::Kit *k, - const QString &sourceDir) const + const QString &sourceDir, + BuildType buildType) const { CMakeBuildInfo *info = new CMakeBuildInfo(this); - info->typeName = tr("Build"); info->kitId = k->id(); info->environment = Environment::systemEnvironment(); k->addToEnvironment(info->environment); info->useNinja = false; info->sourceDirectory = sourceDir; + switch (buildType) { + case BuildTypeNone: + info->typeName = tr("Build"); + break; + case BuildTypeDebug: + info->arguments = QLatin1String("-DCMAKE_BUILD_TYPE=Debug"); + info->typeName = tr("Debug"); + break; + case BuildTypeRelease: + info->arguments = QLatin1String("-DCMAKE_BUILD_TYPE=Release"); + info->typeName = tr("Release"); + break; + case BuildTypeMinSizeRel: + info->arguments = QLatin1String("-DCMAKE_BUILD_TYPE=MinSizeRel"); + info->typeName = tr("Minimum Size Release"); + break; + case BuildTypeRelWithDebInfo: + info->arguments = QLatin1String("-DCMAKE_BUILD_TYPE=RelWithDebInfo"); + info->typeName = tr("Release with Debug Information"); + break; + default: + QTC_CHECK(false); + break; + } return info; } |