1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmConfigureFileCommand.cxx,v $
6 Date: $Date: 2008-03-07 20:30:33 $
7 Version: $Revision: 1.34 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmConfigureFileCommand.h"
19 #include <cmsys/RegularExpression.hxx>
21 // cmConfigureFileCommand
22 bool cmConfigureFileCommand
23 ::InitialPass(std::vector
<std::string
> const& args
, cmExecutionStatus
&)
27 this->SetError("called with incorrect number of arguments, expected 2");
30 this->InputFile
= args
[0];
31 this->OuputFile
= args
[1];
32 if ( !this->Makefile
->CanIWriteThisFile(this->OuputFile
.c_str()) )
34 std::string e
= "attempted to configure a file: " + this->OuputFile
35 + " into a source directory.";
36 this->SetError(e
.c_str());
37 cmSystemTools::SetFatalErrorOccured();
40 this->CopyOnly
= false;
41 this->EscapeQuotes
= false;
43 // for CMake 2.0 and earlier CONFIGURE_FILE defaults to the FinalPass,
44 // after 2.0 it only does InitialPass
45 this->Immediate
= !this->Makefile
->NeedBackwardsCompatibility(2,0);
48 for(unsigned int i
=2;i
< args
.size();++i
)
50 if(args
[i
] == "COPYONLY")
52 this->CopyOnly
= true;
54 else if(args
[i
] == "ESCAPE_QUOTES")
56 this->EscapeQuotes
= true;
58 else if(args
[i
] == "@ONLY")
62 else if(args
[i
] == "IMMEDIATE")
64 this->Immediate
= true;
68 // If we were told to copy the file immediately, then do it on the
72 if ( !this->ConfigureFile() )
74 this->SetError("Problem configuring file");
82 void cmConfigureFileCommand::FinalPass()
86 this->ConfigureFile();
90 int cmConfigureFileCommand::ConfigureFile()
92 std::string inFile
= this->InputFile
;
93 if (!cmSystemTools::FileIsFullPath(inFile
.c_str()))
95 inFile
= this->Makefile
->GetStartDirectory();
97 inFile
+= this->InputFile
;
99 return this->Makefile
->ConfigureFile(inFile
.c_str(),
100 this->OuputFile
.c_str(),