| 73 | } // namespace |
| 74 | |
| 75 | static 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")); |
no test coverage detected
searching dependent graphs…