CMakeBuildConfiguration *CMakeBuildConfigurationFactory::create(ProjectExplorer::Target *parent, const Core::Id id, const QString &name) { if (!canCreate(parent, id)) return 0; CMakeProject *project = static_cast<CMakeProject *>(parent->project()); bool ok = true; QString buildConfigurationName = name; if (buildConfigurationName.isNull()) buildConfigurationName = QInputDialog::getText(0, tr("New Configuration"), tr("New configuration name:"), QLineEdit::Normal, QString(), &ok); buildConfigurationName = buildConfigurationName.trimmed(); if (!ok || buildConfigurationName.isEmpty()) return 0; CMakeOpenProjectWizard::BuildInfo info; info.sourceDirectory = project->projectDirectory(); info.environment = Utils::Environment::systemEnvironment(); parent->kit()->addToEnvironment(info.environment); info.buildDirectory = project->shadowBuildDirectory(project->document()->fileName(), parent->kit(), buildConfigurationName); info.kit = parent->kit(); info.useNinja = false; // This is ignored anyway CMakeOpenProjectWizard copw(project->projectManager(), CMakeOpenProjectWizard::ChangeDirectory, info); if (copw.exec() != QDialog::Accepted) return 0; CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(parent); bc->setDisplayName(buildConfigurationName); ProjectExplorer::BuildStepList *buildSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); ProjectExplorer::BuildStepList *cleanSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_CLEAN); MakeStep *makeStep = new MakeStep(buildSteps); buildSteps->insertStep(0, makeStep); MakeStep *cleanMakeStep = new MakeStep(cleanSteps); cleanSteps->insertStep(0, cleanMakeStep); cleanMakeStep->setAdditionalArguments(QLatin1String("clean")); cleanMakeStep->setClean(true); bc->setBuildDirectory(copw.buildDirectory()); bc->setUseNinja(copw.useNinja()); // Default to all if (project->hasBuildTarget(QLatin1String("all"))) makeStep->setBuildTarget(QLatin1String("all"), true); return bc; }
void CMakeManager::runCMake(ProjectExplorer::Project *project) { if (!project) return; CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(project); if (!cmakeProject) return; if (!cmakeProject->activeTarget()) return; if (!cmakeProject->activeTarget()->activeBuildConfiguration()) return; CMakeBuildConfiguration *bc = cmakeProject->activeTarget()->activeBuildConfiguration(); CMakeOpenProjectWizard copw(this, cmakeProject->projectDirectory(), bc->buildDirectory(), CMakeOpenProjectWizard::WantToUpdate, bc->environment()); if (copw.exec() == QDialog::Accepted) { cmakeProject->parseCMakeLists(); } }