forked from qt-creator/qt-creator
CMakePM: Fix Presets macro expanding of environment
Amends a25bbf23c6
The commit broke evironment variable usage in CMake presets. For example
"$env{HOME}" would have been expanded to "/home/user:/home/user" because
of code thinking it deals with paths.
Change-Id: I3ef34179e2ebaf55b25a42dcce87438c1a72b73e
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user