1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmExportFileGenerator.h,v $
6 Date: $Date: 2008/02/01 13:56:00 $
7 Version: $Revision: 1.8 $
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 SetImportLinkProperties(const char* config
,
71 std::string
const& suffix
, cmTarget
* target
,
72 ImportPropertyMap
& properties
);
73 void SetImportLinkProperty(std::string
const& suffix
,
74 cmTarget
* target
, const char* propName
,
75 std::vector
<std::string
> const& libs
,
76 ImportPropertyMap
& properties
);
78 /** Each subclass knows how to generate its kind of export file. */
79 virtual bool GenerateMainFile(std::ostream
& os
) = 0;
81 /** Each subclass knows where the target files are located. */
82 virtual void GenerateImportTargetsConfig(std::ostream
& os
,
84 std::string
const& suffix
) = 0;
86 /** Each subclass knows how to complain about a target that is
87 missing from an export set. */
88 virtual void ComplainAboutMissingTarget(cmTarget
* depender
,
89 cmTarget
* dependee
) = 0;
91 // The namespace in which the exports are placed in the generated file.
92 std::string Namespace
;
94 // The set of configurations to export.
95 std::vector
<std::string
> Configurations
;
97 // The file to generate.
98 std::string MainImportFile
;
100 std::string FileBase
;
104 // The set of targets included in the export.
105 std::set
<cmTarget
*> ExportedTargets
;