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