diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp index b5adf4bc09d..4b6ab55d4df 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp @@ -1621,10 +1621,24 @@ bool CMakeBuildConfiguration::fromMap(const QVariantMap &map) m_buildSystem->setInitialCMakeArguments(cmd.splitArguments()); } - d->m_clearSystemConfigureEnvironment = map.value(QLatin1String(CLEAR_SYSTEM_ENVIRONMENT_KEY)) - .toBool(); + // Upgrading from Qt Creator version <9 to 9, if the build environment is set + // apply the specific values to the configure environment + auto settingsKey = [map](const QLatin1String &configureKey, const QLatin1String &buildKey) { + if (!map.contains(configureKey) && map.contains(buildKey)) + return buildKey; + return configureKey; + }; + + const QLatin1String clearSystemEnvironmentKey + = settingsKey(QLatin1String(CLEAR_SYSTEM_ENVIRONMENT_KEY), + QLatin1String(ProjectExplorer::Constants::CLEAR_SYSTEM_ENVIRONMENT_KEY)); + const QLatin1String userEnvironmentChangesKey + = settingsKey(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY), + QLatin1String(ProjectExplorer::Constants::USER_ENVIRONMENT_CHANGES_KEY)); + + d->m_clearSystemConfigureEnvironment = map.value(clearSystemEnvironmentKey).toBool(); d->m_userConfigureEnvironmentChanges = EnvironmentItem::fromStringList( - map.value(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY)).toStringList()); + map.value(userEnvironmentChangesKey).toStringList()); updateAndEmitConfigureEnvironmentChanged(); diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp index b858fdb4d46..a812eb13b2d 100644 --- a/src/plugins/projectexplorer/buildconfiguration.cpp +++ b/src/plugins/projectexplorer/buildconfiguration.cpp @@ -46,8 +46,6 @@ using namespace Utils; const char BUILD_STEP_LIST_COUNT[] = "ProjectExplorer.BuildConfiguration.BuildStepListCount"; const char BUILD_STEP_LIST_PREFIX[] = "ProjectExplorer.BuildConfiguration.BuildStepList."; -const char CLEAR_SYSTEM_ENVIRONMENT_KEY[] = "ProjectExplorer.BuildConfiguration.ClearSystemEnvironment"; -const char USER_ENVIRONMENT_CHANGES_KEY[] = "ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"; const char CUSTOM_PARSERS_KEY[] = "ProjectExplorer.BuildConfiguration.CustomParsers"; const char PARSE_STD_OUT_KEY[] = "ProjectExplorer.BuildConfiguration.ParseStandardOutput"; @@ -378,8 +376,9 @@ QVariantMap BuildConfiguration::toMap() const { QVariantMap map = ProjectConfiguration::toMap(); - map.insert(QLatin1String(CLEAR_SYSTEM_ENVIRONMENT_KEY), d->m_clearSystemEnvironment); - map.insert(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY), EnvironmentItem::toStringList(d->m_userEnvironmentChanges)); + map.insert(QLatin1String(Constants::CLEAR_SYSTEM_ENVIRONMENT_KEY), d->m_clearSystemEnvironment); + map.insert(QLatin1String(Constants::USER_ENVIRONMENT_CHANGES_KEY), + EnvironmentItem::toStringList(d->m_userEnvironmentChanges)); map.insert(QLatin1String(BUILD_STEP_LIST_COUNT), 2); map.insert(QLatin1String(BUILD_STEP_LIST_PREFIX) + QString::number(0), d->m_buildSteps.toMap()); @@ -393,8 +392,10 @@ QVariantMap BuildConfiguration::toMap() const bool BuildConfiguration::fromMap(const QVariantMap &map) { - d->m_clearSystemEnvironment = map.value(QLatin1String(CLEAR_SYSTEM_ENVIRONMENT_KEY)).toBool(); - d->m_userEnvironmentChanges = EnvironmentItem::fromStringList(map.value(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY)).toStringList()); + d->m_clearSystemEnvironment = map.value(QLatin1String(Constants::CLEAR_SYSTEM_ENVIRONMENT_KEY)) + .toBool(); + d->m_userEnvironmentChanges = EnvironmentItem::fromStringList( + map.value(QLatin1String(Constants::USER_ENVIRONMENT_CHANGES_KEY)).toStringList()); updateCacheAndEmitEnvironmentChanged(); diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h index ccdb0d44d3a..2ff240b4a3f 100644 --- a/src/plugins/projectexplorer/projectexplorerconstants.h +++ b/src/plugins/projectexplorer/projectexplorerconstants.h @@ -219,6 +219,8 @@ const char SETTINGS_MENU_HIDE_BUILD[] = "Menu/HideBuild"; const char SETTINGS_MENU_HIDE_DEBUG[] = "Menu/HideDebug"; const char SETTINGS_MENU_HIDE_ANALYZE[] = "Menu/HideAnalyze"; const char SESSION_TASKFILE_KEY[] = "TaskList.File"; +const char CLEAR_SYSTEM_ENVIRONMENT_KEY[] = "ProjectExplorer.BuildConfiguration.ClearSystemEnvironment"; +const char USER_ENVIRONMENT_CHANGES_KEY[] = "ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"; // UI texts PROJECTEXPLORER_EXPORT QString msgAutoDetected();