cmUnsetCommand
| 9 | |
| 10 | // cmUnsetCommand |
| 11 | bool cmUnsetCommand(std::vector<std::string> const& args, |
| 12 | cmExecutionStatus& status) |
| 13 | { |
| 14 | if (args.empty() || args.size() > 2) { |
| 15 | status.SetError("called with incorrect number of arguments"); |
| 16 | return false; |
| 17 | } |
| 18 | |
| 19 | auto const& variable = args[0]; |
| 20 | |
| 21 | // unset(ENV{VAR}) |
| 22 | if (cmHasLiteralPrefix(variable, "ENV{") && variable.size() > 5) { |
| 23 | // what is the variable name |
| 24 | auto const& envVarName = variable.substr(4, variable.size() - 5); |
| 25 | |
| 26 | #ifndef CMAKE_BOOTSTRAP |
| 27 | cmSystemTools::UnsetEnv(envVarName.c_str()); |
| 28 | #endif |
| 29 | return true; |
| 30 | } |
| 31 | // unset(CACHE{VAR}) |
| 32 | if (cmHasLiteralPrefix(variable, "CACHE{") && variable.size() > 7 && |
| 33 | cmHasSuffix(variable, '}')) { |
| 34 | // get the variable name |
| 35 | auto const& varName = variable.substr(6, variable.size() - 7); |
| 36 | status.GetMakefile().RemoveCacheDefinition(varName); |
| 37 | return true; |
| 38 | } |
| 39 | // unset(VAR) |
| 40 | if (args.size() == 1) { |
| 41 | status.GetMakefile().RemoveDefinition(variable); |
| 42 | return true; |
| 43 | } |
| 44 | // unset(VAR CACHE) |
| 45 | if ((args.size() == 2) && (args[1] == "CACHE")) { |
| 46 | status.GetMakefile().RemoveCacheDefinition(variable); |
| 47 | return true; |
| 48 | } |
| 49 | // unset(VAR PARENT_SCOPE) |
| 50 | if ((args.size() == 2) && (args[1] == "PARENT_SCOPE")) { |
| 51 | status.GetMakefile().RaiseScope(variable, nullptr); |
| 52 | return true; |
| 53 | } |
| 54 | // ERROR: second argument isn't CACHE or PARENT_SCOPE |
| 55 | status.SetError("called with an invalid second argument"); |
| 56 | return false; |
| 57 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…