Commit 1d6c960f authored by Tobias Hunger's avatar Tobias Hunger

CMake: Avoid passing CMakeManager around

Change-Id: I96d7f3785767d1d56ca27a2d0af778edf98d63e1
Reviewed-by: default avatarTim Jenssen <tim.jenssen@theqtcompany.com>
parent 53597087
......@@ -91,13 +91,11 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
void CMakeBuildSettingsWidget::openChangeBuildDirectoryDialog()
{
auto project = static_cast<CMakeProject *>(m_buildConfiguration->target()->project());
auto manager = static_cast<CMakeManager *>(project->projectManager());
CMakeBuildInfo info(m_buildConfiguration);
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(),
manager, CMakeOpenProjectWizard::ChangeDirectory,
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), CMakeOpenProjectWizard::ChangeDirectory,
&info);
if (copw.exec() == QDialog::Accepted) {
auto project = static_cast<CMakeProject *>(m_buildConfiguration->target()->project());
project->changeBuildDirectory(m_buildConfiguration, copw.buildDirectory());
m_pathLineEdit->setText(m_buildConfiguration->rawBuildDirectory().toString());
}
......@@ -107,13 +105,13 @@ void CMakeBuildSettingsWidget::runCMake()
{
if (!ProjectExplorer::ProjectExplorerPlugin::saveModifiedFiles())
return;
auto project = static_cast<CMakeProject *>(m_buildConfiguration->target()->project());
auto manager = static_cast<CMakeManager *>(project->projectManager());
CMakeBuildInfo info(m_buildConfiguration);
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), manager,
CMakeOpenProjectWizard::WantToUpdate, &info);
if (copw.exec() == QDialog::Accepted)
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), CMakeOpenProjectWizard::WantToUpdate,
&info);
if (copw.exec() == QDialog::Accepted) {
auto project = static_cast<CMakeProject *>(m_buildConfiguration->target()->project());
project->parseCMakeLists();
}
}
} // namespace Internal
} // namespace CMakeProjectManager
......@@ -82,14 +82,13 @@ using namespace ProjectExplorer;
//////////////
/// CMakeOpenProjectWizard
//////////////
CMakeOpenProjectWizard::CMakeOpenProjectWizard(QWidget *parent, CMakeManager *cmakeManager,
CMakeOpenProjectWizard::CMakeOpenProjectWizard(QWidget *parent,
CMakeOpenProjectWizard::Mode mode,
const CMakeBuildInfo *info)
: Utils::Wizard(parent),
m_cmakeManager(cmakeManager),
m_sourceDirectory(info->sourceDirectory),
m_environment(info->environment),
m_kit(KitManager::find(info->kitId))
const CMakeBuildInfo *info) :
Utils::Wizard(parent),
m_sourceDirectory(info->sourceDirectory),
m_environment(info->environment),
m_kit(KitManager::find(info->kitId))
{
CMakeRunPage::Mode rmode;
if (mode == CMakeOpenProjectWizard::NeedToCreate)
......@@ -115,11 +114,6 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(QWidget *parent, CMakeManager *cm
setWindowTitle(tr("CMake Wizard"));
}
CMakeManager *CMakeOpenProjectWizard::cmakeManager() const
{
return m_cmakeManager;
}
bool CMakeOpenProjectWizard::hasInSourceBuild() const
{
return QFileInfo::exists(m_sourceDirectory + QLatin1String("/CMakeCache.txt"));
......@@ -127,7 +121,7 @@ bool CMakeOpenProjectWizard::hasInSourceBuild() const
bool CMakeOpenProjectWizard::compatibleKitExist() const
{
bool preferNinja = m_cmakeManager->preferNinja();
bool preferNinja = CMakeManager::preferNinja();
const QList<Kit *> kitList = KitManager::kits();
foreach (Kit *k, kitList) {
......@@ -493,7 +487,7 @@ void CMakeRunPage::initializePage()
// Build the list of generators/toolchains we want to offer
m_generatorComboBox->clear();
bool preferNinja = m_cmakeWizard->cmakeManager()->preferNinja();
bool preferNinja = CMakeManager::preferNinja();
QList<GeneratorInfo> infos;
CMakeTool *cmake = CMakeKitInformation::cmakeTool(m_cmakeWizard->kit());
......@@ -539,7 +533,6 @@ void CMakeRunPage::runCMake()
m_output->clear();
CMakeTool *cmake = CMakeKitInformation::cmakeTool(generatorInfo.kit());
CMakeManager *cmakeManager = m_cmakeWizard->cmakeManager();
if (cmake && cmake->isValid()) {
m_cmakeProcess = new Utils::QtcProcess();
connect(m_cmakeProcess, &QProcess::readyReadStandardOutput,
......@@ -555,7 +548,7 @@ void CMakeRunPage::runCMake()
.arg(cmake->cmakeExecutable().toUserOutput())
.arg(arguments)
.arg(QDir::toNativeSeparators(m_buildDirectory)));
cmakeManager->createXmlFile(m_cmakeProcess, cmake->cmakeExecutable().toString(),
CMakeManager::createXmlFile(m_cmakeProcess, cmake->cmakeExecutable().toString(),
arguments, m_cmakeWizard->sourceDirectory(),
m_buildDirectory, env,
QString::fromLatin1(generatorInfo.generatorArgument()),
......
......@@ -77,13 +77,11 @@ public:
/// used to update if we have already a .user file
/// recreates or updates the cbp file
/// Also used to change the build directory of one buildconfiguration or create a new buildconfiguration
CMakeOpenProjectWizard(QWidget *parent, CMakeManager *cmakeManager, Mode mode,
const CMakeBuildInfo *info);
CMakeOpenProjectWizard(QWidget *parent, Mode mode, const CMakeBuildInfo *info);
QString buildDirectory() const;
QString sourceDirectory() const;
void setBuildDirectory(const QString &directory);
CMakeManager *cmakeManager() const;
QString arguments() const;
void setArguments(const QString &args);
Utils::Environment environment() const;
......@@ -94,7 +92,6 @@ public:
private:
bool hasInSourceBuild() const;
CMakeManager *m_cmakeManager;
QString m_buildDirectory;
QString m_sourceDirectory;
QString m_arguments;
......
......@@ -145,7 +145,7 @@ void CMakeProject::changeActiveBuildConfiguration(ProjectExplorer::BuildConfigur
if (mode != CMakeOpenProjectWizard::Nothing) {
CMakeBuildInfo info(cmakebc);
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), m_manager, mode, &info);
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), mode, &info);
if (copw.exec() == QDialog::Accepted)
cmakebc->setInitialArguments(QString());
}
......@@ -565,7 +565,7 @@ 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);
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), mode, &info);
if (copw.exec() != QDialog::Accepted)
return RestoreResult::UserAbort;
else
......
......@@ -112,8 +112,7 @@ void CMakeManager::runCMake(ProjectExplorer::Project *project)
CMakeBuildInfo info(bc);
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), this, CMakeOpenProjectWizard::WantToUpdate,
&info);
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), CMakeOpenProjectWizard::WantToUpdate, &info);
if (copw.exec() == QDialog::Accepted)
cmakeProject->parseCMakeLists();
}
......@@ -136,7 +135,7 @@ QString CMakeManager::mimeType() const
return QLatin1String(Constants::CMAKEPROJECTMIMETYPE);
}
bool CMakeManager::preferNinja() const
bool CMakeManager::preferNinja()
{
return CMakeToolManager::preferNinja();
}
......@@ -145,9 +144,10 @@ bool CMakeManager::preferNinja() const
// we probably want the process instead of this function
// cmakeproject then could even run the cmake process in the background, adding the files afterwards
// sounds like a plan
void CMakeManager::createXmlFile(Utils::QtcProcess *proc, const QString &executable, const QString &arguments,
const QString &sourceDirectory, const QDir &buildDirectory,
const Utils::Environment &env, const QString &generator, const QString &preloadCache)
void CMakeManager::createXmlFile(Utils::QtcProcess *proc, const QString &executable,
const QString &arguments, const QString &sourceDirectory,
const QDir &buildDirectory, const Utils::Environment &env,
const QString &generator, const QString &preloadCache)
{
QString buildDirectoryPath = buildDirectory.absolutePath();
buildDirectory.mkpath(buildDirectoryPath);
......
......@@ -58,15 +58,11 @@ public:
ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString) override;
QString mimeType() const override;
void createXmlFile(Utils::QtcProcess *process,
const QString &executable,
const QString &arguments,
const QString &sourceDirectory,
const QDir &buildDirectory,
const Utils::Environment &env,
const QString &generator,
const QString &preloadCache);
bool preferNinja() const;
static void createXmlFile(Utils::QtcProcess *process, const QString &executable,
const QString &arguments, const QString &sourceDirectory,
const QDir &buildDirectory, const Utils::Environment &env,
const QString &generator, const QString &preloadCache);
static bool preferNinja();
static QString findCbpFile(const QDir &);
private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment