cmExportBuildFileGenerator.h 2.9 KB

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