forked from qt-creator/qt-creator
CMakePM: Add project CMake settings support
This is useful if projects do not to have "Auto Run" CMake or want to have Junctions enabled. Change-Id: I4a636e7bf64fe2d29d15d39fe9aa46807684c716 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -50,13 +50,13 @@ BuildDirParameters::BuildDirParameters(CMakeBuildSystem *buildSystem)
|
|||||||
});
|
});
|
||||||
const Target *t = bc->target();
|
const Target *t = bc->target();
|
||||||
const Kit *k = t->kit();
|
const Kit *k = t->kit();
|
||||||
const Project *p = t->project();
|
|
||||||
|
|
||||||
projectName = p->displayName();
|
project = t->project();
|
||||||
|
projectName = project->displayName();
|
||||||
|
|
||||||
sourceDirectory = bc->sourceDirectory();
|
sourceDirectory = bc->sourceDirectory();
|
||||||
if (sourceDirectory.isEmpty())
|
if (sourceDirectory.isEmpty())
|
||||||
sourceDirectory = p->projectDirectory();
|
sourceDirectory = project->projectDirectory();
|
||||||
buildDirectory = bc->buildDirectory();
|
buildDirectory = bc->buildDirectory();
|
||||||
|
|
||||||
cmakeBuildType = buildSystem->cmakeBuildType();
|
cmakeBuildType = buildSystem->cmakeBuildType();
|
||||||
|
@@ -15,6 +15,10 @@ class MacroExpander;
|
|||||||
class OutputLineParser;
|
class OutputLineParser;
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
|
||||||
|
namespace ProjectExplorer {
|
||||||
|
class Project;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CMakeProjectManager::Internal {
|
namespace CMakeProjectManager::Internal {
|
||||||
|
|
||||||
class CMakeBuildSystem;
|
class CMakeBuildSystem;
|
||||||
@@ -29,6 +33,7 @@ public:
|
|||||||
CMakeTool *cmakeTool() const;
|
CMakeTool *cmakeTool() const;
|
||||||
|
|
||||||
QString projectName;
|
QString projectName;
|
||||||
|
ProjectExplorer::Project *project = nullptr;
|
||||||
|
|
||||||
Utils::FilePath sourceDirectory;
|
Utils::FilePath sourceDirectory;
|
||||||
Utils::FilePath buildDirectory;
|
Utils::FilePath buildDirectory;
|
||||||
|
@@ -42,6 +42,7 @@
|
|||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/projectexplorertr.h>
|
#include <projectexplorer/projectexplorertr.h>
|
||||||
#include <projectexplorer/projectmanager.h>
|
#include <projectexplorer/projectmanager.h>
|
||||||
|
#include <projectexplorer/projecttree.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <projectexplorer/taskhub.h>
|
#include <projectexplorer/taskhub.h>
|
||||||
|
|
||||||
@@ -297,7 +298,8 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
|
|||||||
m_batchEditButton->setToolTip(Tr::tr("Set or reset multiple values in the CMake configuration."));
|
m_batchEditButton->setToolTip(Tr::tr("Set or reset multiple values in the CMake configuration."));
|
||||||
|
|
||||||
m_showAdvancedCheckBox = new QCheckBox(Tr::tr("Advanced"));
|
m_showAdvancedCheckBox = new QCheckBox(Tr::tr("Advanced"));
|
||||||
m_showAdvancedCheckBox->setChecked(settings().showAdvancedOptionsByDefault());
|
m_showAdvancedCheckBox->setChecked(
|
||||||
|
settings(m_buildConfig->project()).showAdvancedOptionsByDefault());
|
||||||
|
|
||||||
connect(m_configView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
connect(m_configView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||||
this, [this](const QItemSelection &, const QItemSelection &) {
|
this, [this](const QItemSelection &, const QItemSelection &) {
|
||||||
@@ -586,11 +588,11 @@ void CMakeBuildSettingsWidget::reconfigureWithInitialParameters()
|
|||||||
Core::ICore::dialogParent(),
|
Core::ICore::dialogParent(),
|
||||||
Tr::tr("Re-configure with Initial Parameters"),
|
Tr::tr("Re-configure with Initial Parameters"),
|
||||||
Tr::tr("Clear CMake configuration and configure with initial parameters?"),
|
Tr::tr("Clear CMake configuration and configure with initial parameters?"),
|
||||||
settings().askBeforeReConfigureInitialParams.askAgainCheckableDecider(),
|
settings(m_buildConfig->project()).askBeforeReConfigureInitialParams.askAgainCheckableDecider(),
|
||||||
QMessageBox::Yes | QMessageBox::No,
|
QMessageBox::Yes | QMessageBox::No,
|
||||||
QMessageBox::Yes);
|
QMessageBox::Yes);
|
||||||
|
|
||||||
settings().writeSettings();
|
settings(m_buildConfig->project()).writeSettings();
|
||||||
|
|
||||||
if (reply != QMessageBox::Yes)
|
if (reply != QMessageBox::Yes)
|
||||||
return;
|
return;
|
||||||
@@ -1127,7 +1129,7 @@ static CommandLine defaultInitialCMakeCommand(const Kit *k, const QString &build
|
|||||||
cmd.addArg("-DCMAKE_BUILD_TYPE:STRING=" + buildType);
|
cmd.addArg("-DCMAKE_BUILD_TYPE:STRING=" + buildType);
|
||||||
|
|
||||||
// Package manager auto setup
|
// Package manager auto setup
|
||||||
if (settings().packageManagerAutoSetup()) {
|
if (settings(ProjectTree::currentProject()).packageManagerAutoSetup()) {
|
||||||
cmd.addArg(QString("-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH="
|
cmd.addArg(QString("-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH="
|
||||||
"%{BuildConfig:BuildDirectory:NativeFilePath}/%1/auto-setup.cmake")
|
"%{BuildConfig:BuildDirectory:NativeFilePath}/%1/auto-setup.cmake")
|
||||||
.arg(Constants::PACKAGE_MANAGER_DIR));
|
.arg(Constants::PACKAGE_MANAGER_DIR));
|
||||||
@@ -2038,7 +2040,7 @@ void CMakeBuildConfiguration::addToEnvironment(Utils::Environment &env) const
|
|||||||
if (tool && tool->cmakeExecutable().needsDevice())
|
if (tool && tool->cmakeExecutable().needsDevice())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const FilePath ninja = settings().ninjaPath();
|
const FilePath ninja = settings(nullptr).ninjaPath();
|
||||||
if (!ninja.isEmpty())
|
if (!ninja.isEmpty())
|
||||||
env.appendOrSetPath(ninja.isFile() ? ninja.parentDir() : ninja);
|
env.appendOrSetPath(ninja.isFile() ? ninja.parentDir() : ninja);
|
||||||
}
|
}
|
||||||
|
@@ -436,10 +436,15 @@ CommandLine CMakeBuildStep::cmakeCommand() const
|
|||||||
CommandLine cmd{cmakeExecutable()};
|
CommandLine cmd{cmakeExecutable()};
|
||||||
|
|
||||||
FilePath buildDirectory = ".";
|
FilePath buildDirectory = ".";
|
||||||
if (buildConfiguration())
|
Project *project = nullptr;
|
||||||
|
if (buildConfiguration()) {
|
||||||
buildDirectory = buildConfiguration()->buildDirectory();
|
buildDirectory = buildConfiguration()->buildDirectory();
|
||||||
|
project = buildConfiguration()->project();
|
||||||
|
}
|
||||||
|
|
||||||
cmd.addArgs({"--build", CMakeToolManager::mappedFilePath(buildDirectory).path()});
|
cmd.addArgs(
|
||||||
|
{"--build",
|
||||||
|
CMakeToolManager::mappedFilePath(project, buildDirectory).path()});
|
||||||
|
|
||||||
cmd.addArg("--target");
|
cmd.addArg("--target");
|
||||||
cmd.addArgs(Utils::transform(m_buildTargets, [this](const QString &s) {
|
cmd.addArgs(Utils::transform(m_buildTargets, [this](const QString &s) {
|
||||||
|
@@ -1643,7 +1643,7 @@ void CMakeBuildSystem::wireUpConnections()
|
|||||||
connect(project(), &Project::projectFileIsDirty, this, [this] {
|
connect(project(), &Project::projectFileIsDirty, this, [this] {
|
||||||
const bool isBuilding = BuildManager::isBuilding(project());
|
const bool isBuilding = BuildManager::isBuilding(project());
|
||||||
if (buildConfiguration()->isActive() && !isParsing() && !isBuilding) {
|
if (buildConfiguration()->isActive() && !isParsing() && !isBuilding) {
|
||||||
if (settings().autorunCMake()) {
|
if (settings(project()).autorunCMake()) {
|
||||||
qCDebug(cmakeBuildSystemLog) << "Requesting parse due to dirty project file";
|
qCDebug(cmakeBuildSystemLog) << "Requesting parse due to dirty project file";
|
||||||
reparse(CMakeBuildSystem::REPARSE_FORCE_CMAKE_RUN);
|
reparse(CMakeBuildSystem::REPARSE_FORCE_CMAKE_RUN);
|
||||||
}
|
}
|
||||||
@@ -2300,11 +2300,14 @@ MakeInstallCommand CMakeBuildSystem::makeInstallCommand(const FilePath &installR
|
|||||||
installTarget = "INSTALL";
|
installTarget = "INSTALL";
|
||||||
|
|
||||||
FilePath buildDirectory = ".";
|
FilePath buildDirectory = ".";
|
||||||
if (auto bc = buildConfiguration())
|
Project *project = nullptr;
|
||||||
|
if (auto bc = buildConfiguration()) {
|
||||||
buildDirectory = bc->buildDirectory();
|
buildDirectory = bc->buildDirectory();
|
||||||
|
project = bc->project();
|
||||||
|
}
|
||||||
|
|
||||||
cmd.command.addArg("--build");
|
cmd.command.addArg("--build");
|
||||||
cmd.command.addArg(CMakeToolManager::mappedFilePath(buildDirectory).path());
|
cmd.command.addArg(CMakeToolManager::mappedFilePath(project, buildDirectory).path());
|
||||||
cmd.command.addArg("--target");
|
cmd.command.addArg("--target");
|
||||||
cmd.command.addArg(installTarget);
|
cmd.command.addArg(installTarget);
|
||||||
|
|
||||||
|
@@ -665,7 +665,7 @@ QVariant CMakeGeneratorKitAspectFactory::defaultValue(const Kit *k) const
|
|||||||
});
|
});
|
||||||
if (it != known.constEnd()) {
|
if (it != known.constEnd()) {
|
||||||
const bool hasNinja = [k, tool] {
|
const bool hasNinja = [k, tool] {
|
||||||
if (Internal::settings().ninjaPath().isEmpty()) {
|
if (Internal::settings(nullptr).ninjaPath().isEmpty()) {
|
||||||
auto findNinja = [](const Environment &env) -> bool {
|
auto findNinja = [](const Environment &env) -> bool {
|
||||||
return !env.searchInPath("ninja").isEmpty();
|
return !env.searchInPath("ninja").isEmpty();
|
||||||
};
|
};
|
||||||
|
@@ -103,7 +103,7 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList &
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy the "package-manager" CMake code from the ${IDE:ResourcePath} to the build directory
|
// Copy the "package-manager" CMake code from the ${IDE:ResourcePath} to the build directory
|
||||||
if (settings().packageManagerAutoSetup()) {
|
if (settings(parameters.project).packageManagerAutoSetup()) {
|
||||||
const FilePath localPackageManagerDir = buildDirectory.pathAppended(Constants::PACKAGE_MANAGER_DIR);
|
const FilePath localPackageManagerDir = buildDirectory.pathAppended(Constants::PACKAGE_MANAGER_DIR);
|
||||||
const FilePath idePackageManagerDir = FilePath::fromString(
|
const FilePath idePackageManagerDir = FilePath::fromString(
|
||||||
parameters.expander->expand(QStringLiteral("%{IDE:ResourcePath}/package-manager")));
|
parameters.expander->expand(QStringLiteral("%{IDE:ResourcePath}/package-manager")));
|
||||||
@@ -149,10 +149,11 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList &
|
|||||||
});
|
});
|
||||||
|
|
||||||
CommandLine commandLine(cmakeExecutable);
|
CommandLine commandLine(cmakeExecutable);
|
||||||
commandLine.addArgs({"-S",
|
commandLine.addArgs(
|
||||||
CMakeToolManager::mappedFilePath(sourceDirectory).path(),
|
{"-S",
|
||||||
"-B",
|
CMakeToolManager::mappedFilePath(parameters.project, sourceDirectory).path(),
|
||||||
CMakeToolManager::mappedFilePath(buildDirectory).path()});
|
"-B",
|
||||||
|
CMakeToolManager::mappedFilePath(parameters.project, buildDirectory).path()});
|
||||||
commandLine.addArgs(arguments);
|
commandLine.addArgs(arguments);
|
||||||
|
|
||||||
TaskHub::clearTasks(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
|
TaskHub::clearTasks(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
|
||||||
|
@@ -34,6 +34,7 @@ namespace CMakeProjectManager {
|
|||||||
*/
|
*/
|
||||||
CMakeProject::CMakeProject(const FilePath &fileName)
|
CMakeProject::CMakeProject(const FilePath &fileName)
|
||||||
: Project(Utils::Constants::CMAKE_MIMETYPE, fileName)
|
: Project(Utils::Constants::CMAKE_MIMETYPE, fileName)
|
||||||
|
, m_settings(this, true)
|
||||||
{
|
{
|
||||||
setId(CMakeProjectManager::Constants::CMAKE_PROJECT_ID);
|
setId(CMakeProjectManager::Constants::CMAKE_PROJECT_ID);
|
||||||
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
||||||
@@ -232,6 +233,11 @@ void CMakeProject::setupBuildPresets(Internal::PresetsData &presetsData)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Internal::CMakeSpecificSettings &CMakeProject::settings()
|
||||||
|
{
|
||||||
|
return m_settings;
|
||||||
|
}
|
||||||
|
|
||||||
void CMakeProject::readPresets()
|
void CMakeProject::readPresets()
|
||||||
{
|
{
|
||||||
auto parsePreset = [](const Utils::FilePath &presetFile) -> Internal::PresetsData {
|
auto parsePreset = [](const Utils::FilePath &presetFile) -> Internal::PresetsData {
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cmake_global.h"
|
#include "cmake_global.h"
|
||||||
|
#include "cmakespecificsettings.h"
|
||||||
#include "presetsparser.h"
|
#include "presetsparser.h"
|
||||||
|
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
@@ -34,6 +35,8 @@ public:
|
|||||||
void setOldPresetKits(const QList<ProjectExplorer::Kit *> &presetKits) const;
|
void setOldPresetKits(const QList<ProjectExplorer::Kit *> &presetKits) const;
|
||||||
QList<ProjectExplorer::Kit *> oldPresetKits() const;
|
QList<ProjectExplorer::Kit *> oldPresetKits() const;
|
||||||
|
|
||||||
|
Internal::CMakeSpecificSettings &settings();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool setupTarget(ProjectExplorer::Target *t) final;
|
bool setupTarget(ProjectExplorer::Target *t) final;
|
||||||
|
|
||||||
@@ -50,6 +53,7 @@ private:
|
|||||||
|
|
||||||
ProjectExplorer::Tasks m_issues;
|
ProjectExplorer::Tasks m_issues;
|
||||||
Internal::PresetsData m_presetsData;
|
Internal::PresetsData m_presetsData;
|
||||||
|
Internal::CMakeSpecificSettings m_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CMakeProjectManager
|
} // namespace CMakeProjectManager
|
||||||
|
@@ -41,10 +41,11 @@ const char CMAKE_BUILDCONFIGURATION_ID[] = "CMakeProjectManager.CMakeBuildConfig
|
|||||||
const char M_CONTEXT[] = "CMakeEditor.ContextMenu";
|
const char M_CONTEXT[] = "CMakeEditor.ContextMenu";
|
||||||
|
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
const char GENERAL_ID[] = "CMakeSpecifcSettings";
|
const char GENERAL_ID[] = "CMakeSpecificSettings";
|
||||||
const char TOOLS_ID[] = "K.CMake.Tools";
|
const char TOOLS_ID[] = "K.CMake.Tools";
|
||||||
const char FORMATTER_ID[] = "K.CMake.Formatter";
|
const char FORMATTER_ID[] = "K.CMake.Formatter";
|
||||||
const char CATEGORY[] = "K.CMake";
|
const char CATEGORY[] = "K.CMake";
|
||||||
|
const char USE_GLOBAL_SETTINGS[] = "UseGlobalSettings";
|
||||||
} // namespace Settings
|
} // namespace Settings
|
||||||
|
|
||||||
// Snippets
|
// Snippets
|
||||||
|
@@ -349,12 +349,16 @@ void CMakeManager::enableBuildFileMenus(Node *node)
|
|||||||
|
|
||||||
void CMakeManager::reloadCMakePresets()
|
void CMakeManager::reloadCMakePresets()
|
||||||
{
|
{
|
||||||
|
CMakeProject *project = qobject_cast<CMakeProject *>(ProjectTree::currentProject());
|
||||||
|
if (!project)
|
||||||
|
return;
|
||||||
|
|
||||||
QMessageBox::StandardButton clickedButton = CheckableMessageBox::question(
|
QMessageBox::StandardButton clickedButton = CheckableMessageBox::question(
|
||||||
Core::ICore::dialogParent(),
|
Core::ICore::dialogParent(),
|
||||||
Tr::tr("Reload CMake Presets"),
|
Tr::tr("Reload CMake Presets"),
|
||||||
Tr::tr("Re-generates the kits that were created for CMake presets. All manual "
|
Tr::tr("Re-generates the kits that were created for CMake presets. All manual "
|
||||||
"modifications to the CMake project settings will be lost."),
|
"modifications to the CMake project settings will be lost."),
|
||||||
settings().askBeforePresetsReload.askAgainCheckableDecider(),
|
settings(project).askBeforePresetsReload.askAgainCheckableDecider(),
|
||||||
QMessageBox::Yes | QMessageBox::Cancel,
|
QMessageBox::Yes | QMessageBox::Cancel,
|
||||||
QMessageBox::Yes,
|
QMessageBox::Yes,
|
||||||
QMessageBox::Yes,
|
QMessageBox::Yes,
|
||||||
@@ -362,15 +366,11 @@ void CMakeManager::reloadCMakePresets()
|
|||||||
{QMessageBox::Yes, Tr::tr("Reload")},
|
{QMessageBox::Yes, Tr::tr("Reload")},
|
||||||
});
|
});
|
||||||
|
|
||||||
settings().writeSettings();
|
settings(project).writeSettings();
|
||||||
|
|
||||||
if (clickedButton == QMessageBox::Cancel)
|
if (clickedButton == QMessageBox::Cancel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CMakeProject *project = static_cast<CMakeProject *>(ProjectTree::currentProject());
|
|
||||||
if (!project)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const QSet<QString> oldPresets = Utils::transform<QSet>(project->presetsData().configurePresets,
|
const QSet<QString> oldPresets = Utils::transform<QSet>(project->presetsData().configurePresets,
|
||||||
[](const auto &preset) {
|
[](const auto &preset) {
|
||||||
return preset.name;
|
return preset.name;
|
||||||
|
@@ -1,30 +1,44 @@
|
|||||||
// Copyright (C) 2018 The Qt Company Ltd.
|
// Copyright (C) 2018 The Qt Company Ltd.
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
|
#include "cmakeproject.h"
|
||||||
#include "cmakespecificsettings.h"
|
#include "cmakespecificsettings.h"
|
||||||
|
|
||||||
#include "cmakeprojectconstants.h"
|
#include "cmakeprojectconstants.h"
|
||||||
#include "cmakeprojectmanagertr.h"
|
#include "cmakeprojectmanagertr.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
#include <projectexplorer/projectpanelfactory.h>
|
||||||
|
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/layoutbuilder.h>
|
#include <utils/layoutbuilder.h>
|
||||||
|
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
using namespace ProjectExplorer;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace CMakeProjectManager::Internal {
|
namespace CMakeProjectManager::Internal {
|
||||||
|
|
||||||
CMakeSpecificSettings &settings()
|
CMakeSpecificSettings &settings(Project *project)
|
||||||
{
|
{
|
||||||
static CMakeSpecificSettings theSettings;
|
static CMakeSpecificSettings theSettings(nullptr, false);
|
||||||
return theSettings;
|
if (!project)
|
||||||
|
return theSettings;
|
||||||
|
|
||||||
|
CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(project);
|
||||||
|
if (!cmakeProject || cmakeProject->settings().useGlobalSettings)
|
||||||
|
return theSettings;
|
||||||
|
|
||||||
|
return cmakeProject->settings();
|
||||||
}
|
}
|
||||||
|
|
||||||
CMakeSpecificSettings::CMakeSpecificSettings()
|
CMakeSpecificSettings::CMakeSpecificSettings(Project *p, bool autoApply)
|
||||||
|
: project(p)
|
||||||
{
|
{
|
||||||
setLayouter([this] {
|
setLayouter([this] {
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
@@ -43,8 +57,8 @@ CMakeSpecificSettings::CMakeSpecificSettings()
|
|||||||
// TODO: fixup of QTCREATORBUG-26289 , remove in Qt Creator 7 or so
|
// TODO: fixup of QTCREATORBUG-26289 , remove in Qt Creator 7 or so
|
||||||
Core::ICore::settings()->remove("CMakeSpecificSettings/NinjaPath");
|
Core::ICore::settings()->remove("CMakeSpecificSettings/NinjaPath");
|
||||||
|
|
||||||
setSettingsGroup("CMakeSpecificSettings");
|
setSettingsGroup(Constants::Settings::GENERAL_ID);
|
||||||
setAutoApply(false);
|
setAutoApply(autoApply);
|
||||||
|
|
||||||
autorunCMake.setSettingsKey("AutorunCMake");
|
autorunCMake.setSettingsKey("AutorunCMake");
|
||||||
autorunCMake.setDefaultValue(true);
|
autorunCMake.setDefaultValue(true);
|
||||||
@@ -105,6 +119,36 @@ CMakeSpecificSettings::CMakeSpecificSettings()
|
|||||||
"Junctions are used for CMake configure, build and install operations."));
|
"Junctions are used for CMake configure, build and install operations."));
|
||||||
|
|
||||||
readSettings();
|
readSettings();
|
||||||
|
|
||||||
|
if (project) {
|
||||||
|
// Re-read the settings. Reading in constructor is too early
|
||||||
|
connect(project, &Project::settingsLoaded, this, [this] {
|
||||||
|
readSettings();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMakeSpecificSettings::readSettings()
|
||||||
|
{
|
||||||
|
if (!project) {
|
||||||
|
AspectContainer::readSettings();
|
||||||
|
} else {
|
||||||
|
const Store data = storeFromVariant(project->namedSettings(Constants::Settings::GENERAL_ID));
|
||||||
|
useGlobalSettings = data.value(Constants::Settings::USE_GLOBAL_SETTINGS, true).toBool();
|
||||||
|
fromMap(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMakeSpecificSettings::writeSettings() const
|
||||||
|
{
|
||||||
|
if (!project) {
|
||||||
|
AspectContainer::writeSettings();
|
||||||
|
} else {
|
||||||
|
Store data;
|
||||||
|
toMap(data);
|
||||||
|
data.insert(Constants::Settings::USE_GLOBAL_SETTINGS, useGlobalSettings);
|
||||||
|
project->setNamedSettings(Constants::Settings::GENERAL_ID, variantFromStore(data));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CMakeSpecificSettingsPage final : public Core::IOptionsPage
|
class CMakeSpecificSettingsPage final : public Core::IOptionsPage
|
||||||
@@ -117,10 +161,87 @@ public:
|
|||||||
setDisplayCategory("CMake");
|
setDisplayCategory("CMake");
|
||||||
setCategory(Constants::Settings::CATEGORY);
|
setCategory(Constants::Settings::CATEGORY);
|
||||||
setCategoryIconPath(Constants::Icons::SETTINGS_CATEGORY);
|
setCategoryIconPath(Constants::Icons::SETTINGS_CATEGORY);
|
||||||
setSettingsProvider([] { return &settings(); });
|
setSettingsProvider([] { return &settings(nullptr); });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const CMakeSpecificSettingsPage settingsPage;
|
const CMakeSpecificSettingsPage settingsPage;
|
||||||
|
|
||||||
|
class CMakeProjectSettingsWidget : public ProjectSettingsWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit CMakeProjectSettingsWidget(Project *project)
|
||||||
|
: m_widget(new QWidget)
|
||||||
|
, m_project(qobject_cast<CMakeProject *>(project))
|
||||||
|
, m_displayedSettings(project, true)
|
||||||
|
{
|
||||||
|
setGlobalSettingsId(Constants::Settings::GENERAL_ID);
|
||||||
|
|
||||||
|
// Construct the widget layout from the aspect container
|
||||||
|
const auto layout = new QVBoxLayout(this);
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
if (auto layouter = m_displayedSettings.layouter())
|
||||||
|
layouter().attachTo(m_widget);
|
||||||
|
layout->addWidget(m_widget);
|
||||||
|
|
||||||
|
setUseGlobalSettings(m_displayedSettings.useGlobalSettings);
|
||||||
|
m_widget->setEnabled(!useGlobalSettings());
|
||||||
|
|
||||||
|
if (m_project) {
|
||||||
|
connect(
|
||||||
|
this, &ProjectSettingsWidget::useGlobalSettingsChanged, this, [this](bool useGlobal) {
|
||||||
|
m_widget->setEnabled(!useGlobal);
|
||||||
|
m_displayedSettings.useGlobalSettings = useGlobal;
|
||||||
|
m_displayedSettings.copyFrom(
|
||||||
|
useGlobal ? settings(nullptr) : m_project->settings());
|
||||||
|
|
||||||
|
m_project->settings().useGlobalSettings = useGlobal;
|
||||||
|
m_project->settings().writeSettings();
|
||||||
|
});
|
||||||
|
|
||||||
|
// React on Global settings changes
|
||||||
|
connect(&settings(nullptr), &AspectContainer::changed, this, [this] {
|
||||||
|
if (m_displayedSettings.useGlobalSettings)
|
||||||
|
m_displayedSettings.copyFrom(settings(nullptr));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Reflect changes to the project settings in the displayed settings
|
||||||
|
connect(&m_project->settings(), &AspectContainer::changed, this, [this] {
|
||||||
|
if (!m_displayedSettings.useGlobalSettings)
|
||||||
|
m_displayedSettings.copyFrom(m_project->settings());
|
||||||
|
});
|
||||||
|
|
||||||
|
// React on project settings changes in the "CMake" project settings
|
||||||
|
connect(&m_displayedSettings, &AspectContainer::changed, this, [this] {
|
||||||
|
if (!m_displayedSettings.useGlobalSettings) {
|
||||||
|
m_project->settings().copyFrom(m_displayedSettings);
|
||||||
|
m_project->settings().writeSettings();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Only for CMake projects
|
||||||
|
setUseGlobalSettingsCheckBoxEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *m_widget = nullptr;
|
||||||
|
CMakeProject *m_project = nullptr;
|
||||||
|
CMakeSpecificSettings m_displayedSettings;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CMakeProjectSettingsPanelFactory final : public ProjectPanelFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CMakeProjectSettingsPanelFactory()
|
||||||
|
{
|
||||||
|
setPriority(120);
|
||||||
|
setDisplayName("CMake");
|
||||||
|
setCreateWidgetFunction([](Project *project) {
|
||||||
|
return new CMakeProjectSettingsWidget(project);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const CMakeProjectSettingsPanelFactory projectSettingsPane;
|
||||||
|
|
||||||
} // CMakeProjectManager::Internal
|
} // CMakeProjectManager::Internal
|
||||||
|
@@ -5,12 +5,20 @@
|
|||||||
|
|
||||||
#include <utils/aspects.h>
|
#include <utils/aspects.h>
|
||||||
|
|
||||||
|
namespace ProjectExplorer {
|
||||||
|
class Project;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CMakeProjectManager::Internal {
|
namespace CMakeProjectManager::Internal {
|
||||||
|
|
||||||
class CMakeSpecificSettings final : public Utils::AspectContainer
|
class CMakeSpecificSettings final : public Utils::AspectContainer
|
||||||
{
|
{
|
||||||
|
ProjectExplorer::Project *project{nullptr};
|
||||||
public:
|
public:
|
||||||
CMakeSpecificSettings();
|
CMakeSpecificSettings(ProjectExplorer::Project *project, bool autoApply);
|
||||||
|
|
||||||
|
void readSettings() final;
|
||||||
|
void writeSettings() const final;
|
||||||
|
|
||||||
Utils::BoolAspect autorunCMake{this};
|
Utils::BoolAspect autorunCMake{this};
|
||||||
Utils::FilePathAspect ninjaPath{this};
|
Utils::FilePathAspect ninjaPath{this};
|
||||||
@@ -20,8 +28,10 @@ public:
|
|||||||
Utils::BoolAspect showSourceSubFolders{this};
|
Utils::BoolAspect showSourceSubFolders{this};
|
||||||
Utils::BoolAspect showAdvancedOptionsByDefault{this};
|
Utils::BoolAspect showAdvancedOptionsByDefault{this};
|
||||||
Utils::BoolAspect useJunctionsForSourceAndBuildDirectories{this};
|
Utils::BoolAspect useJunctionsForSourceAndBuildDirectories{this};
|
||||||
|
|
||||||
|
bool useGlobalSettings{true};
|
||||||
};
|
};
|
||||||
|
|
||||||
CMakeSpecificSettings &settings();
|
CMakeSpecificSettings &settings(ProjectExplorer::Project *project);
|
||||||
|
|
||||||
} // CMakeProjectManager::Internal
|
} // CMakeProjectManager::Internal
|
||||||
|
@@ -436,7 +436,7 @@ QString CMakeToolManager::toolTipForRstHelpFile(const FilePath &helpFile)
|
|||||||
return tooltip;
|
return tooltip;
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath CMakeToolManager::mappedFilePath(const FilePath &path)
|
FilePath CMakeToolManager::mappedFilePath(Project *project, const FilePath &path)
|
||||||
{
|
{
|
||||||
if (!HostOsInfo::isWindowsHost())
|
if (!HostOsInfo::isWindowsHost())
|
||||||
return path;
|
return path;
|
||||||
@@ -444,16 +444,14 @@ FilePath CMakeToolManager::mappedFilePath(const FilePath &path)
|
|||||||
if (path.needsDevice())
|
if (path.needsDevice())
|
||||||
return path;
|
return path;
|
||||||
|
|
||||||
auto project = ProjectManager::startupProject();
|
|
||||||
auto environment = Environment::systemEnvironment();
|
auto environment = Environment::systemEnvironment();
|
||||||
if (project)
|
if (project)
|
||||||
environment.modify(project->additionalEnvironment());
|
environment.modify(project->additionalEnvironment());
|
||||||
const bool enableJunctions
|
const bool enableJunctions
|
||||||
= QVariant(
|
= QVariant(environment.value_or(
|
||||||
environment.value_or("QTC_CMAKE_USE_JUNCTIONS",
|
"QTC_CMAKE_USE_JUNCTIONS",
|
||||||
Internal::settings().useJunctionsForSourceAndBuildDirectories()
|
Internal::settings(project).useJunctionsForSourceAndBuildDirectories() ? "1"
|
||||||
? "1"
|
: "0"))
|
||||||
: "0"))
|
|
||||||
.toBool();
|
.toBool();
|
||||||
|
|
||||||
if (!enableJunctions)
|
if (!enableJunctions)
|
||||||
|
@@ -14,6 +14,10 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
namespace ProjectExplorer {
|
||||||
|
class Project;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CMakeProjectManager {
|
namespace CMakeProjectManager {
|
||||||
|
|
||||||
class CMAKE_EXPORT CMakeToolManager : public QObject
|
class CMAKE_EXPORT CMakeToolManager : public QObject
|
||||||
@@ -44,7 +48,7 @@ public:
|
|||||||
|
|
||||||
static QString toolTipForRstHelpFile(const Utils::FilePath &helpFile);
|
static QString toolTipForRstHelpFile(const Utils::FilePath &helpFile);
|
||||||
|
|
||||||
static Utils::FilePath mappedFilePath(const Utils::FilePath &path);
|
static Utils::FilePath mappedFilePath(ProjectExplorer::Project *project, const Utils::FilePath &path);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QList<Utils::Id> autoDetectCMakeForDevice(const Utils::FilePaths &searchPaths,
|
QList<Utils::Id> autoDetectCMakeForDevice(const Utils::FilePaths &searchPaths,
|
||||||
|
@@ -704,7 +704,7 @@ static void addCompileGroups(ProjectNode *targetRoot,
|
|||||||
if (buildDirQmldirOrRcc || otherDirQmldirOrMetatypes || buildDirPluginCpp)
|
if (buildDirQmldirOrRcc || otherDirQmldirOrMetatypes || buildDirPluginCpp)
|
||||||
node->setIsGenerated(true);
|
node->setIsGenerated(true);
|
||||||
|
|
||||||
const bool showSourceFolders = settings().showSourceSubFolders()
|
const bool showSourceFolders = settings(targetRoot->getProject()).showSourceSubFolders()
|
||||||
&& defaultCMakeSourceGroupFolder(td.sourceGroups[si.sourceGroup]);
|
&& defaultCMakeSourceGroupFolder(td.sourceGroups[si.sourceGroup]);
|
||||||
|
|
||||||
// Where does the file node need to go?
|
// Where does the file node need to go?
|
||||||
@@ -718,7 +718,7 @@ static void addCompileGroups(ProjectNode *targetRoot,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < sourceGroupFileNodes.size(); ++i) {
|
for (size_t i = 0; i < sourceGroupFileNodes.size(); ++i) {
|
||||||
const bool showSourceFolders = settings().showSourceSubFolders()
|
const bool showSourceFolders = settings(targetRoot->getProject()).showSourceSubFolders()
|
||||||
&& defaultCMakeSourceGroupFolder(td.sourceGroups[i]);
|
&& defaultCMakeSourceGroupFolder(td.sourceGroups[i]);
|
||||||
|
|
||||||
std::vector<std::unique_ptr<FileNode>> ¤t = sourceGroupFileNodes[i];
|
std::vector<std::unique_ptr<FileNode>> ¤t = sourceGroupFileNodes[i];
|
||||||
|
@@ -130,7 +130,8 @@ void FileApiReader::parse(bool forceCMakeRun,
|
|||||||
// * A query file is newer than the reply file
|
// * A query file is newer than the reply file
|
||||||
const bool hasArguments = !args.isEmpty();
|
const bool hasArguments = !args.isEmpty();
|
||||||
const bool replyFileMissing = !replyFile.exists();
|
const bool replyFileMissing = !replyFile.exists();
|
||||||
const bool cmakeFilesChanged = m_parameters.cmakeTool() && settings().autorunCMake()
|
const bool cmakeFilesChanged = m_parameters.cmakeTool()
|
||||||
|
&& settings(m_parameters.project).autorunCMake()
|
||||||
&& anyOf(m_cmakeFiles, [&replyFile](const CMakeFileInfo &info) {
|
&& anyOf(m_cmakeFiles, [&replyFile](const CMakeFileInfo &info) {
|
||||||
return !info.isGenerated
|
return !info.isGenerated
|
||||||
&& info.path.lastModified() > replyFile.lastModified();
|
&& info.path.lastModified() > replyFile.lastModified();
|
||||||
|
Reference in New Issue
Block a user