summaryrefslogtreecommitdiffstats
path: root/Source/cmExportFileGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-01-28 18:21:42 (GMT)
committerBrad King <brad.king@kitware.com>2008-01-28 18:21:42 (GMT)
commit6388ebceb12e8eca3ce0e30528f0edaa990c8f7a (patch)
tree93706ecc2ed10615acdbf78216e3d4bd49389b53 /Source/cmExportFileGenerator.cxx
parent611bff2c1b8a0ce533d92662504a391c9e3d494b (diff)
downloadCMake-6388ebceb12e8eca3ce0e30528f0edaa990c8f7a.zip
CMake-6388ebceb12e8eca3ce0e30528f0edaa990c8f7a.tar.gz
CMake-6388ebceb12e8eca3ce0e30528f0edaa990c8f7a.tar.bz2
ENH: Restored APPEND option to EXPORT() command in new implementation.
Diffstat (limited to 'Source/cmExportFileGenerator.cxx')
-rw-r--r--Source/cmExportFileGenerator.cxx29
1 files changed, 26 insertions, 3 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 2c916e5..dd0c33a 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -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 @@ void cmExportFileGenerator::SetExportFile(const char* mainFile)
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 @@ bool cmExportFileGenerator::GenerateImportFile()
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);