cmExportFileGenerator.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmExportFileGenerator_h
  11. #define cmExportFileGenerator_h
  12. #include "cmCommand.h"
  13. /** \class cmExportFileGenerator
  14. * \brief Generate a file exporting targets from a build or install tree.
  15. *
  16. * cmExportFileGenerator is the superclass for
  17. * cmExportBuildFileGenerator and cmExportInstallFileGenerator. It
  18. * contains common code generation routines for the two kinds of
  19. * export implementations.
  20. */
  21. class cmExportFileGenerator
  22. {
  23. public:
  24. cmExportFileGenerator();
  25. virtual ~cmExportFileGenerator() {}
  26. /** Set the full path to the export file to generate. */
  27. void SetExportFile(const char* mainFile);
  28. /** Set the namespace in which to place exported target names. */
  29. void SetNamespace(const char* ns) { this->Namespace = ns; }
  30. /** Add a configuration to be exported. */
  31. void AddConfiguration(const char* config);
  32. /** Actually generate the export file. Returns whether there was an
  33. error. */
  34. bool GenerateImportFile();
  35. protected:
  36. typedef std::map<cmStdString, cmStdString> ImportPropertyMap;
  37. // Generate per-configuration target information to the given output
  38. // stream.
  39. void GenerateImportConfig(std::ostream& os, const char* config);
  40. // Methods to implement export file code generation.
  41. void GenerateImportHeaderCode(std::ostream& os, const char* config = 0);
  42. void GenerateImportFooterCode(std::ostream& os);
  43. void GenerateImportVersionCode(std::ostream& os);
  44. void GenerateImportTargetCode(std::ostream& os, cmTarget* target);
  45. void GenerateImportPropertyCode(std::ostream& os, const char* config,
  46. cmTarget* target,
  47. ImportPropertyMap const& properties);
  48. // Collect properties with detailed information about targets beyond
  49. // their location on disk.
  50. void SetImportDetailProperties(const char* config,
  51. std::string const& suffix, cmTarget* target,
  52. ImportPropertyMap& properties);
  53. void SetImportLinkProperty(std::string const& suffix,
  54. cmTarget* target, const char* propName,
  55. std::vector<std::string> const& libs,
  56. ImportPropertyMap& properties);
  57. /** Each subclass knows how to generate its kind of export file. */
  58. virtual bool GenerateMainFile(std::ostream& os) = 0;
  59. /** Each subclass knows where the target files are located. */
  60. virtual void GenerateImportTargetsConfig(std::ostream& os,
  61. const char* config,
  62. std::string const& suffix) = 0;
  63. /** Each subclass knows how to complain about a target that is
  64. missing from an export set. */
  65. virtual void ComplainAboutMissingTarget(cmTarget* depender,
  66. cmTarget* dependee) = 0;
  67. // The namespace in which the exports are placed in the generated file.
  68. std::string Namespace;
  69. // The set of configurations to export.
  70. std::vector<std::string> Configurations;
  71. // The file to generate.
  72. std::string MainImportFile;
  73. std::string FileDir;
  74. std::string FileBase;
  75. std::string FileExt;
  76. bool AppendMode;
  77. // The set of targets included in the export.
  78. std::set<cmTarget*> ExportedTargets;
  79. };
  80. #endif