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

Function HandleSpecialExportMode

Source/cmExportCommand.cxx:339–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

337
338template <typename ArgumentsType, typename GeneratorType>
339static bool HandleSpecialExportMode(std::vector<std::string> const& args,
340 cmExecutionStatus& status)
341{
342 struct ExportArguments
343 : public ArgumentsType
344 , public ArgumentParser::ParseResult
345 {
346 ArgumentParser::NonEmpty<std::string> ExportSetName;
347 ArgumentParser::NonEmpty<std::string> CxxModulesDirectory;
348
349 using ArgumentsType::Check;
350 using ArgumentParser::ParseResult::Check;
351 };
352
353 auto parser =
354 cmArgumentParser<ExportArguments>{}
355 .Bind("EXPORT"_s, &ExportArguments::ExportSetName)
356 .Bind("CXX_MODULES_DIRECTORY"_s, &ExportArguments::CxxModulesDirectory);
357 ArgumentsType::Bind(parser);
358
359 std::vector<std::string> unknownArgs;
360 ExportArguments arguments = parser.Parse(args, &unknownArgs);
361
362 if (!arguments.Check(args[0], &unknownArgs, status)) {
363 return false;
364 }
365
366 if (arguments.ExportSetName.empty()) {
367 status.SetError(cmStrCat(args[0], " missing EXPORT."));
368 return false;
369 }
370
371 if (!arguments.Check(status) || !arguments.SetMetadataFromProject(status)) {
372 return false;
373 }
374
375 cmMakefile& mf = status.GetMakefile();
376 cmGlobalGenerator* gg = mf.GetGlobalGenerator();
377
378 std::string const& dir =
379 arguments.GetDefaultDestination(mf.GetCurrentBinaryDirectory());
380 std::string const fname = cmStrCat(dir, '/', arguments.GetPackageFileName());
381
382 if (gg->GetExportedTargetsFile(fname)) {
383 status.SetError(cmStrCat("command already specified for the file "_s,
384 cmSystemTools::GetFilenameNameView(fname), '.'));
385 return false;
386 }
387
388 // Look up the export set
389 cm::optional<cmExportSet*> const exportSet =
390 GetExportSet(arguments.ExportSetName, gg, status);
391 if (!exportSet) {
392 return false;
393 }
394
395 // Create the export build generator
396 auto ebpg = cm::make_unique<GeneratorType>(arguments);

Callers

nothing calls this directly

Calls 15

GetExportSetFunction · 0.85
AddExportGeneratorFunction · 0.85
moveFunction · 0.85
cmStrCatFunction · 0.70
BindMethod · 0.45
ParseMethod · 0.45
CheckMethod · 0.45
emptyMethod · 0.45
SetErrorMethod · 0.45
GetMakefileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…