cmExportInstallFileGenerator.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 cmExportInstallFileGenerator_h
  11. #define cmExportInstallFileGenerator_h
  12. #include "cmExportFileGenerator.h"
  13. class cmInstallExportGenerator;
  14. class cmInstallFilesGenerator;
  15. class cmInstallTargetGenerator;
  16. class cmTargetExport;
  17. /** \class cmExportInstallFileGenerator
  18. * \brief Generate a file exporting targets from an install tree.
  19. *
  20. * cmExportInstallFileGenerator generates files exporting targets from
  21. * install an installation tree. The files are placed in a temporary
  22. * location for installation by cmInstallExportGenerator. One main
  23. * file is generated that creates the imported targets and loads
  24. * per-configuration files. Target locations and settings for each
  25. * configuration are written to these per-configuration files. After
  26. * installation the main file loads the configurations that have been
  27. * installed.
  28. *
  29. * This is used to implement the INSTALL(EXPORT) command.
  30. */
  31. class cmExportInstallFileGenerator: public cmExportFileGenerator
  32. {
  33. public:
  34. /** Construct with the export installer that will install the
  35. files. */
  36. cmExportInstallFileGenerator(cmInstallExportGenerator* iegen);
  37. /** Set the name of the export associated with the files. This is
  38. the name given to the install(EXPORT) command mode. */
  39. void SetName(const char* name) { this->Name = name; }
  40. /** Set the set of targets to be exported. These are the targets
  41. associated with the export name. */
  42. void SetExportSet(std::vector<cmTargetExport*> const* eSet)
  43. { this->ExportSet = eSet; }
  44. /** Get the per-config file generated for each configuraiton. This
  45. maps from the configuration name to the file temporary location
  46. for installation. */
  47. std::map<cmStdString, cmStdString> const& GetConfigImportFiles()
  48. { return this->ConfigImportFiles; }
  49. /** Compute the globbing expression used to load per-config import
  50. files from the main file. */
  51. std::string GetConfigImportFileGlob();
  52. protected:
  53. // Implement virtual methods from the superclass.
  54. virtual bool GenerateMainFile(std::ostream& os);
  55. virtual void GenerateImportTargetsConfig(std::ostream& os,
  56. const char* config,
  57. std::string const& suffix);
  58. virtual void ComplainAboutMissingTarget(cmTarget* depender,
  59. cmTarget* dependee);
  60. /** Generate a per-configuration file for the targets. */
  61. bool GenerateImportFileConfig(const char* config);
  62. /** Fill in properties indicating installed file locations. */
  63. void SetImportLocationProperty(const char* config,
  64. std::string const& suffix,
  65. cmInstallTargetGenerator* itgen,
  66. ImportPropertyMap& properties,
  67. std::set<std::string>& importedLocations
  68. );
  69. void ComplainAboutImportPrefix(cmInstallTargetGenerator* itgen);
  70. cmInstallExportGenerator* InstallExportGenerator;
  71. std::string Name;
  72. std::vector<cmTargetExport*> const* ExportSet;
  73. std::string ImportPrefix;
  74. // The import file generated for each configuration.
  75. std::map<cmStdString, cmStdString> ConfigImportFiles;
  76. };
  77. /*
  78. cmTargetExport is used in cmGlobalGenerator to collect the install
  79. generators for targets associated with an export.
  80. */
  81. class cmTargetExport
  82. {
  83. public:
  84. cmTargetExport(cmTarget* tgt,
  85. cmInstallTargetGenerator* archive,
  86. cmInstallTargetGenerator* runtime,
  87. cmInstallTargetGenerator* library,
  88. cmInstallTargetGenerator* framework,
  89. cmInstallTargetGenerator* bundle,
  90. cmInstallFilesGenerator* headers
  91. ) : Target(tgt), ArchiveGenerator(archive),
  92. RuntimeGenerator(runtime), LibraryGenerator(library),
  93. FrameworkGenerator(framework), BundleGenerator(bundle),
  94. HeaderGenerator(headers) {}
  95. cmTarget* Target;
  96. cmInstallTargetGenerator* ArchiveGenerator;
  97. cmInstallTargetGenerator* RuntimeGenerator;
  98. cmInstallTargetGenerator* LibraryGenerator;
  99. cmInstallTargetGenerator* FrameworkGenerator;
  100. cmInstallTargetGenerator* BundleGenerator;
  101. cmInstallFilesGenerator* HeaderGenerator;
  102. private:
  103. cmTargetExport();
  104. };
  105. #endif