2009-09-28 15:43:28 +00:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2008-01-28 13:38:36 +00:00
|
|
|
|
2009-09-28 15:43:28 +00:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2008-01-28 13:38:36 +00:00
|
|
|
|
2009-09-28 15:43:28 +00:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2008-01-28 13:38:36 +00:00
|
|
|
#ifndef cmExportFileGenerator_h
|
|
|
|
#define cmExportFileGenerator_h
|
|
|
|
|
|
|
|
#include "cmCommand.h"
|
2012-12-10 22:05:11 +00:00
|
|
|
#include "cmGeneratorExpression.h"
|
2008-01-28 13:38:36 +00:00
|
|
|
|
2013-01-05 11:13:49 +00:00
|
|
|
class cmTargetExport;
|
|
|
|
|
2008-01-28 13:38:36 +00:00
|
|
|
/** \class cmExportFileGenerator
|
|
|
|
* \brief Generate a file exporting targets from a build or install tree.
|
|
|
|
*
|
|
|
|
* cmExportFileGenerator is the superclass for
|
|
|
|
* cmExportBuildFileGenerator and cmExportInstallFileGenerator. It
|
|
|
|
* contains common code generation routines for the two kinds of
|
|
|
|
* export implementations.
|
|
|
|
*/
|
|
|
|
class cmExportFileGenerator
|
|
|
|
{
|
|
|
|
public:
|
2008-01-28 18:21:42 +00:00
|
|
|
cmExportFileGenerator();
|
2008-01-28 14:53:21 +00:00
|
|
|
virtual ~cmExportFileGenerator() {}
|
|
|
|
|
2008-01-28 13:38:36 +00:00
|
|
|
/** Set the full path to the export file to generate. */
|
|
|
|
void SetExportFile(const char* mainFile);
|
|
|
|
|
|
|
|
/** Set the namespace in which to place exported target names. */
|
|
|
|
void SetNamespace(const char* ns) { this->Namespace = ns; }
|
|
|
|
|
2013-06-04 14:47:57 +00:00
|
|
|
void SetExportOld(bool exportOld) { this->ExportOld = exportOld; }
|
|
|
|
|
2008-01-28 13:38:36 +00:00
|
|
|
/** Add a configuration to be exported. */
|
|
|
|
void AddConfiguration(const char* config);
|
|
|
|
|
|
|
|
/** Actually generate the export file. Returns whether there was an
|
|
|
|
error. */
|
|
|
|
bool GenerateImportFile();
|
|
|
|
protected:
|
|
|
|
|
|
|
|
typedef std::map<cmStdString, cmStdString> ImportPropertyMap;
|
|
|
|
|
|
|
|
// Generate per-configuration target information to the given output
|
|
|
|
// stream.
|
2013-01-13 08:44:52 +00:00
|
|
|
void GenerateImportConfig(std::ostream& os, const char* config,
|
|
|
|
std::vector<std::string> &missingTargets);
|
2008-01-28 13:38:36 +00:00
|
|
|
|
|
|
|
// Methods to implement export file code generation.
|
|
|
|
void GenerateImportHeaderCode(std::ostream& os, const char* config = 0);
|
|
|
|
void GenerateImportFooterCode(std::ostream& os);
|
|
|
|
void GenerateImportVersionCode(std::ostream& os);
|
|
|
|
void GenerateImportTargetCode(std::ostream& os, cmTarget* target);
|
|
|
|
void GenerateImportPropertyCode(std::ostream& os, const char* config,
|
|
|
|
cmTarget* target,
|
|
|
|
ImportPropertyMap const& properties);
|
2011-11-12 17:12:07 +00:00
|
|
|
void GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target,
|
|
|
|
ImportPropertyMap const& properties,
|
|
|
|
const std::set<std::string>& importedLocations);
|
|
|
|
void GenerateImportedFileCheckLoop(std::ostream& os);
|
2012-09-15 20:38:30 +00:00
|
|
|
void GenerateMissingTargetsCheckCode(std::ostream& os,
|
|
|
|
const std::vector<std::string>& missingTargets);
|
2011-11-12 17:12:07 +00:00
|
|
|
|
2012-11-30 08:26:09 +00:00
|
|
|
void GenerateExpectedTargetsCode(std::ostream& os,
|
|
|
|
const std::string &expectedTargets);
|
2008-01-28 13:38:36 +00:00
|
|
|
|
|
|
|
// Collect properties with detailed information about targets beyond
|
|
|
|
// their location on disk.
|
|
|
|
void SetImportDetailProperties(const char* config,
|
|
|
|
std::string const& suffix, cmTarget* target,
|
2012-09-15 20:38:30 +00:00
|
|
|
ImportPropertyMap& properties,
|
|
|
|
std::vector<std::string>& missingTargets);
|
2008-01-31 20:45:31 +00:00
|
|
|
void SetImportLinkProperty(std::string const& suffix,
|
|
|
|
cmTarget* target, const char* propName,
|
|
|
|
std::vector<std::string> const& libs,
|
2012-09-15 20:38:30 +00:00
|
|
|
ImportPropertyMap& properties,
|
|
|
|
std::vector<std::string>& missingTargets);
|
2008-01-28 13:38:36 +00:00
|
|
|
|
|
|
|
/** Each subclass knows how to generate its kind of export file. */
|
|
|
|
virtual bool GenerateMainFile(std::ostream& os) = 0;
|
|
|
|
|
|
|
|
/** Each subclass knows where the target files are located. */
|
|
|
|
virtual void GenerateImportTargetsConfig(std::ostream& os,
|
|
|
|
const char* config,
|
2013-01-13 08:44:52 +00:00
|
|
|
std::string const& suffix,
|
|
|
|
std::vector<std::string> &missingTargets) = 0;
|
2008-01-28 13:38:36 +00:00
|
|
|
|
2012-09-28 19:47:37 +00:00
|
|
|
/** Each subclass knows how to deal with a target that is missing from an
|
|
|
|
* export set. */
|
|
|
|
virtual void HandleMissingTarget(std::string& link_libs,
|
|
|
|
std::vector<std::string>& missingTargets,
|
|
|
|
cmMakefile* mf,
|
|
|
|
cmTarget* depender,
|
|
|
|
cmTarget* dependee) = 0;
|
2012-12-10 22:05:11 +00:00
|
|
|
void PopulateInterfaceProperty(const char *,
|
|
|
|
cmTarget *target,
|
|
|
|
cmGeneratorExpression::PreprocessContext,
|
|
|
|
ImportPropertyMap &properties,
|
|
|
|
std::vector<std::string> &missingTargets);
|
2013-06-04 14:47:57 +00:00
|
|
|
bool PopulateInterfaceLinkLibrariesProperty(cmTarget *target,
|
|
|
|
cmGeneratorExpression::PreprocessContext,
|
|
|
|
ImportPropertyMap &properties,
|
|
|
|
std::vector<std::string> &missingTargets);
|
2013-01-12 11:13:19 +00:00
|
|
|
void PopulateInterfaceProperty(const char *propName, cmTarget *target,
|
|
|
|
ImportPropertyMap &properties);
|
2013-01-20 16:09:29 +00:00
|
|
|
void PopulateCompatibleInterfaceProperties(cmTarget *target,
|
|
|
|
ImportPropertyMap &properties);
|
2012-12-10 22:05:11 +00:00
|
|
|
void GenerateInterfaceProperties(cmTarget *target, std::ostream& os,
|
|
|
|
const ImportPropertyMap &properties);
|
2013-03-24 20:18:17 +00:00
|
|
|
void PopulateIncludeDirectoriesInterface(
|
2013-01-05 11:13:49 +00:00
|
|
|
cmTargetExport *target,
|
2013-03-24 20:18:17 +00:00
|
|
|
cmGeneratorExpression::PreprocessContext preprocessRule,
|
|
|
|
ImportPropertyMap &properties,
|
|
|
|
std::vector<std::string> &missingTargets);
|
2008-01-28 13:38:36 +00:00
|
|
|
|
2013-01-04 14:58:16 +00:00
|
|
|
void SetImportLinkInterface(const char* config, std::string const& suffix,
|
|
|
|
cmGeneratorExpression::PreprocessContext preprocessRule,
|
|
|
|
cmTarget* target, ImportPropertyMap& properties,
|
|
|
|
std::vector<std::string>& missingTargets);
|
2013-01-04 14:56:13 +00:00
|
|
|
|
|
|
|
enum FreeTargetsReplace {
|
|
|
|
ReplaceFreeTargets,
|
|
|
|
NoReplaceFreeTargets
|
|
|
|
};
|
|
|
|
|
2012-12-10 22:07:09 +00:00
|
|
|
void ResolveTargetsInGeneratorExpressions(std::string &input,
|
2013-02-12 10:56:58 +00:00
|
|
|
cmTarget* target,
|
2013-01-04 14:56:13 +00:00
|
|
|
std::vector<std::string> &missingTargets,
|
|
|
|
FreeTargetsReplace replace = NoReplaceFreeTargets);
|
2012-12-10 22:07:09 +00:00
|
|
|
|
2013-06-04 14:47:57 +00:00
|
|
|
void GenerateRequiredCMakeVersion(std::ostream& os,
|
|
|
|
const char *versionString);
|
|
|
|
|
2008-01-28 13:38:36 +00:00
|
|
|
// The namespace in which the exports are placed in the generated file.
|
|
|
|
std::string Namespace;
|
|
|
|
|
2013-06-04 14:47:57 +00:00
|
|
|
bool ExportOld;
|
|
|
|
|
2008-01-28 13:38:36 +00:00
|
|
|
// The set of configurations to export.
|
|
|
|
std::vector<std::string> Configurations;
|
|
|
|
|
|
|
|
// The file to generate.
|
|
|
|
std::string MainImportFile;
|
|
|
|
std::string FileDir;
|
|
|
|
std::string FileBase;
|
|
|
|
std::string FileExt;
|
2008-01-28 18:21:42 +00:00
|
|
|
bool AppendMode;
|
2008-01-28 13:38:36 +00:00
|
|
|
|
|
|
|
// The set of targets included in the export.
|
|
|
|
std::set<cmTarget*> ExportedTargets;
|
2012-12-10 22:05:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void PopulateInterfaceProperty(const char *, const char *,
|
|
|
|
cmTarget *target,
|
|
|
|
cmGeneratorExpression::PreprocessContext,
|
|
|
|
ImportPropertyMap &properties,
|
|
|
|
std::vector<std::string> &missingTargets);
|
2013-01-08 19:58:33 +00:00
|
|
|
|
|
|
|
bool AddTargetNamespace(std::string &input, cmTarget* target,
|
|
|
|
std::vector<std::string> &missingTargets);
|
|
|
|
|
2013-01-04 14:56:13 +00:00
|
|
|
void ResolveTargetsInGeneratorExpression(std::string &input,
|
2013-02-12 10:56:58 +00:00
|
|
|
cmTarget* target,
|
2013-01-04 14:56:13 +00:00
|
|
|
std::vector<std::string> &missingTargets);
|
2013-01-27 08:43:44 +00:00
|
|
|
|
|
|
|
virtual void ReplaceInstallPrefix(std::string &input);
|
2013-05-20 22:57:58 +00:00
|
|
|
|
|
|
|
virtual std::string InstallNameDir(cmTarget* target,
|
|
|
|
const std::string& config) = 0;
|
2008-01-28 13:38:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|