| 530 | } |
| 531 | |
| 532 | void cmExportCMakeConfigGenerator::GenerateImportedFileCheckLoop( |
| 533 | std::ostream& os) |
| 534 | { |
| 535 | // Add code which verifies at cmake time that the file which is being |
| 536 | // imported actually exists on disk. This should in theory always be theory |
| 537 | // case, but still when packages are split into normal and development |
| 538 | // packages this might get broken (e.g. the Config.cmake could be part of |
| 539 | // the non-development package, something similar happened to me without |
| 540 | // on SUSE with a mysql pkg-config file, which claimed everything is fine, |
| 541 | // but the development package was not installed.). |
| 542 | os << "# Loop over all imported files and verify that they actually exist\n" |
| 543 | "foreach(_cmake_target IN LISTS _cmake_import_check_targets)\n" |
| 544 | " if(CMAKE_VERSION VERSION_LESS \"3.28\"\n" |
| 545 | " OR NOT DEFINED " |
| 546 | "_cmake_import_check_xcframework_for_${_cmake_target}\n" |
| 547 | " OR NOT IS_DIRECTORY " |
| 548 | "\"${_cmake_import_check_xcframework_for_${_cmake_target}}\")\n" |
| 549 | " foreach(_cmake_file IN LISTS " |
| 550 | "\"_cmake_import_check_files_for_${_cmake_target}\")\n" |
| 551 | " if(NOT EXISTS \"${_cmake_file}\")\n" |
| 552 | " message(FATAL_ERROR \"The imported target " |
| 553 | "\\\"${_cmake_target}\\\" references the file\n" |
| 554 | " \\\"${_cmake_file}\\\"\n" |
| 555 | "but this file does not exist. Possible reasons include:\n" |
| 556 | "* The file was deleted, renamed, or moved to another location.\n" |
| 557 | "* An install or uninstall procedure did not complete successfully.\n" |
| 558 | "* The installation package was faulty and contained\n" |
| 559 | " \\\"${CMAKE_CURRENT_LIST_FILE}\\\"\n" |
| 560 | "but not all the files it references.\n" |
| 561 | "\")\n" |
| 562 | " endif()\n" |
| 563 | " endforeach()\n" |
| 564 | " endif()\n" |
| 565 | " unset(_cmake_file)\n" |
| 566 | " unset(\"_cmake_import_check_files_for_${_cmake_target}\")\n" |
| 567 | "endforeach()\n" |
| 568 | "unset(_cmake_target)\n" |
| 569 | "unset(_cmake_import_check_targets)\n" |
| 570 | "\n"; |
| 571 | } |
| 572 | |
| 573 | void cmExportCMakeConfigGenerator::GenerateImportedFileChecksCode( |
| 574 | std::ostream& os, cmGeneratorTarget const* target, |