2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2008-01-28 16:38:36 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2008-01-28 16:38:36 +03:00
|
|
|
|
2009-09-28 19:43:28 +04: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 16:38:36 +03:00
|
|
|
#ifndef cmExportFileGenerator_h
|
|
|
|
#define cmExportFileGenerator_h
|
|
|
|
|
2016-09-01 21:59:28 +03:00
|
|
|
#include <cmConfigure.h> // IWYU pragma: keep
|
2008-01-28 16:38:36 +03:00
|
|
|
|
2016-09-01 21:59:28 +03:00
|
|
|
#include "cmGeneratorExpression.h"
|
2014-02-11 19:31:53 +04:00
|
|
|
#include "cmVersion.h"
|
2016-09-01 21:59:28 +03:00
|
|
|
#include "cmVersionConfig.h"
|
|
|
|
|
|
|
|
#include <iosfwd>
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class cmGeneratorTarget;
|
2014-02-11 19:31:53 +04:00
|
|
|
|
|
|
|
#define STRINGIFY_HELPER(X) #X
|
|
|
|
#define STRINGIFY(X) STRINGIFY_HELPER(X)
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
#define DEVEL_CMAKE_VERSION(major, minor) \
|
|
|
|
(CMake_VERSION_ENCODE(major, minor, 0) > \
|
|
|
|
CMake_VERSION_ENCODE(CMake_VERSION_MAJOR, CMake_VERSION_MINOR, 0) \
|
|
|
|
? STRINGIFY(CMake_VERSION_MAJOR) "." STRINGIFY( \
|
|
|
|
CMake_VERSION_MINOR) "." STRINGIFY(CMake_VERSION_PATCH) \
|
|
|
|
: #major "." #minor ".0")
|
2014-02-11 19:31:53 +04:00
|
|
|
|
2013-01-05 15:13:49 +04:00
|
|
|
class cmTargetExport;
|
|
|
|
|
2008-01-28 16:38:36 +03: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 21:21:42 +03:00
|
|
|
cmExportFileGenerator();
|
2008-01-28 17:53:21 +03:00
|
|
|
virtual ~cmExportFileGenerator() {}
|
|
|
|
|
2008-01-28 16:38:36 +03:00
|
|
|
/** Set the full path to the export file to generate. */
|
|
|
|
void SetExportFile(const char* mainFile);
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* GetMainExportFileName() const;
|
2008-01-28 16:38:36 +03:00
|
|
|
|
|
|
|
/** Set the namespace in which to place exported target names. */
|
2014-02-22 04:05:55 +04:00
|
|
|
void SetNamespace(const std::string& ns) { this->Namespace = ns; }
|
2012-10-06 19:27:40 +04:00
|
|
|
std::string GetNamespace() const { return this->Namespace; }
|
2008-01-28 16:38:36 +03:00
|
|
|
|
2013-06-04 18:47:57 +04:00
|
|
|
void SetExportOld(bool exportOld) { this->ExportOld = exportOld; }
|
|
|
|
|
2008-01-28 16:38:36 +03:00
|
|
|
/** Add a configuration to be exported. */
|
2014-02-10 07:48:34 +04:00
|
|
|
void AddConfiguration(const std::string& config);
|
2008-01-28 16:38:36 +03:00
|
|
|
|
|
|
|
/** Actually generate the export file. Returns whether there was an
|
|
|
|
error. */
|
|
|
|
bool GenerateImportFile();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
protected:
|
2014-02-10 09:21:34 +04:00
|
|
|
typedef std::map<std::string, std::string> ImportPropertyMap;
|
2008-01-28 16:38:36 +03:00
|
|
|
|
|
|
|
// Generate per-configuration target information to the given output
|
|
|
|
// stream.
|
2014-02-10 07:48:34 +04:00
|
|
|
void GenerateImportConfig(std::ostream& os, const std::string& config,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<std::string>& missingTargets);
|
2008-01-28 16:38:36 +03:00
|
|
|
|
|
|
|
// Methods to implement export file code generation.
|
2016-07-12 20:26:55 +03:00
|
|
|
virtual void GeneratePolicyHeaderCode(std::ostream& os);
|
|
|
|
virtual void GeneratePolicyFooterCode(std::ostream& os);
|
|
|
|
virtual void GenerateImportHeaderCode(std::ostream& os,
|
|
|
|
const std::string& config = "");
|
|
|
|
virtual void GenerateImportFooterCode(std::ostream& os);
|
2008-01-28 16:38:36 +03:00
|
|
|
void GenerateImportVersionCode(std::ostream& os);
|
2016-07-12 20:26:55 +03:00
|
|
|
virtual void GenerateImportTargetCode(std::ostream& os,
|
|
|
|
cmGeneratorTarget const* target);
|
|
|
|
virtual void GenerateImportPropertyCode(std::ostream& os,
|
|
|
|
const std::string& config,
|
|
|
|
cmGeneratorTarget const* target,
|
|
|
|
ImportPropertyMap const& properties);
|
|
|
|
virtual void GenerateImportedFileChecksCode(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::ostream& os, cmGeneratorTarget* target,
|
|
|
|
ImportPropertyMap const& properties,
|
|
|
|
const std::set<std::string>& importedLocations);
|
2016-07-12 20:26:55 +03:00
|
|
|
virtual void GenerateImportedFileCheckLoop(std::ostream& os);
|
|
|
|
virtual void GenerateMissingTargetsCheckCode(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::ostream& os, const std::vector<std::string>& missingTargets);
|
2011-11-12 21:12:07 +04:00
|
|
|
|
2016-07-12 20:26:55 +03:00
|
|
|
virtual void GenerateExpectedTargetsCode(std::ostream& os,
|
|
|
|
const std::string& expectedTargets);
|
2008-01-28 16:38:36 +03:00
|
|
|
|
|
|
|
// Collect properties with detailed information about targets beyond
|
|
|
|
// their location on disk.
|
2014-02-10 07:48:34 +04:00
|
|
|
void SetImportDetailProperties(const std::string& config,
|
2012-10-06 19:51:07 +04:00
|
|
|
std::string const& suffix,
|
|
|
|
cmGeneratorTarget* target,
|
2012-09-16 00:38:30 +04:00
|
|
|
ImportPropertyMap& properties,
|
|
|
|
std::vector<std::string>& missingTargets);
|
2014-06-16 17:38:04 +04:00
|
|
|
|
|
|
|
template <typename T>
|
2008-01-31 23:45:31 +03:00
|
|
|
void SetImportLinkProperty(std::string const& suffix,
|
2012-10-06 19:51:07 +04:00
|
|
|
cmGeneratorTarget* target,
|
|
|
|
const std::string& propName,
|
2014-06-16 17:38:04 +04:00
|
|
|
std::vector<T> const& entries,
|
2012-09-16 00:38:30 +04:00
|
|
|
ImportPropertyMap& properties,
|
|
|
|
std::vector<std::string>& missingTargets);
|
2008-01-28 16:38:36 +03: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. */
|
2016-05-16 17:34:04 +03:00
|
|
|
virtual void GenerateImportTargetsConfig(
|
|
|
|
std::ostream& os, const std::string& config, std::string const& suffix,
|
|
|
|
std::vector<std::string>& missingTargets) = 0;
|
2008-01-28 16:38:36 +03:00
|
|
|
|
2012-09-28 23:47:37 +04: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,
|
2015-10-17 16:05:46 +03:00
|
|
|
cmGeneratorTarget* depender,
|
|
|
|
cmGeneratorTarget* dependee) = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
void PopulateInterfaceProperty(const std::string&, cmGeneratorTarget* target,
|
2012-12-11 02:05:11 +04:00
|
|
|
cmGeneratorExpression::PreprocessContext,
|
2016-05-16 17:34:04 +03:00
|
|
|
ImportPropertyMap& properties,
|
|
|
|
std::vector<std::string>& missingTargets);
|
|
|
|
bool PopulateInterfaceLinkLibrariesProperty(
|
|
|
|
cmGeneratorTarget* target, cmGeneratorExpression::PreprocessContext,
|
|
|
|
ImportPropertyMap& properties, std::vector<std::string>& missingTargets);
|
2015-10-17 15:33:51 +03:00
|
|
|
void PopulateInterfaceProperty(const std::string& propName,
|
|
|
|
cmGeneratorTarget* target,
|
2016-05-16 17:34:04 +03:00
|
|
|
ImportPropertyMap& properties);
|
|
|
|
void PopulateCompatibleInterfaceProperties(cmGeneratorTarget* target,
|
|
|
|
ImportPropertyMap& properties);
|
2016-07-12 20:26:55 +03:00
|
|
|
virtual void GenerateInterfaceProperties(
|
|
|
|
cmGeneratorTarget const* target, std::ostream& os,
|
|
|
|
const ImportPropertyMap& properties);
|
2013-03-25 00:18:17 +04:00
|
|
|
void PopulateIncludeDirectoriesInterface(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmTargetExport* target,
|
|
|
|
cmGeneratorExpression::PreprocessContext preprocessRule,
|
|
|
|
ImportPropertyMap& properties, std::vector<std::string>& missingTargets);
|
2014-11-28 20:58:38 +03:00
|
|
|
void PopulateSourcesInterface(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmTargetExport* target,
|
|
|
|
cmGeneratorExpression::PreprocessContext preprocessRule,
|
|
|
|
ImportPropertyMap& properties, std::vector<std::string>& missingTargets);
|
|
|
|
|
|
|
|
void SetImportLinkInterface(
|
|
|
|
const std::string& config, std::string const& suffix,
|
|
|
|
cmGeneratorExpression::PreprocessContext preprocessRule,
|
|
|
|
cmGeneratorTarget* target, ImportPropertyMap& properties,
|
|
|
|
std::vector<std::string>& missingTargets);
|
|
|
|
|
|
|
|
enum FreeTargetsReplace
|
|
|
|
{
|
2013-01-04 18:56:13 +04:00
|
|
|
ReplaceFreeTargets,
|
|
|
|
NoReplaceFreeTargets
|
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void ResolveTargetsInGeneratorExpressions(
|
|
|
|
std::string& input, cmGeneratorTarget* target,
|
|
|
|
std::vector<std::string>& missingTargets,
|
|
|
|
FreeTargetsReplace replace = NoReplaceFreeTargets);
|
2012-12-11 02:07:09 +04:00
|
|
|
|
2016-07-12 20:26:55 +03:00
|
|
|
virtual void GenerateRequiredCMakeVersion(std::ostream& os,
|
|
|
|
const char* versionString);
|
2013-06-04 18:47:57 +04:00
|
|
|
|
2008-01-28 16:38:36 +03:00
|
|
|
// The namespace in which the exports are placed in the generated file.
|
|
|
|
std::string Namespace;
|
|
|
|
|
2013-06-04 18:47:57 +04:00
|
|
|
bool ExportOld;
|
|
|
|
|
2008-01-28 16:38:36 +03: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 21:21:42 +03:00
|
|
|
bool AppendMode;
|
2008-01-28 16:38:36 +03:00
|
|
|
|
|
|
|
// The set of targets included in the export.
|
2015-10-17 15:33:51 +03:00
|
|
|
std::set<cmGeneratorTarget*> ExportedTargets;
|
2012-12-11 02:05:11 +04:00
|
|
|
|
|
|
|
private:
|
2014-02-05 01:06:56 +04:00
|
|
|
void PopulateInterfaceProperty(const std::string&, const std::string&,
|
2015-10-17 15:33:51 +03:00
|
|
|
cmGeneratorTarget* target,
|
2012-12-11 02:05:11 +04:00
|
|
|
cmGeneratorExpression::PreprocessContext,
|
2016-05-16 17:34:04 +03:00
|
|
|
ImportPropertyMap& properties,
|
|
|
|
std::vector<std::string>& missingTargets);
|
2013-01-08 23:58:33 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool AddTargetNamespace(std::string& input, cmGeneratorTarget* target,
|
|
|
|
std::vector<std::string>& missingTargets);
|
2013-01-08 23:58:33 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void ResolveTargetsInGeneratorExpression(
|
|
|
|
std::string& input, cmGeneratorTarget* target,
|
|
|
|
std::vector<std::string>& missingTargets);
|
2013-01-27 12:43:44 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
virtual void ReplaceInstallPrefix(std::string& input);
|
2013-05-21 02:57:58 +04:00
|
|
|
|
2015-08-04 20:19:47 +03:00
|
|
|
virtual std::string InstallNameDir(cmGeneratorTarget* target,
|
2013-05-21 02:57:58 +04:00
|
|
|
const std::string& config) = 0;
|
2008-01-28 16:38:36 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|