MCPcopy Create free account
hub / github.com/Kitware/CMake / PassParsedArguments

Function PassParsedArguments

Source/cmParseArgumentsCommand.cxx:75–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73} // namespace
74
75static void PassParsedArguments(
76 std::string const& prefix, cmMakefile& makefile, options_map const& options,
77 single_map const& singleValArgs, multi_map const& multiValArgs,
78 std::vector<std::string> const& unparsed, options_set const& keywordsSeen,
79 options_set const& keywordsMissingValues, bool parseFromArgV)
80{
81 for (auto const& iter : options) {
82 makefile.AddDefinition(cmStrCat(prefix, iter.first),
83 iter.second ? "TRUE" : "FALSE");
84 }
85
86 cmPolicies::PolicyStatus const cmp0174 =
87 makefile.GetPolicyStatus(cmPolicies::CMP0174);
88 for (auto const& iter : singleValArgs) {
89 if (keywordsSeen.find(iter.first) == keywordsSeen.end()) {
90 makefile.RemoveDefinition(cmStrCat(prefix, iter.first));
91 } else if ((parseFromArgV && cmp0174 == cmPolicies::NEW) ||
92 !iter.second.empty()) {
93 makefile.AddDefinition(cmStrCat(prefix, iter.first), iter.second);
94 } else {
95 // The OLD policy behavior doesn't define a variable for an empty or
96 // missing value, and we can't differentiate between those two cases.
97 if (parseFromArgV && (cmp0174 == cmPolicies::WARN)) {
98 makefile.IssueMessage(
99 MessageType::AUTHOR_WARNING,
100 cmStrCat("The ", iter.first,
101 " keyword was followed by an empty string or no value at "
102 "all. Policy CMP0174 is not set, so "
103 "cmake_parse_arguments() will unset the ",
104 prefix, iter.first,
105 " variable rather than setting it to an empty string."));
106 }
107 makefile.RemoveDefinition(cmStrCat(prefix, iter.first));
108 }
109 }
110
111 for (auto const& iter : multiValArgs) {
112 if (!iter.second.empty()) {
113 makefile.AddDefinition(cmStrCat(prefix, iter.first),
114 JoinList(iter.second, parseFromArgV));
115 } else {
116 makefile.RemoveDefinition(cmStrCat(prefix, iter.first));
117 }
118 }
119
120 if (!unparsed.empty()) {
121 makefile.AddDefinition(cmStrCat(prefix, "UNPARSED_ARGUMENTS"),
122 JoinList(unparsed, parseFromArgV));
123 } else {
124 makefile.RemoveDefinition(cmStrCat(prefix, "UNPARSED_ARGUMENTS"));
125 }
126
127 if (!keywordsMissingValues.empty()) {
128 makefile.AddDefinition(
129 cmStrCat(prefix, "KEYWORDS_MISSING_VALUES"),
130 cmList::to_string(cmMakeRange(keywordsMissingValues)));
131 } else {
132 makefile.RemoveDefinition(cmStrCat(prefix, "KEYWORDS_MISSING_VALUES"));

Callers 1

cmParseArgumentsCommandFunction · 0.85

Calls 11

JoinListFunction · 0.85
to_stringFunction · 0.85
cmMakeRangeFunction · 0.85
cmStrCatFunction · 0.70
AddDefinitionMethod · 0.45
GetPolicyStatusMethod · 0.45
findMethod · 0.45
endMethod · 0.45
RemoveDefinitionMethod · 0.45
emptyMethod · 0.45
IssueMessageMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…