cmExportBuildFileGenerator.h 2.9 KB

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