cmExportBuildFileGenerator.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 the name of the C++ module directory. */
  43. void SetCxxModuleDirectory(std::string cxx_module_dir)
  44. {
  45. this->CxxModulesDirectory = std::move(cxx_module_dir);
  46. }
  47. const std::string& GetCxxModuleDirectory() const
  48. {
  49. return this->CxxModulesDirectory;
  50. }
  51. /** Set whether to append generated code to the output file. */
  52. void SetAppendMode(bool append) { this->AppendMode = append; }
  53. void Compute(cmLocalGenerator* lg);
  54. protected:
  55. // Implement virtual methods from the superclass.
  56. bool GenerateMainFile(std::ostream& os) override;
  57. void GenerateImportTargetsConfig(std::ostream& os, const std::string& config,
  58. std::string const& suffix) override;
  59. cmStateEnums::TargetType GetExportTargetType(
  60. cmGeneratorTarget const* target) const;
  61. void HandleMissingTarget(std::string& link_libs,
  62. cmGeneratorTarget const* depender,
  63. cmGeneratorTarget* dependee) override;
  64. void ComplainAboutMissingTarget(cmGeneratorTarget const* depender,
  65. cmGeneratorTarget const* dependee,
  66. std::vector<std::string> const& namespaces);
  67. /** Fill in properties indicating built file locations. */
  68. void SetImportLocationProperty(const std::string& config,
  69. std::string const& suffix,
  70. cmGeneratorTarget* target,
  71. ImportPropertyMap& properties);
  72. std::string InstallNameDir(cmGeneratorTarget const* target,
  73. const std::string& config) override;
  74. std::string GetFileSetDirectories(cmGeneratorTarget* gte, cmFileSet* fileSet,
  75. cmTargetExport* te) override;
  76. std::string GetFileSetFiles(cmGeneratorTarget* gte, cmFileSet* fileSet,
  77. cmTargetExport* te) override;
  78. std::pair<std::vector<std::string>, std::string> FindBuildExportInfo(
  79. cmGlobalGenerator* gg, const std::string& name);
  80. std::vector<std::string> Targets;
  81. cmExportSet* ExportSet;
  82. std::vector<cmGeneratorTarget*> Exports;
  83. cmLocalGenerator* LG;
  84. // The directory for C++ module information.
  85. std::string CxxModulesDirectory;
  86. };