cmExportBuildFileGenerator.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 "cmExportFileGenerator.h"
  7. #include <iosfwd>
  8. #include <string>
  9. #include <vector>
  10. class cmExportSet;
  11. class cmGeneratorTarget;
  12. class cmGlobalGenerator;
  13. class cmLocalGenerator;
  14. /** \class cmExportBuildFileGenerator
  15. * \brief Generate a file exporting targets from a build tree.
  16. *
  17. * cmExportBuildFileGenerator generates a file exporting targets from
  18. * a build tree. A single file exports information for all
  19. * configurations built.
  20. *
  21. * This is used to implement the EXPORT() command.
  22. */
  23. class cmExportBuildFileGenerator : public cmExportFileGenerator
  24. {
  25. public:
  26. cmExportBuildFileGenerator();
  27. /** Set the list of targets to export. */
  28. void SetTargets(std::vector<std::string> const& targets)
  29. {
  30. this->Targets = targets;
  31. }
  32. void GetTargets(std::vector<std::string>& targets) const;
  33. void AppendTargets(std::vector<std::string> const& targets)
  34. {
  35. this->Targets.insert(this->Targets.end(), targets.begin(), targets.end());
  36. }
  37. void SetExportSet(cmExportSet*);
  38. /** Set whether to append generated code to the output file. */
  39. void SetAppendMode(bool append) { this->AppendMode = append; }
  40. void Compute(cmLocalGenerator* lg);
  41. protected:
  42. // Implement virtual methods from the superclass.
  43. bool GenerateMainFile(std::ostream& os) override;
  44. void GenerateImportTargetsConfig(
  45. std::ostream& os, const std::string& config, std::string const& suffix,
  46. std::vector<std::string>& missingTargets) override;
  47. void HandleMissingTarget(std::string& link_libs,
  48. std::vector<std::string>& missingTargets,
  49. cmGeneratorTarget* depender,
  50. cmGeneratorTarget* dependee) override;
  51. void ComplainAboutMissingTarget(cmGeneratorTarget* depender,
  52. cmGeneratorTarget* dependee,
  53. int occurrences);
  54. /** Fill in properties indicating built file locations. */
  55. void SetImportLocationProperty(const std::string& config,
  56. std::string const& suffix,
  57. cmGeneratorTarget* target,
  58. ImportPropertyMap& properties);
  59. std::string InstallNameDir(cmGeneratorTarget* target,
  60. const std::string& config) override;
  61. std::vector<std::string> FindNamespaces(cmGlobalGenerator* gg,
  62. const std::string& name);
  63. std::vector<std::string> Targets;
  64. cmExportSet* ExportSet;
  65. std::vector<cmGeneratorTarget*> Exports;
  66. cmLocalGenerator* LG;
  67. };
  68. #endif