| 245 | } |
| 246 | |
| 247 | static bool HandleExportMode(std::vector<std::string> const& args, |
| 248 | cmExecutionStatus& status) |
| 249 | { |
| 250 | struct ExportArguments : public ArgumentParser::ParseResult |
| 251 | { |
| 252 | ArgumentParser::NonEmpty<std::string> ExportSetName; |
| 253 | ArgumentParser::MaybeEmpty<std::string> Namespace; |
| 254 | ArgumentParser::NonEmpty<std::string> Filename; |
| 255 | ArgumentParser::NonEmpty<std::string> CxxModulesDirectory; |
| 256 | bool ExportPackageDependencies = false; |
| 257 | }; |
| 258 | |
| 259 | auto parser = |
| 260 | cmArgumentParser<ExportArguments>{} |
| 261 | .Bind("EXPORT"_s, &ExportArguments::ExportSetName) |
| 262 | .Bind("NAMESPACE"_s, &ExportArguments::Namespace) |
| 263 | .Bind("FILE"_s, &ExportArguments::Filename) |
| 264 | .Bind("CXX_MODULES_DIRECTORY"_s, &ExportArguments::CxxModulesDirectory); |
| 265 | |
| 266 | if (cmExperimental::HasSupportEnabled( |
| 267 | status.GetMakefile(), |
| 268 | cmExperimental::Feature::ExportPackageDependencies)) { |
| 269 | parser.Bind("EXPORT_PACKAGE_DEPENDENCIES"_s, |
| 270 | &ExportArguments::ExportPackageDependencies); |
| 271 | } |
| 272 | |
| 273 | std::vector<std::string> unknownArgs; |
| 274 | ExportArguments arguments = parser.Parse(args, &unknownArgs); |
| 275 | |
| 276 | cmMakefile& mf = status.GetMakefile(); |
| 277 | cmGlobalGenerator* gg = mf.GetGlobalGenerator(); |
| 278 | |
| 279 | if (!arguments.Check(args[0], &unknownArgs, status)) { |
| 280 | cmPolicies::PolicyStatus const p = |
| 281 | status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0208); |
| 282 | if (!unknownArgs.empty() || p == cmPolicies::NEW) { |
| 283 | return false; |
| 284 | } |
| 285 | if (p == cmPolicies::WARN) { |
| 286 | status.GetMakefile().IssueMessage( |
| 287 | MessageType::AUTHOR_WARNING, cmStrCat("export "_s, status.GetError())); |
| 288 | status.GetMakefile().IssueMessage( |
| 289 | MessageType::AUTHOR_WARNING, |
| 290 | cmPolicies::GetPolicyWarning(cmPolicies::CMP0208)); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | std::string fname; |
| 295 | if (arguments.Filename.empty()) { |
| 296 | fname = arguments.ExportSetName + ".cmake"; |
| 297 | } else { |
| 298 | if (!cmHasSuffix(arguments.Filename, ".cmake"_s)) { |
| 299 | std::ostringstream e; |
| 300 | e << "FILE option given filename \"" << arguments.Filename |
| 301 | << "\" which does not have an extension of \".cmake\".\n"; |
| 302 | status.SetError(e.str()); |
| 303 | return false; |
| 304 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…