cmExportBuildFileGenerator.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <iosfwd>
  6. #include <string>
  7. #include <utility>
  8. #include <vector>
  9. #include <cmext/algorithm>
  10. #include "cmExportFileGenerator.h"
  11. #include "cmStateTypes.h"
  12. class cmExportSet;
  13. class cmFileSet;
  14. class cmGeneratorTarget;
  15. class cmGlobalGenerator;
  16. class cmLocalGenerator;
  17. class cmTargetExport;
  18. /** \class cmExportBuildFileGenerator
  19. * \brief Generate a file exporting targets from a build tree.
  20. *
  21. * cmExportBuildFileGenerator generates a file exporting targets from
  22. * a build tree. A single file exports information for all
  23. * configurations built.
  24. *
  25. * This is used to implement the export() command.
  26. */
  27. class cmExportBuildFileGenerator : public cmExportFileGenerator
  28. {
  29. public:
  30. cmExportBuildFileGenerator();
  31. /** Set the list of targets to export. */
  32. void SetTargets(std::vector<std::string> const& targets)
  33. {
  34. this->Targets = targets;
  35. }
  36. void GetTargets(std::vector<std::string>& targets) const;
  37. void AppendTargets(std::vector<std::string> const& targets)
  38. {
  39. cm::append(this->Targets, targets);
  40. }
  41. void SetExportSet(cmExportSet*);
  42. /** Set whether to append generated code to the output file. */
  43. void SetAppendMode(bool append) { this->AppendMode = append; }
  44. void Compute(cmLocalGenerator* lg);
  45. protected:
  46. // Implement virtual methods from the superclass.
  47. bool GenerateMainFile(std::ostream& os) override;
  48. void GenerateImportTargetsConfig(std::ostream& os, const std::string& config,
  49. std::string const& suffix) override;
  50. cmStateEnums::TargetType GetExportTargetType(
  51. cmGeneratorTarget const* target) const;
  52. void HandleMissingTarget(std::string& link_libs,
  53. cmGeneratorTarget const* depender,
  54. cmGeneratorTarget* dependee) override;
  55. void ComplainAboutMissingTarget(cmGeneratorTarget const* depender,
  56. cmGeneratorTarget const* dependee,
  57. std::vector<std::string> const& namespaces);
  58. /** Fill in properties indicating built file locations. */
  59. void SetImportLocationProperty(const std::string& config,
  60. std::string const& suffix,
  61. cmGeneratorTarget* target,
  62. ImportPropertyMap& properties);
  63. std::string InstallNameDir(cmGeneratorTarget const* target,
  64. const std::string& config) override;
  65. std::string GetFileSetDirectories(cmGeneratorTarget* gte, cmFileSet* fileSet,
  66. cmTargetExport* te) override;
  67. std::string GetFileSetFiles(cmGeneratorTarget* gte, cmFileSet* fileSet,
  68. cmTargetExport* te) override;
  69. std::pair<std::vector<std::string>, std::string> FindBuildExportInfo(
  70. cmGlobalGenerator* gg, const std::string& name);
  71. std::vector<std::string> Targets;
  72. cmExportSet* ExportSet;
  73. std::vector<cmGeneratorTarget*> Exports;
  74. cmLocalGenerator* LG;
  75. };