forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -144,9 +144,12 @@ void CMakeProject::changeActiveBuildConfiguration(ProjectExplorer::BuildConfigur
|
||||
|
||||
if (mode != CMakeOpenProjectWizard::Nothing) {
|
||||
CMakeBuildInfo info(cmakebc);
|
||||
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), m_manager, mode, &info);
|
||||
if (copw.exec() == QDialog::Accepted)
|
||||
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), m_manager, mode, &info,
|
||||
bc->target()->displayName(), bc->displayName());
|
||||
if (copw.exec() == QDialog::Accepted) {
|
||||
cmakebc->setUseNinja(copw.useNinja()); // NeedToCreate can change the Ninja setting
|
||||
cmakebc->setInitialArguments(QString());
|
||||
}
|
||||
}
|
||||
|
||||
// reparse
|
||||
@@ -379,6 +382,16 @@ bool CMakeProject::parseCMakeLists()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CMakeProject::needsConfiguration() const
|
||||
{
|
||||
return targets().isEmpty();
|
||||
}
|
||||
|
||||
bool CMakeProject::requiresTargetPanel() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMakeProject::isProjectFile(const FileName &fileName)
|
||||
{
|
||||
return m_watchedFiles.contains(fileName);
|
||||
@@ -529,31 +542,7 @@ Project::RestoreResult CMakeProject::fromMap(const QVariantMap &map, QString *er
|
||||
|
||||
bool hasUserFile = activeTarget();
|
||||
if (!hasUserFile) {
|
||||
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), m_manager, projectDirectory().toString(), Environment::systemEnvironment());
|
||||
if (copw.exec() != QDialog::Accepted)
|
||||
return RestoreResult::UserAbort;
|
||||
Kit *k = copw.kit();
|
||||
Target *t = new Target(this, k);
|
||||
CMakeBuildConfiguration *bc(new CMakeBuildConfiguration(t));
|
||||
bc->setDefaultDisplayName(QLatin1String("all"));
|
||||
bc->setUseNinja(copw.useNinja());
|
||||
bc->setBuildDirectory(FileName::fromString(copw.buildDirectory()));
|
||||
ProjectExplorer::BuildStepList *buildSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
||||
ProjectExplorer::BuildStepList *cleanSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_CLEAN);
|
||||
|
||||
// Now create a standard build configuration
|
||||
buildSteps->insertStep(0, new MakeStep(buildSteps));
|
||||
|
||||
MakeStep *cleanMakeStep = new MakeStep(cleanSteps);
|
||||
cleanSteps->insertStep(0, cleanMakeStep);
|
||||
cleanMakeStep->setAdditionalArguments(QLatin1String("clean"));
|
||||
cleanMakeStep->setClean(true);
|
||||
|
||||
t->addBuildConfiguration(bc);
|
||||
|
||||
t->updateDefaultDeployConfigurations();
|
||||
|
||||
addTarget(t);
|
||||
// Nothing to do, the target setup page will show up
|
||||
} else {
|
||||
// We have a user file, but we could still be missing the cbp file
|
||||
// or simply run createXml with the saved settings
|
||||
@@ -573,11 +562,14 @@ Project::RestoreResult CMakeProject::fromMap(const QVariantMap &map, QString *er
|
||||
|
||||
if (mode != CMakeOpenProjectWizard::Nothing) {
|
||||
CMakeBuildInfo info(activeBC);
|
||||
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), m_manager, mode, &info);
|
||||
if (copw.exec() != QDialog::Accepted)
|
||||
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), m_manager, mode, &info,
|
||||
activeBC->target()->displayName(), activeBC->displayName());
|
||||
if (copw.exec() != QDialog::Accepted) {
|
||||
return RestoreResult::UserAbort;
|
||||
else
|
||||
} else {
|
||||
activeBC->setUseNinja(copw.useNinja());
|
||||
activeBC->setInitialArguments(QString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -614,6 +606,8 @@ CMakeBuildTarget CMakeProject::buildTargetForTitle(const QString &title)
|
||||
|
||||
QString CMakeProject::uiHeaderFile(const QString &uiFile)
|
||||
{
|
||||
if (!activeTarget())
|
||||
return QString();
|
||||
QFileInfo fi(uiFile);
|
||||
FileName project = projectDirectory();
|
||||
FileName baseDirectory = FileName::fromString(fi.absolutePath());
|
||||
@@ -684,6 +678,8 @@ void CMakeProject::updateRunConfigurations(Target *t)
|
||||
void CMakeProject::updateApplicationAndDeploymentTargets()
|
||||
{
|
||||
Target *t = activeTarget();
|
||||
if (!t)
|
||||
return;
|
||||
|
||||
QFile deploymentFile;
|
||||
QTextStream deploymentStream;
|
||||
|
||||
Reference in New Issue
Block a user