[cmake-commits] king committed cmExportBuildFileGenerator.h 1.1 1.2
cmExportCommand.cxx 1.8 1.9 cmExportCommand.h 1.7 1.8
cmExportFileGenerator.cxx 1.2 1.3 cmExportFileGenerator.h 1.2 1.3
cmake-commits at cmake.org
cmake-commits at cmake.org
Mon Jan 28 13:21:44 EST 2008
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv12494/Source
Modified Files:
cmExportBuildFileGenerator.h cmExportCommand.cxx
cmExportCommand.h cmExportFileGenerator.cxx
cmExportFileGenerator.h
Log Message:
ENH: Restored APPEND option to EXPORT() command in new implementation.
Index: cmExportBuildFileGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExportBuildFileGenerator.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cmExportBuildFileGenerator.h 28 Jan 2008 13:38:35 -0000 1.1
+++ cmExportBuildFileGenerator.h 28 Jan 2008 18:21:42 -0000 1.2
@@ -35,6 +35,8 @@
void SetExports(std::vector<cmTarget*> const* exports)
{ this->Exports = exports; }
+ /** Set whether to append generated code to the output file. */
+ void SetAppendMode(bool append) { this->AppendMode = append; }
protected:
// Implement virtual methods from the superclass.
virtual bool GenerateMainFile(std::ostream& os);
Index: cmExportFileGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExportFileGenerator.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cmExportFileGenerator.h 28 Jan 2008 14:53:21 -0000 1.2
+++ cmExportFileGenerator.h 28 Jan 2008 18:21:42 -0000 1.3
@@ -30,6 +30,7 @@
class cmExportFileGenerator
{
public:
+ cmExportFileGenerator();
virtual ~cmExportFileGenerator() {}
/** Set the full path to the export file to generate. */
@@ -90,6 +91,7 @@
std::string FileDir;
std::string FileBase;
std::string FileExt;
+ bool AppendMode;
// The set of targets included in the export.
std::set<cmTarget*> ExportedTargets;
Index: cmExportCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExportCommand.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- cmExportCommand.cxx 28 Jan 2008 13:38:35 -0000 1.8
+++ cmExportCommand.cxx 28 Jan 2008 18:21:42 -0000 1.9
@@ -26,6 +26,7 @@
:cmCommand()
,ArgumentGroup()
,Targets(&Helper, "TARGETS")
+,Append(&Helper, "APPEND", &ArgumentGroup)
,Namespace(&Helper, "NAMESPACE", &ArgumentGroup)
,Filename(&Helper, "FILE", &ArgumentGroup)
{
@@ -146,6 +147,7 @@
cmExportBuildFileGenerator ebfg;
ebfg.SetExportFile(fname.c_str());
ebfg.SetNamespace(this->Namespace.GetCString());
+ ebfg.SetAppendMode(this->Append.IsEnabled());
ebfg.SetExports(&targets);
// Compute the set of configurations exported.
Index: cmExportCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExportCommand.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- cmExportCommand.h 28 Jan 2008 13:38:35 -0000 1.7
+++ cmExportCommand.h 28 Jan 2008 18:21:42 -0000 1.8
@@ -65,7 +65,7 @@
{
return
" export(TARGETS [target1 [target2 [...]]] [NAMESPACE <namespace>]\n"
- " FILE <filename>)\n"
+ " [APPEND] FILE <filename>)\n"
"Create a file <filename> that may be included by outside projects to "
"import targets from the current project's build tree. "
"This is useful during cross-compiling to build utility executables "
@@ -73,6 +73,8 @@
"them into another project being compiled for the target platform. "
"If the NAMESPACE option is given the <namespace> string will be "
"prepended to all target names written to the file. "
+ "If the APPEND option is given the generated code will be appended "
+ "to the file instead of overwriting it. "
"If a library target is included in the export but "
"a target to which it links is not included the behavior is "
"unspecified."
@@ -88,6 +90,7 @@
private:
cmCommandArgumentGroup ArgumentGroup;
cmCAStringVector Targets;
+ cmCAEnabler Append;
cmCAString Namespace;
cmCAString Filename;
};
Index: cmExportFileGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExportFileGenerator.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cmExportFileGenerator.cxx 28 Jan 2008 18:05:58 -0000 1.2
+++ cmExportFileGenerator.cxx 28 Jan 2008 18:21:42 -0000 1.3
@@ -21,6 +21,14 @@
#include "cmSystemTools.h"
#include "cmTarget.h"
+#include <cmsys/auto_ptr.hxx>
+
+//----------------------------------------------------------------------------
+cmExportFileGenerator::cmExportFileGenerator()
+{
+ this->AppendMode = false;
+}
+
//----------------------------------------------------------------------------
void cmExportFileGenerator::AddConfiguration(const char* config)
{
@@ -43,8 +51,23 @@
bool cmExportFileGenerator::GenerateImportFile()
{
// Open the output file to generate it.
- cmGeneratedFileStream exportFileStream(this->MainImportFile.c_str(), true);
- if(!exportFileStream)
+ cmsys::auto_ptr<std::ofstream> foutPtr;
+ if(this->AppendMode)
+ {
+ // Open for append.
+ cmsys::auto_ptr<std::ofstream>
+ ap(new std::ofstream(this->MainImportFile.c_str(), std::ios::app));
+ foutPtr = ap;
+ }
+ else
+ {
+ // Generate atomically and with copy-if-different.
+ cmsys::auto_ptr<cmGeneratedFileStream>
+ ap(new cmGeneratedFileStream(this->MainImportFile.c_str(), true));
+ ap->SetCopyIfDifferent(true);
+ foutPtr = ap;
+ }
+ if(!foutPtr.get() || !*foutPtr)
{
std::string se = cmSystemTools::GetLastSystemError();
cmOStringStream e;
@@ -53,7 +76,7 @@
cmSystemTools::Error(e.str().c_str());
return false;
}
- std::ostream& os = exportFileStream;
+ std::ostream& os = *foutPtr;
// Start with the import file header.
this->GenerateImportHeaderCode(os);
More information about the Cmake-commits
mailing list