cmExportFileGenerator.h 4.0 KB

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