1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmExportFileGenerator.h,v $
6 Date: $Date: 2009-07-06 20:25:20 $
7 Version: $Revision: 1.9 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #ifndef cmExportFileGenerator_h
18 #define cmExportFileGenerator_h
20 #include "cmCommand.h"
22 /** \class cmExportFileGenerator
23 * \brief Generate a file exporting targets from a build or install tree.
25 * cmExportFileGenerator is the superclass for
26 * cmExportBuildFileGenerator and cmExportInstallFileGenerator. It
27 * contains common code generation routines for the two kinds of
28 * export implementations.
30 class cmExportFileGenerator
33 cmExportFileGenerator();
34 virtual ~cmExportFileGenerator() {}
36 /** Set the full path to the export file to generate. */
37 void SetExportFile(const char* mainFile
);
39 /** Set the namespace in which to place exported target names. */
40 void SetNamespace(const char* ns
) { this->Namespace
= ns
; }
42 /** Add a configuration to be exported. */
43 void AddConfiguration(const char* config
);
45 /** Actually generate the export file. Returns whether there was an
47 bool GenerateImportFile();
50 typedef std::map
<cmStdString
, cmStdString
> ImportPropertyMap
;
52 // Generate per-configuration target information to the given output
54 void GenerateImportConfig(std::ostream
& os
, const char* config
);
56 // Methods to implement export file code generation.
57 void GenerateImportHeaderCode(std::ostream
& os
, const char* config
= 0);
58 void GenerateImportFooterCode(std::ostream
& os
);
59 void GenerateImportVersionCode(std::ostream
& os
);
60 void GenerateImportTargetCode(std::ostream
& os
, cmTarget
* target
);
61 void GenerateImportPropertyCode(std::ostream
& os
, const char* config
,
63 ImportPropertyMap
const& properties
);
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
;