cmExportBuildFileGenerator.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmExportBuildFileGenerator_h
  4. #define cmExportBuildFileGenerator_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include "cmAlgorithms.h"
  7. #include "cmExportFileGenerator.h"
  8. #include "cmStateTypes.h"
  9. #include <iosfwd>
  10. #include <string>
  11. #include <vector>
  12. class cmExportSet;
  13. class cmGeneratorTarget;
  14. class cmGlobalGenerator;
  15. class cmLocalGenerator;
  16. /** \class cmExportBuildFileGenerator
  17. * \brief Generate a file exporting targets from a build tree.
  18. *
  19. * cmExportBuildFileGenerator generates a file exporting targets from
  20. * a build tree. A single file exports information for all
  21. * configurations built.
  22. *
  23. * This is used to implement the EXPORT() command.
  24. */
  25. class cmExportBuildFileGenerator : public cmExportFileGenerator
  26. {
  27. public:
  28. cmExportBuildFileGenerator();
  29. /** Set the list of targets to export. */
  30. void SetTargets(std::vector<std::string> const& targets)
  31. {
  32. this->Targets = targets;
  33. }
  34. void GetTargets(std::vector<std::string>& targets) const;
  35. void AppendTargets(std::vector<std::string> const& targets)
  36. {
  37. cmAppend(this->Targets, targets);
  38. }
  39. void SetExportSet(cmExportSet*);
  40. /** Set whether to append generated code to the output file. */
  41. void SetAppendMode(bool append) { this->AppendMode = append; }
  42. void Compute(cmLocalGenerator* lg);
  43. protected:
  44. // Implement virtual methods from the superclass.
  45. bool GenerateMainFile(std::ostream& os) override;
  46. void GenerateImportTargetsConfig(
  47. std::ostream& os, const std::string& config, std::string const& suffix,
  48. std::vector<std::string>& missingTargets) override;
  49. cmStateEnums::TargetType GetExportTargetType(
  50. cmGeneratorTarget const* target) const;
  51. void HandleMissingTarget(std::string& link_libs,
  52. std::vector<std::string>& missingTargets,
  53. cmGeneratorTarget* depender,
  54. cmGeneratorTarget* dependee) override;
  55. void ComplainAboutMissingTarget(cmGeneratorTarget* depender,
  56. cmGeneratorTarget* dependee,
  57. int occurrences);
  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* target,
  64. const std::string& config) override;
  65. std::vector<std::string> FindNamespaces(cmGlobalGenerator* gg,
  66. const std::string& name);
  67. std::vector<std::string> Targets;
  68. cmExportSet* ExportSet;
  69. std::vector<cmGeneratorTarget*> Exports;
  70. cmLocalGenerator* LG;
  71. };
  72. #endif