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
|
|
|
|
|
|
|
|
#include "cmCommand.h"
|
2012-12-11 02:05:11 +04:00
|
|
|
#include "cmGeneratorExpression.h"
|
2008-01-28 16:38:36 +03:00
|
|
|
|
2014-02-11 19:31:53 +04:00
|
|
|
#include "cmVersion.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmVersionMacros.h"
|
2014-02-11 19:31:53 +04:00
|
|
|
|
|
|
|
#define STRINGIFY_HELPER(X) #X
|
|
|
|
#define STRINGIFY(X) STRINGIFY_HELPER(X)
|
|
|
|
|
2014-02-19 18:15:42 +04:00
|
|
|
#define DEVEL_CMAKE_VERSION(major, minor) ( \
|
|
|
|
CMake_VERSION_ENCODE(major, minor, 0) > \
|
|
|
|
CMake_VERSION_ENCODE(CMake_VERSION_MAJOR, CMake_VERSION_MINOR, 0) ? \
|
2014-02-11 19:31:53 +04:00
|
|
|
STRINGIFY(CMake_VERSION_MAJOR) "." STRINGIFY(CMake_VERSION_MINOR) "." \
|
2014-02-19 18:15:42 +04:00
|
|
|
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);
|
2012-10-06 19:27:40 +04: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();
|
|
|
|
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,
|
2013-01-13 12:44:52 +04:00
|
|
|
std::vector<std::string> &missingTargets);
|
2008-01-28 16:38:36 +03:00
|
|
|
|
|
|
|
// Methods to implement export file code generation.
|
2014-02-10 07:48:34 +04:00
|
|
|
void GenerateImportHeaderCode(std::ostream& os,
|
|
|
|
const std::string& config = "");
|
2008-01-28 16:38:36 +03:00
|
|
|
void GenerateImportFooterCode(std::ostream& os);
|
|
|
|
void GenerateImportVersionCode(std::ostream& os);
|
2015-10-17 15:33:51 +03:00
|
|
|
void GenerateImportTargetCode(std::ostream& os,
|
|
|
|
cmGeneratorTarget const* target);
|
2014-02-10 07:48:34 +04:00
|
|
|
void GenerateImportPropertyCode(std::ostream& os, const std::string& config,
|
2015-10-17 16:10:32 +03:00
|
|
|
cmGeneratorTarget const* target,
|
2008-01-28 16:38:36 +03:00
|
|
|
ImportPropertyMap const& properties);
|
2015-10-17 16:10:32 +03:00
|
|
|
void GenerateImportedFileChecksCode(std::ostream& os,
|
|
|
|
cmGeneratorTarget* target,
|
2011-11-12 21:12:07 +04:00
|
|
|
ImportPropertyMap const& properties,
|
|
|
|
const std::set<std::string>& importedLocations);
|
|
|
|
void GenerateImportedFileCheckLoop(std::ostream& os);
|
2012-09-16 00:38:30 +04:00
|
|
|
void GenerateMissingTargetsCheckCode(std::ostream& os,
|
|
|
|
const std::vector<std::string>& missingTargets);
|
2011-11-12 21:12:07 +04:00
|
|
|
|
2012-11-30 12:26:09 +04:00
|
|
|
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. */
|
|
|
|
virtual void GenerateImportTargetsConfig(std::ostream& os,
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& config,
|
2013-01-13 12:44:52 +04:00
|
|
|
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;
|
2013-09-03 00:27:32 +04:00
|
|
|
void PopulateInterfaceProperty(const std::string&,
|
2015-10-17 15:33:51 +03:00
|
|
|
cmGeneratorTarget *target,
|
2012-12-11 02:05:11 +04:00
|
|
|
cmGeneratorExpression::PreprocessContext,
|
|
|
|
ImportPropertyMap &properties,
|
|
|
|
std::vector<std::string> &missingTargets);
|
2015-10-17 15:33:51 +03:00
|
|
|
bool PopulateInterfaceLinkLibrariesProperty(cmGeneratorTarget* target,
|
2013-06-04 18:47:57 +04:00
|
|
|
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,
|
2013-01-12 15:13:19 +04:00
|
|
|
ImportPropertyMap &properties);
|
2015-08-04 20:19:42 +03:00
|
|
|
void PopulateCompatibleInterfaceProperties(cmGeneratorTarget *target,
|
2013-01-20 20:09:29 +04:00
|
|
|
ImportPropertyMap &properties);
|
2015-10-17 15:33:51 +03:00
|
|
|
void GenerateInterfaceProperties(cmGeneratorTarget const* target,
|
|
|
|
std::ostream& os,
|
2012-12-11 02:05:11 +04:00
|
|
|
const ImportPropertyMap &properties);
|
2013-03-25 00:18:17 +04:00
|
|
|
void PopulateIncludeDirectoriesInterface(
|
2013-01-05 15:13:49 +04:00
|
|
|
cmTargetExport *target,
|
2013-03-25 00:18:17 +04:00
|
|
|
cmGeneratorExpression::PreprocessContext preprocessRule,
|
|
|
|
ImportPropertyMap &properties,
|
|
|
|
std::vector<std::string> &missingTargets);
|
2014-11-28 20:58:38 +03:00
|
|
|
void PopulateSourcesInterface(
|
|
|
|
cmTargetExport *target,
|
|
|
|
cmGeneratorExpression::PreprocessContext preprocessRule,
|
|
|
|
ImportPropertyMap &properties,
|
|
|
|
std::vector<std::string> &missingTargets);
|
2008-01-28 16:38:36 +03:00
|
|
|
|
2014-02-10 07:48:34 +04:00
|
|
|
void SetImportLinkInterface(const std::string& config,
|
|
|
|
std::string const& suffix,
|
2013-01-04 18:58:16 +04:00
|
|
|
cmGeneratorExpression::PreprocessContext preprocessRule,
|
2012-10-06 19:51:07 +04:00
|
|
|
cmGeneratorTarget* target, ImportPropertyMap& properties,
|
2013-01-04 18:58:16 +04:00
|
|
|
std::vector<std::string>& missingTargets);
|
2013-01-04 18:56:13 +04:00
|
|
|
|
|
|
|
enum FreeTargetsReplace {
|
|
|
|
ReplaceFreeTargets,
|
|
|
|
NoReplaceFreeTargets
|
|
|
|
};
|
|
|
|
|
2012-12-11 02:07:09 +04:00
|
|
|
void ResolveTargetsInGeneratorExpressions(std::string &input,
|
2015-10-17 15:33:51 +03:00
|
|
|
cmGeneratorTarget* target,
|
2013-01-04 18:56:13 +04:00
|
|
|
std::vector<std::string> &missingTargets,
|
|
|
|
FreeTargetsReplace replace = NoReplaceFreeTargets);
|
2012-12-11 02:07:09 +04:00
|
|
|
|
2013-06-04 18:47:57 +04:00
|
|
|
void GenerateRequiredCMakeVersion(std::ostream& os,
|
|
|
|
const char *versionString);
|
|
|
|
|
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,
|
|
|
|
ImportPropertyMap &properties,
|
|
|
|
std::vector<std::string> &missingTargets);
|
2013-01-08 23:58:33 +04:00
|
|
|
|
2015-10-17 15:33:51 +03:00
|
|
|
bool AddTargetNamespace(std::string &input, cmGeneratorTarget* target,
|
2013-01-08 23:58:33 +04:00
|
|
|
std::vector<std::string> &missingTargets);
|
|
|
|
|
2013-01-04 18:56:13 +04:00
|
|
|
void ResolveTargetsInGeneratorExpression(std::string &input,
|
2015-10-17 15:33:51 +03:00
|
|
|
cmGeneratorTarget* target,
|
2013-01-04 18:56:13 +04:00
|
|
|
std::vector<std::string> &missingTargets);
|
2013-01-27 12:43:44 +04: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
|