2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2018 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2018-03-10 18:45:06 +01:00
|
|
|
|
2022-07-08 17:07:33 +02:00
|
|
|
#include "cmakespecificsettings.h"
|
2018-03-10 18:45:06 +01:00
|
|
|
|
2022-09-29 15:26:31 +02:00
|
|
|
#include "cmakeprojectconstants.h"
|
|
|
|
|
#include "cmakeprojectmanagertr.h"
|
|
|
|
|
|
2021-09-22 15:57:27 +02:00
|
|
|
#include <coreplugin/icore.h>
|
2023-07-06 17:06:20 +02:00
|
|
|
#include <coreplugin/dialogs/ioptionspage.h>
|
|
|
|
|
|
2021-03-23 15:58:16 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
|
|
2024-01-31 09:49:56 +01:00
|
|
|
#include <utils/hostosinfo.h>
|
2021-03-23 15:58:16 +01:00
|
|
|
#include <utils/layoutbuilder.h>
|
|
|
|
|
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
2022-09-29 15:26:31 +02:00
|
|
|
namespace CMakeProjectManager::Internal {
|
2018-03-10 18:45:06 +01:00
|
|
|
|
2023-07-06 17:06:20 +02:00
|
|
|
CMakeSpecificSettings &settings()
|
2023-05-10 13:51:34 +02:00
|
|
|
{
|
2023-07-06 17:06:20 +02:00
|
|
|
static CMakeSpecificSettings theSettings;
|
2023-05-10 13:51:34 +02:00
|
|
|
return theSettings;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-23 15:58:16 +01:00
|
|
|
CMakeSpecificSettings::CMakeSpecificSettings()
|
|
|
|
|
{
|
2023-05-17 17:18:11 +02:00
|
|
|
setLayouter([this] {
|
2023-05-10 13:51:34 +02:00
|
|
|
using namespace Layouting;
|
2023-05-17 17:18:11 +02:00
|
|
|
return Column {
|
2023-05-10 13:51:34 +02:00
|
|
|
autorunCMake,
|
|
|
|
|
packageManagerAutoSetup,
|
|
|
|
|
askBeforeReConfigureInitialParams,
|
2023-05-09 18:22:47 +02:00
|
|
|
askBeforePresetsReload,
|
2023-05-10 13:51:34 +02:00
|
|
|
showSourceSubFolders,
|
|
|
|
|
showAdvancedOptionsByDefault,
|
2024-01-31 09:49:56 +01:00
|
|
|
useJunctionsForSourceAndBuildDirectories,
|
2023-05-10 13:51:34 +02:00
|
|
|
st
|
2023-05-17 17:18:11 +02:00
|
|
|
};
|
2023-05-10 13:51:34 +02:00
|
|
|
});
|
|
|
|
|
|
2021-09-22 15:57:27 +02:00
|
|
|
// TODO: fixup of QTCREATORBUG-26289 , remove in Qt Creator 7 or so
|
|
|
|
|
Core::ICore::settings()->remove("CMakeSpecificSettings/NinjaPath");
|
|
|
|
|
|
2021-03-23 15:58:16 +01:00
|
|
|
setSettingsGroup("CMakeSpecificSettings");
|
|
|
|
|
setAutoApply(false);
|
|
|
|
|
|
2022-12-12 20:02:01 +01:00
|
|
|
autorunCMake.setSettingsKey("AutorunCMake");
|
|
|
|
|
autorunCMake.setDefaultValue(true);
|
|
|
|
|
autorunCMake.setLabelText(::CMakeProjectManager::Tr::tr("Autorun CMake"));
|
|
|
|
|
autorunCMake.setToolTip(::CMakeProjectManager::Tr::tr(
|
|
|
|
|
"Automatically run CMake after changes to CMake project files."));
|
|
|
|
|
|
2021-03-26 16:54:40 +01:00
|
|
|
ninjaPath.setSettingsKey("NinjaPath");
|
2021-09-22 15:57:27 +02:00
|
|
|
// never save this to the settings:
|
|
|
|
|
ninjaPath.setToSettingsTransformation(
|
|
|
|
|
[](const QVariant &) { return QVariant::fromValue(QString()); });
|
2023-08-03 16:10:16 +02:00
|
|
|
ninjaPath.setFromSettingsTransformation([](const QVariant &from) {
|
|
|
|
|
// Sometimes the installer appends the same ninja path to the qtcreator.ini file
|
|
|
|
|
const QString path = from.canConvert<QStringList>() ? from.toStringList().last()
|
|
|
|
|
: from.toString();
|
|
|
|
|
return FilePath::fromUserInput(path).toVariant();
|
|
|
|
|
});
|
2021-03-23 15:58:16 +01:00
|
|
|
|
2021-03-26 16:54:40 +01:00
|
|
|
packageManagerAutoSetup.setSettingsKey("PackageManagerAutoSetup");
|
2023-02-07 18:15:58 +01:00
|
|
|
packageManagerAutoSetup.setDefaultValue(true);
|
2022-09-29 15:26:31 +02:00
|
|
|
packageManagerAutoSetup.setLabelText(::CMakeProjectManager::Tr::tr("Package manager auto setup"));
|
|
|
|
|
packageManagerAutoSetup.setToolTip(::CMakeProjectManager::Tr::tr("Add the CMAKE_PROJECT_INCLUDE_BEFORE variable "
|
2021-03-23 15:58:16 +01:00
|
|
|
"pointing to a CMake script that will install dependencies from the conanfile.txt, "
|
|
|
|
|
"conanfile.py, or vcpkg.json file from the project source directory."));
|
|
|
|
|
|
2021-03-26 16:54:40 +01:00
|
|
|
askBeforeReConfigureInitialParams.setSettingsKey("AskReConfigureInitialParams");
|
|
|
|
|
askBeforeReConfigureInitialParams.setDefaultValue(true);
|
2022-09-29 15:26:31 +02:00
|
|
|
askBeforeReConfigureInitialParams.setLabelText(::CMakeProjectManager::Tr::tr("Ask before re-configuring with "
|
2021-03-23 15:58:16 +01:00
|
|
|
"initial parameters"));
|
2022-07-04 08:54:24 +02:00
|
|
|
|
2023-05-09 18:22:47 +02:00
|
|
|
askBeforePresetsReload.setSettingsKey("AskBeforePresetsReload");
|
|
|
|
|
askBeforePresetsReload.setDefaultValue(true);
|
|
|
|
|
askBeforePresetsReload.setLabelText(::CMakeProjectManager::Tr::tr("Ask before reloading CMake Presets"));
|
|
|
|
|
|
2022-07-04 08:54:24 +02:00
|
|
|
showSourceSubFolders.setSettingsKey("ShowSourceSubFolders");
|
|
|
|
|
showSourceSubFolders.setDefaultValue(true);
|
2022-09-29 15:26:31 +02:00
|
|
|
showSourceSubFolders.setLabelText(
|
|
|
|
|
::CMakeProjectManager::Tr::tr("Show subfolders inside source group folders"));
|
2022-11-30 01:10:44 +03:00
|
|
|
|
|
|
|
|
showAdvancedOptionsByDefault.setSettingsKey("ShowAdvancedOptionsByDefault");
|
|
|
|
|
showAdvancedOptionsByDefault.setDefaultValue(false);
|
|
|
|
|
showAdvancedOptionsByDefault.setLabelText(
|
|
|
|
|
::CMakeProjectManager::Tr::tr("Show advanced options by default"));
|
2021-03-26 16:54:40 +01:00
|
|
|
|
2024-01-31 09:49:56 +01:00
|
|
|
useJunctionsForSourceAndBuildDirectories.setSettingsKey(
|
|
|
|
|
"UseJunctionsForSourceAndBuildDirectories");
|
|
|
|
|
useJunctionsForSourceAndBuildDirectories.setDefaultValue(false);
|
|
|
|
|
useJunctionsForSourceAndBuildDirectories.setLabelText(::CMakeProjectManager::Tr::tr(
|
2024-02-26 13:35:24 +01:00
|
|
|
"Use junctions for CMake configuration and build operations"));
|
2024-01-31 09:49:56 +01:00
|
|
|
useJunctionsForSourceAndBuildDirectories.setVisible(Utils::HostOsInfo().isWindowsHost());
|
|
|
|
|
useJunctionsForSourceAndBuildDirectories.setToolTip(::CMakeProjectManager::Tr::tr(
|
2024-02-26 13:35:24 +01:00
|
|
|
"Create and use junctions for the source and build directories to overcome "
|
2024-01-31 09:49:56 +01:00
|
|
|
"issues with long paths on Windows.<br><br>"
|
2024-02-26 13:35:24 +01:00
|
|
|
"Junctions are stored under <tt>C:\\ProgramData\\QtCreator\\Links</tt> (overridable via "
|
|
|
|
|
"the <tt>QTC_CMAKE_JUNCTIONS_DIR</tt> environment variable).<br><br>"
|
|
|
|
|
"With <tt>QTC_CMAKE_JUNCTIONS_HASH_LENGTH</tt>, you can shorten the MD5 hash key length "
|
2024-01-31 09:49:56 +01:00
|
|
|
"to a value smaller than the default length value of 32.<br><br>"
|
2024-02-26 13:35:24 +01:00
|
|
|
"Junctions are used for CMake configure, build and install operations."));
|
2024-01-31 09:49:56 +01:00
|
|
|
|
2023-05-16 13:06:18 +02:00
|
|
|
readSettings();
|
2018-03-10 18:45:06 +01:00
|
|
|
}
|
2021-03-23 15:58:16 +01:00
|
|
|
|
2023-07-06 17:06:20 +02:00
|
|
|
class CMakeSpecificSettingsPage final : public Core::IOptionsPage
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
CMakeSpecificSettingsPage()
|
|
|
|
|
{
|
|
|
|
|
setId(Constants::Settings::GENERAL_ID);
|
|
|
|
|
setDisplayName(::CMakeProjectManager::Tr::tr("General"));
|
|
|
|
|
setDisplayCategory("CMake");
|
|
|
|
|
setCategory(Constants::Settings::CATEGORY);
|
|
|
|
|
setCategoryIconPath(Constants::Icons::SETTINGS_CATEGORY);
|
|
|
|
|
setSettingsProvider([] { return &settings(); });
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const CMakeSpecificSettingsPage settingsPage;
|
|
|
|
|
|
2022-09-29 15:26:31 +02:00
|
|
|
} // CMakeProjectManager::Internal
|