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

Method GenerateMissingTargetsCheckCode

Source/cmExportCMakeConfigGenerator.cxx:488–530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486}
487
488void cmExportCMakeConfigGenerator::GenerateMissingTargetsCheckCode(
489 std::ostream& os)
490{
491 if (this->MissingTargets.empty()) {
492 os << "# This file does not depend on other imported targets which have\n"
493 "# been exported from the same project but in a separate "
494 "export set.\n\n";
495 return;
496 }
497 os << "# Make sure the targets which have been exported in some other\n"
498 "# export set exist.\n"
499 "unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
500 "foreach(_target ";
501 std::set<std::string> emitted;
502 for (std::string const& missingTarget : this->MissingTargets) {
503 if (emitted.insert(missingTarget).second) {
504 os << '"' << missingTarget << "\" ";
505 }
506 }
507 os << ")\n"
508 " if(NOT TARGET \"${_target}\" )\n"
509 " set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets \""
510 "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets} ${_target}\")"
511 "\n"
512 " endif()\n"
513 "endforeach()\n"
514 "\n"
515 "if(DEFINED ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
516 " if(CMAKE_FIND_PACKAGE_NAME)\n"
517 " set( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)\n"
518 " set( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "
519 "\"The following imported targets are "
520 "referenced, but are missing: "
521 "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets}\")\n"
522 " else()\n"
523 " message(FATAL_ERROR \"The following imported targets are "
524 "referenced, but are missing: "
525 "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets}\")\n"
526 " endif()\n"
527 "endif()\n"
528 "unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
529 "\n";
530}
531
532void cmExportCMakeConfigGenerator::GenerateImportedFileCheckLoop(
533 std::ostream& os)

Callers 2

GenerateMainFileMethod · 0.80
GenerateMainFileMethod · 0.80

Calls 2

emptyMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected