cmExportInstallFileGenerator.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 <cmConfigure.h>
  13. #include "cmExportFileGenerator.h"
  14. #include <iosfwd>
  15. #include <map>
  16. #include <set>
  17. #include <string>
  18. #include <vector>
  19. class cmGeneratorTarget;
  20. class cmGlobalGenerator;
  21. class cmInstallExportGenerator;
  22. class cmInstallTargetGenerator;
  23. /** \class cmExportInstallFileGenerator
  24. * \brief Generate a file exporting targets from an install tree.
  25. *
  26. * cmExportInstallFileGenerator generates files exporting targets from
  27. * install an installation tree. The files are placed in a temporary
  28. * location for installation by cmInstallExportGenerator. One main
  29. * file is generated that creates the imported targets and loads
  30. * per-configuration files. Target locations and settings for each
  31. * configuration are written to these per-configuration files. After
  32. * installation the main file loads the configurations that have been
  33. * installed.
  34. *
  35. * This is used to implement the INSTALL(EXPORT) command.
  36. */
  37. class cmExportInstallFileGenerator : public cmExportFileGenerator
  38. {
  39. public:
  40. /** Construct with the export installer that will install the
  41. files. */
  42. cmExportInstallFileGenerator(cmInstallExportGenerator* iegen);
  43. /** Get the per-config file generated for each configuraiton. This
  44. maps from the configuration name to the file temporary location
  45. for installation. */
  46. std::map<std::string, std::string> const& GetConfigImportFiles()
  47. {
  48. return this->ConfigImportFiles;
  49. }
  50. /** Compute the globbing expression used to load per-config import
  51. files from the main file. */
  52. std::string GetConfigImportFileGlob();
  53. protected:
  54. // Implement virtual methods from the superclass.
  55. bool GenerateMainFile(std::ostream& os) CM_OVERRIDE;
  56. void GenerateImportTargetsConfig(
  57. std::ostream& os, const std::string& config, std::string const& suffix,
  58. std::vector<std::string>& missingTargets) CM_OVERRIDE;
  59. void HandleMissingTarget(std::string& link_libs,
  60. std::vector<std::string>& missingTargets,
  61. cmGeneratorTarget* depender,
  62. cmGeneratorTarget* dependee) CM_OVERRIDE;
  63. void ReplaceInstallPrefix(std::string& input) CM_OVERRIDE;
  64. void ComplainAboutMissingTarget(cmGeneratorTarget* depender,
  65. cmGeneratorTarget* dependee,
  66. int occurrences);
  67. std::vector<std::string> FindNamespaces(cmGlobalGenerator* gg,
  68. const std::string& name);
  69. /** Generate a per-configuration file for the targets. */
  70. bool GenerateImportFileConfig(const std::string& config,
  71. std::vector<std::string>& missingTargets);
  72. /** Fill in properties indicating installed file locations. */
  73. void SetImportLocationProperty(const std::string& config,
  74. std::string const& suffix,
  75. cmInstallTargetGenerator* itgen,
  76. ImportPropertyMap& properties,
  77. std::set<std::string>& importedLocations);
  78. std::string InstallNameDir(cmGeneratorTarget* target,
  79. const std::string& config) CM_OVERRIDE;
  80. cmInstallExportGenerator* IEGen;
  81. // The import file generated for each configuration.
  82. std::map<std::string, std::string> ConfigImportFiles;
  83. };
  84. #endif