diff options
author | Brad King <brad.king@kitware.com> | 2008-01-28 13:38:36 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-01-28 13:38:36 (GMT) |
commit | 5594ad488576a77d9c6b8c3c1999a04fb4e6867d (patch) | |
tree | f22726476b6eaaf3832e48c185fe3c112601db17 /Source/cmExportFileGenerator.h | |
parent | a7cb9d1120c0555f1da67dd585bd1b4fd16d389d (diff) | |
download | CMake-5594ad488576a77d9c6b8c3c1999a04fb4e6867d.zip CMake-5594ad488576a77d9c6b8c3c1999a04fb4e6867d.tar.gz CMake-5594ad488576a77d9c6b8c3c1999a04fb4e6867d.tar.bz2 |
ENH: Updated exporting and importing of targets to support libraries and configurations.
- Created cmExportFileGenerator hierarchy to implement export file generation
- Installed exports use per-config import files loaded by a central one.
- Include soname of shared libraries in import information
- Renamed PREFIX to NAMESPACE in INSTALL(EXPORT) and EXPORT() commands
- Move addition of CMAKE_INSTALL_PREFIX to destinations to install generators
- Import files compute the installation prefix relative to their location when loaded
- Add mapping of importer configurations to importee configurations
- Rename IMPORT targets to IMPORTED targets to distinguish from windows import libraries
- Scope IMPORTED targets within directories to isolate them
- Place all properties created by import files in the IMPORTED namespace
- Document INSTALL(EXPORT) and EXPORT() commands.
- Document IMPORTED signature of add_executable and add_library
- Enable finding of imported targets in cmComputeLinkDepends
Diffstat (limited to 'Source/cmExportFileGenerator.h')
-rw-r--r-- | Source/cmExportFileGenerator.h | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h new file mode 100644 index 0000000..22592d7 --- /dev/null +++ b/Source/cmExportFileGenerator.h @@ -0,0 +1,96 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmExportFileGenerator_h +#define cmExportFileGenerator_h + +#include "cmCommand.h" + +/** \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: + /** 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; } + + /** 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. + void GenerateImportConfig(std::ostream& os, const char* config); + + // 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); + + // Collect properties with detailed information about targets beyond + // their location on disk. + void SetImportDetailProperties(const char* config, + std::string const& suffix, cmTarget* target, + ImportPropertyMap& properties); + + /** 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, + std::string const& suffix) = 0; + + /** Each subclass knows how to complain about a target that is + missing from an export set. */ + virtual void ComplainAboutMissingTarget(cmTarget*, const char* dep) = 0; + + // The namespace in which the exports are placed in the generated file. + std::string Namespace; + + // 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; + + // The set of targets included in the export. + std::set<cmTarget*> ExportedTargets; +}; + +#endif |