diff options
author | Alex Reinking <alex.reinking@gmail.com> | 2022-08-14 08:42:11 (GMT) |
---|---|---|
committer | Alex Reinking <alex.reinking@gmail.com> | 2022-08-17 16:54:39 (GMT) |
commit | c9d70a7cc32bd023c92fd9eac19cb907b86ada8f (patch) | |
tree | 551a9588a3f1daaefc62134d892fa30ca4c1560e /Source/cmSystemTools.cxx | |
parent | 5b949bbb9114379120c29134b5effd77e39dd134 (diff) | |
download | CMake-c9d70a7cc32bd023c92fd9eac19cb907b86ada8f.zip CMake-c9d70a7cc32bd023c92fd9eac19cb907b86ada8f.tar.gz CMake-c9d70a7cc32bd023c92fd9eac19cb907b86ada8f.tar.bz2 |
cmake -E env: Add --modify flag
When `cmake -E env` is given the `--modify` flag, try to parse the
following argument as an `ENVIRONMENT_MODIFICATION` operation and apply
it to the environment.
This generalizes `--unset=`:
1. When implementing `ENVIRONMENT_MODIFICATION` features for other CMake
commands, the `MYVAR=OP:VALUE` strings do not need to be translated
to OP-specific flags.
2. This provides a natural and consistent extension point to introduce
new operations without introducing very many flags.
3. Users need to learn only one syntax to access the same functionality.
There is one difference between the behavior here as compared to CTest's
interpretation of the `ENVIRONMENT_MODIFICATION` test property.
The `MYVAR=reset:` command when run in `cmake -E env` will reset `MYVAR`
to whatever its value was when `cmake -E env` launched, rather than try
to checkpoint after plain `MYVAR=VALUE` options. This makes `MYVAR=VALUE`
and `--modify MYVAR=set:VALUE` semantically equivalent.
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 2c32f09..3c4e709 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1578,10 +1578,15 @@ void cmSystemTools::EnvDiff::PutEnv(const std::string& env) std::string name = env.substr(0, eq_loc); diff[name] = env.substr(eq_loc + 1); } else { - diff[env] = {}; + this->UnPutEnv(env); } } +void cmSystemTools::EnvDiff::UnPutEnv(const std::string& env) +{ + diff[env] = {}; +} + bool cmSystemTools::EnvDiff::ParseOperation(const std::string& envmod) { char path_sep = GetSystemPathlistSeparator(); |