diff options
author | Brad King <brad.king@kitware.com> | 2004-03-15 15:44:53 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2004-03-15 15:44:53 (GMT) |
commit | 7b6491d36b5a6c0981e61d16f224119f21f02b58 (patch) | |
tree | c1ada6796f9e8cd0f1d23695e45d2e4e90c70c4e /Source/cmExportLibraryDependencies.cxx | |
parent | bf9dce6eb90282a9355a85789882372622798f6c (diff) | |
download | CMake-7b6491d36b5a6c0981e61d16f224119f21f02b58.zip CMake-7b6491d36b5a6c0981e61d16f224119f21f02b58.tar.gz CMake-7b6491d36b5a6c0981e61d16f224119f21f02b58.tar.bz2 |
BUG#675: If not appending, do copy-if-different on exported file.
Diffstat (limited to 'Source/cmExportLibraryDependencies.cxx')
-rw-r--r-- | Source/cmExportLibraryDependencies.cxx | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/Source/cmExportLibraryDependencies.cxx b/Source/cmExportLibraryDependencies.cxx index e73280f..b637f85 100644 --- a/Source/cmExportLibraryDependencies.cxx +++ b/Source/cmExportLibraryDependencies.cxx @@ -17,6 +17,7 @@ #include "cmExportLibraryDependencies.h" #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" +#include "cmGeneratedFileStream.h" #include "cmake.h" // cmExecutableCommand @@ -49,7 +50,7 @@ void cmExportLibraryDependenciesCommand::FinalPass() } - // Create a full path filename for output Testfile + // Create a full path filename for output std::string fname = m_Args[0]; bool append = false; if(m_Args.size() > 1) @@ -59,16 +60,23 @@ void cmExportLibraryDependenciesCommand::FinalPass() append = true; } } - // Open the output Testfile - std::ofstream fout; + + // Use copy-if-different if not appending. + std::ostream* foutPtr; + std::auto_ptr<cmGeneratedFileStream> foutNew; if(append) { - fout.open(fname.c_str(), std::ios::app); + foutPtr = new std::ofstream(fname.c_str(), std::ios::app); } else { - fout.open(fname.c_str()); + std::auto_ptr<cmGeneratedFileStream> ap( + new cmGeneratedFileStream(fname.c_str())); + foutNew = ap; + foutPtr = &foutNew->GetStream(); } + std::ostream& fout = *foutPtr; + if (!fout) { cmSystemTools::Error("Error Writing ", fname.c_str()); @@ -116,6 +124,5 @@ void cmExportLibraryDependenciesCommand::FinalPass() } } } - fout.close(); return; } |