Commit 6e8aeba4 authored by Brad King's avatar Brad King
Browse files

Teach configure_file to handle directory names

This commit teaches configure_file how to handle directories for input
and output.  It is an error if the input is a directory.  If the output
is a directory we put the configured copy of the input file in it with
the same name.  See issue #9537.
parent 700cdf39
......@@ -36,6 +36,17 @@ bool cmConfigureFileCommand
this->InputFile += inFile;
// If the input location is a directory, error out.
cmOStringStream e;
e << "input location\n"
<< " " << this->InputFile << "\n"
<< "is a directory but a file was expected.";
return false;
const char* outFile = args[1].c_str();
......@@ -44,6 +55,13 @@ bool cmConfigureFileCommand
this->OutputFile += outFile;
// If the output location is already a directory put the file in it.
this->OutputFile += "/";
this->OutputFile += cmSystemTools::GetFilenameName(inFile);
if ( !this->Makefile->CanIWriteThisFile(this->OutputFile.c_str()) )
std::string e = "attempted to configure a file: " + this->OutputFile
......@@ -66,8 +66,11 @@ public:
"values referenced in the file content. "
"If <input> is a relative path it is evaluated with respect to "
"the current source directory. "
"The <input> must be a file, not a directory. "
"If <output> is a relative path it is evaluated with respect to "
"the current binary directory. "
"If <output> names an existing directory the input file is placed "
"in that directory with its original name. "
"This command replaces any variables in the input file referenced as "
"${VAR} or @VAR@ with their values as determined by CMake. If a "
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment