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

Function cmcmd_cmake_module_compile_db

Source/cmBuildDatabase.cxx:497–581  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

495}
496
497int cmcmd_cmake_module_compile_db(
498 std::vector<std::string>::const_iterator argBeg,
499 std::vector<std::string>::const_iterator argEnd)
500{
501 std::string const* command = nullptr;
502 std::string const* output = nullptr;
503 std::vector<std::string const*> inputs;
504
505 bool next_is_output = false;
506 for (auto i = argBeg; i != argEnd; ++i) {
507 // The first argument is always the command.
508 if (!command) {
509 command = &(*i);
510 continue;
511 }
512
513 if (*i == "-o"_s) {
514 next_is_output = true;
515 continue;
516 }
517 if (next_is_output) {
518 if (output) {
519 cmSystemTools::Error(
520 "-E cmake_module_compile_db only supports one output file");
521 return EXIT_FAILURE;
522 }
523
524 output = &(*i);
525 next_is_output = false;
526 continue;
527 }
528
529 inputs.emplace_back(&(*i));
530 }
531
532 if (!command) {
533 cmSystemTools::Error("-E cmake_module_compile_db requires a subcommand");
534 return EXIT_FAILURE;
535 }
536
537 int ret = EXIT_SUCCESS;
538
539 if (*command == "verify"_s) {
540 if (output) {
541 cmSystemTools::Error(
542 "-E cmake_module_compile_db verify does not support an output");
543 return EXIT_FAILURE;
544 }
545
546 for (auto const* i : inputs) {
547 auto db = cmBuildDatabase::Load(*i);
548 if (!db) {
549 cmSystemTools::Error(cmStrCat("failed to verify ", *i));
550 ret = EXIT_FAILURE;
551 }
552 }
553 } else if (*command == "merge"_s) {
554 if (!output) {

Callers 1

ExecuteCMakeCommandMethod · 0.85

Calls 6

LoadEnum · 0.85
moveFunction · 0.85
emplace_backMethod · 0.80
ErrorClass · 0.70
cmStrCatFunction · 0.70
WriteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…