cmExportInstallFileGenerator.h 3.7 KB

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