From 1c51dc1adf18999be790ae0788b4309886a55997 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Tue, 18 Oct 2022 18:23:50 +0200 Subject: [PATCH] CMakePM: Do not use systemEnvironment() for CMakePresets This doesn't mean that CMakePresets will work with a remote project, but at least it avoids Environment::systemEnvironment() usage. Change-Id: I17081c747d32e50224ac74507d3aa336ff5c8948 Reviewed-by: Reviewed-by: hjk --- .../cmakeprojectmanager/cmakeprojectimporter.cpp | 10 +++++----- src/plugins/cmakeprojectmanager/presetsmacros.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp index 60c11157239..a64ad830d63 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp @@ -135,7 +135,7 @@ FilePaths CMakeProjectImporter::importCandidates() // If the binaryFilePath exists, do not try to import the existing build, so that // we don't have duplicates, one from the preset and one from the previous configuration. if (configPreset.binaryDir) { - Environment env = Environment::systemEnvironment(); + Environment env = projectDirectory().deviceEnvironment(); CMakePresets::Macros::expand(configPreset, env, projectDirectory()); QString binaryDir = configPreset.binaryDir.value(); @@ -165,15 +165,15 @@ static CMakeConfig configurationFromPresetProbe( cmake.setTimeoutS(30); cmake.setDisableUnixTerminal(); - Environment env = Environment::systemEnvironment(); + const FilePath cmakeExecutable = FilePath::fromString(configurePreset.cmakeExecutable.value()); + + Environment env = cmakeExecutable.deviceEnvironment(); CMakePresets::Macros::expand(configurePreset, env, importPath); env.setupEnglishOutput(); cmake.setEnvironment(env); cmake.setTimeOutMessageBoxEnabled(false); - const FilePath cmakeExecutable = FilePath::fromString(configurePreset.cmakeExecutable.value()); - QStringList args; args.emplace_back("-S"); args.emplace_back(importPath.path()); @@ -428,7 +428,7 @@ QList CMakeProjectImporter::examineDirectory(const FilePath &importPath, return preset.name == presetName; }); - Environment env = Environment::systemEnvironment(); + Environment env = projectDirectory().deviceEnvironment(); CMakePresets::Macros::expand(configurePreset, env, projectDirectory()); if (configurePreset.displayName) diff --git a/src/plugins/cmakeprojectmanager/presetsmacros.cpp b/src/plugins/cmakeprojectmanager/presetsmacros.cpp index 37896bfb700..1220444cbfb 100644 --- a/src/plugins/cmakeprojectmanager/presetsmacros.cpp +++ b/src/plugins/cmakeprojectmanager/presetsmacros.cpp @@ -280,7 +280,7 @@ bool evaluatePresetCondition(const PresetType &preset, const Utils::FilePath &so if (!preset.condition) return true; - Utils::Environment env = Utils::Environment::systemEnvironment(); + Utils::Environment env = sourceDirectory.deviceEnvironment(); expand(preset, env, sourceDirectory); PresetsDetails::Condition condition = preset.condition.value();