mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
ENH: Restored APPEND option to EXPORT() command in new implementation.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user