diff --git a/dist/changelog/changes-13.0.2.md b/dist/changelog/changes-13.0.2.md index 3e1b67b3784..629efc3d1b0 100644 --- a/dist/changelog/changes-13.0.2.md +++ b/dist/changelog/changes-13.0.2.md @@ -28,9 +28,17 @@ Editing * Fixed that `Use Qt module name in #include-directive` used Qt 4 module names ([QTCREATORBUG-30751](https://bugreports.qt.io/browse/QTCREATORBUG-30751)) +### Copilot + +* Adapted to changes in the Copilot neovim plugin + Projects -------- +### CMake + +* Fixed the environment macro expansion for Presets + ### Meson * Fixed a crash when selecting kits diff --git a/src/plugins/cmakeprojectmanager/presetsmacros.cpp b/src/plugins/cmakeprojectmanager/presetsmacros.cpp index b7496d0c412..cfc161b417e 100644 --- a/src/plugins/cmakeprojectmanager/presetsmacros.cpp +++ b/src/plugins/cmakeprojectmanager/presetsmacros.cpp @@ -139,11 +139,13 @@ void expand(const PresetType &preset, Environment &env, const FilePath &sourceDi return presetEnv.value(macroName); }); - bool append = true; + enum Operation { set, appendOrSet, prependOrSet }; + Operation op = set; if (key.compare("PATH", Qt::CaseInsensitive) == 0) { + op = appendOrSet; const int index = value.indexOf("$penv{PATH}", 0, Qt::CaseInsensitive); if (index != 0) - append = false; + op = prependOrSet; value.replace("$penv{PATH}", "", Qt::CaseInsensitive); } @@ -154,10 +156,17 @@ void expand(const PresetType &preset, Environment &env, const FilePath &sourceDi // Make sure to expand the CMake macros also for environment variables expandAllButEnv(preset, sourceDirectory, value); - if (append) + switch (op) { + case set: + env.set(key, value); + break; + case appendOrSet: env.appendOrSet(key, value); - else + break; + case prependOrSet: env.prependOrSet(key, value); + break; + } }); }