cmIncludeGuardCommand
| 47 | |
| 48 | // cmIncludeGuardCommand |
| 49 | bool cmIncludeGuardCommand(std::vector<std::string> const& args, |
| 50 | cmExecutionStatus& status) |
| 51 | { |
| 52 | if (args.size() > 1) { |
| 53 | status.SetError( |
| 54 | "given an invalid number of arguments. The command takes at " |
| 55 | "most 1 argument."); |
| 56 | return false; |
| 57 | } |
| 58 | |
| 59 | IncludeGuardScope scope = VARIABLE; |
| 60 | |
| 61 | if (!args.empty()) { |
| 62 | std::string const& arg = args[0]; |
| 63 | if (arg == "DIRECTORY") { |
| 64 | scope = DIRECTORY; |
| 65 | } else if (arg == "GLOBAL") { |
| 66 | scope = GLOBAL; |
| 67 | } else { |
| 68 | status.SetError("given an invalid scope: " + arg); |
| 69 | return false; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | std::string includeGuardVar = GetIncludeGuardVariableName( |
| 74 | *status.GetMakefile().GetDefinition("CMAKE_CURRENT_LIST_FILE")); |
| 75 | |
| 76 | cmMakefile* const mf = &status.GetMakefile(); |
| 77 | |
| 78 | switch (scope) { |
| 79 | case VARIABLE: |
| 80 | if (mf->IsDefinitionSet(includeGuardVar)) { |
| 81 | status.SetReturnInvoked(); |
| 82 | return true; |
| 83 | } |
| 84 | mf->AddDefinitionBool(includeGuardVar, true); |
| 85 | break; |
| 86 | case DIRECTORY: |
| 87 | if (CheckIncludeGuardIsSet(mf, includeGuardVar)) { |
| 88 | status.SetReturnInvoked(); |
| 89 | return true; |
| 90 | } |
| 91 | mf->SetProperty(includeGuardVar, "TRUE"); |
| 92 | break; |
| 93 | case GLOBAL: |
| 94 | cmake* const cm = mf->GetCMakeInstance(); |
| 95 | if (cm->GetProperty(includeGuardVar)) { |
| 96 | status.SetReturnInvoked(); |
| 97 | return true; |
| 98 | } |
| 99 | cm->SetProperty(includeGuardVar, "TRUE"); |
| 100 | break; |
| 101 | } |
| 102 | |
| 103 | return true; |
| 104 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…