| 88 | } |
| 89 | |
| 90 | static bool HandleTargetsMode(std::vector<std::string> const& args, |
| 91 | cmExecutionStatus& status) |
| 92 | { |
| 93 | struct Arguments |
| 94 | { |
| 95 | cm::optional<ArgumentParser::MaybeEmpty<std::vector<std::string>>> Targets; |
| 96 | ArgumentParser::NonEmpty<std::string> ExportSetName; |
| 97 | ArgumentParser::NonEmpty<std::string> Namespace; |
| 98 | ArgumentParser::NonEmpty<std::string> Filename; |
| 99 | ArgumentParser::NonEmpty<std::string> CxxModulesDirectory; |
| 100 | ArgumentParser::NonEmpty<std::string> AndroidMKFile; |
| 101 | |
| 102 | bool Append = false; |
| 103 | bool ExportOld = false; |
| 104 | }; |
| 105 | |
| 106 | auto parser = |
| 107 | cmArgumentParser<Arguments>{} |
| 108 | .Bind("NAMESPACE"_s, &Arguments::Namespace) |
| 109 | .Bind("FILE"_s, &Arguments::Filename) |
| 110 | .Bind("CXX_MODULES_DIRECTORY"_s, &Arguments::CxxModulesDirectory) |
| 111 | .Bind("TARGETS"_s, &Arguments::Targets) |
| 112 | .Bind("APPEND"_s, &Arguments::Append) |
| 113 | .Bind("ANDROID_MK"_s, &Arguments::AndroidMKFile) |
| 114 | .Bind("EXPORT_LINK_INTERFACE_LIBRARIES"_s, &Arguments::ExportOld); |
| 115 | |
| 116 | std::vector<std::string> unknownArgs; |
| 117 | Arguments arguments = parser.Parse(args, &unknownArgs); |
| 118 | |
| 119 | if (!unknownArgs.empty()) { |
| 120 | status.SetError( |
| 121 | cmStrCat("Unknown argument: \"", unknownArgs.front(), "\".")); |
| 122 | return false; |
| 123 | } |
| 124 | |
| 125 | std::string fname; |
| 126 | bool android = false; |
| 127 | if (!arguments.AndroidMKFile.empty()) { |
| 128 | fname = arguments.AndroidMKFile; |
| 129 | android = true; |
| 130 | } else if (arguments.Filename.empty()) { |
| 131 | fname = arguments.ExportSetName + ".cmake"; |
| 132 | } else { |
| 133 | // Make sure the file has a .cmake extension. |
| 134 | if (!cmHasSuffix(arguments.Filename, ".cmake"_s)) { |
| 135 | std::ostringstream e; |
| 136 | e << "FILE option given filename \"" << arguments.Filename |
| 137 | << "\" which does not have an extension of \".cmake\".\n"; |
| 138 | status.SetError(e.str()); |
| 139 | return false; |
| 140 | } |
| 141 | fname = arguments.Filename; |
| 142 | } |
| 143 | |
| 144 | cmMakefile& mf = status.GetMakefile(); |
| 145 | |
| 146 | // Get the file to write. |
| 147 | if (cmSystemTools::FileIsFullPath(fname)) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…