ENH: Added 'IMMEDIATE' option to CONFIGURE_FILE command to force file copy and configuration on the initial pass so that current variable values are used.
This commit is contained in:
parent
d76f84f70e
commit
9cce835900
@ -52,32 +52,42 @@ bool cmConfigureFileCommand::InitialPass(std::vector<std::string>& args)
|
|||||||
m_OuputFile = args[1];
|
m_OuputFile = args[1];
|
||||||
m_CopyOnly = false;
|
m_CopyOnly = false;
|
||||||
m_EscapeQuotes = false;
|
m_EscapeQuotes = false;
|
||||||
if(args.size() >= 3)
|
m_Immediate = false;
|
||||||
|
for(unsigned int i=2;i < args.size();++i)
|
||||||
{
|
{
|
||||||
if(args[2] == "COPYONLY")
|
if(args[i] == "COPYONLY")
|
||||||
{
|
{
|
||||||
m_CopyOnly = true;
|
m_CopyOnly = true;
|
||||||
}
|
}
|
||||||
if(args[2] == "ESCAPE_QUOTES")
|
else if(args[i] == "ESCAPE_QUOTES")
|
||||||
{
|
{
|
||||||
m_EscapeQuotes = true;
|
m_EscapeQuotes = true;
|
||||||
|
}
|
||||||
|
else if(args[i] == "IMMEDIATE")
|
||||||
|
{
|
||||||
|
m_Immediate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(args.size() >= 4)
|
|
||||||
{
|
// If we were told to copy the file immediately, then do it on the
|
||||||
if(args[3] == "COPYONLY")
|
// first pass (now).
|
||||||
{
|
if(m_Immediate)
|
||||||
m_CopyOnly = true;
|
{
|
||||||
}
|
this->ConfigureFile();
|
||||||
if(args[3] == "ESCAPE_QUOTES")
|
|
||||||
{
|
|
||||||
m_EscapeQuotes = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmConfigureFileCommand::FinalPass()
|
void cmConfigureFileCommand::FinalPass()
|
||||||
|
{
|
||||||
|
if(!m_Immediate)
|
||||||
|
{
|
||||||
|
this->ConfigureFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmConfigureFileCommand::ConfigureFile()
|
||||||
{
|
{
|
||||||
m_Makefile->ExpandVariablesInString(m_InputFile);
|
m_Makefile->ExpandVariablesInString(m_InputFile);
|
||||||
m_Makefile->ExpandVariablesInString(m_OuputFile);
|
m_Makefile->ExpandVariablesInString(m_OuputFile);
|
||||||
|
@ -77,26 +77,28 @@ public:
|
|||||||
virtual const char* GetFullDocumentation()
|
virtual const char* GetFullDocumentation()
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
"CONFIGURE_FILE(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES])\n"
|
"CONFIGURE_FILE(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [IMMEDIATE])\n"
|
||||||
"The Input and Ouput files have to have full paths.\n"
|
"The Input and Ouput files have to have full paths.\n"
|
||||||
"They can also use variables like CMAKE_BINARY_DIR,CMAKE_SOURCE_DIR. "
|
"They can also use variables like CMAKE_BINARY_DIR,CMAKE_SOURCE_DIR. "
|
||||||
"This command replaces any variables in the input file with their "
|
"This command replaces any variables in the input file with their "
|
||||||
"values as determined by CMake. If a variables in not defined, it "
|
"values as determined by CMake. If a variables in not defined, it "
|
||||||
"will be replaced with nothing. If COPYONLY is passed in, then "
|
"will be replaced with nothing. If COPYONLY is passed in, then "
|
||||||
"then no varible expansion will take place. If ESCAPE_QUOTES is "
|
"then no varible expansion will take place. If ESCAPE_QUOTES is "
|
||||||
"passed in then any substitued quotes will be C style escaped.";
|
"passed in then any substitued quotes will be C style escaped. "
|
||||||
|
"If IMMEDIATE is specified, then the file will be configured with "
|
||||||
|
"the current values of CMake variables instead of waiting until the "
|
||||||
|
"end of CMakeLists processing.";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the header files in this pass. This is so
|
|
||||||
* all varibles can be expaned.
|
|
||||||
*/
|
|
||||||
virtual void FinalPass();
|
virtual void FinalPass();
|
||||||
private:
|
private:
|
||||||
|
void ConfigureFile();
|
||||||
|
|
||||||
std::string m_InputFile;
|
std::string m_InputFile;
|
||||||
std::string m_OuputFile;
|
std::string m_OuputFile;
|
||||||
bool m_CopyOnly;
|
bool m_CopyOnly;
|
||||||
bool m_EscapeQuotes;
|
bool m_EscapeQuotes;
|
||||||
|
bool m_Immediate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user