summaryrefslogtreecommitdiffstats
path: root/Source/cmConfigureFileCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-09-16 19:09:42 (GMT)
committerBrad King <brad.king@kitware.com>2009-09-16 19:09:42 (GMT)
commit6e8aeba41502f128cf27457f333dc85f1fe66638 (patch)
treee2befb28d2d902d502f2b642d402353944cc5aeb /Source/cmConfigureFileCommand.cxx
parent700cdf393af6aec04917a190122d7d46a1ba720e (diff)
downloadCMake-6e8aeba41502f128cf27457f333dc85f1fe66638.zip
CMake-6e8aeba41502f128cf27457f333dc85f1fe66638.tar.gz
CMake-6e8aeba41502f128cf27457f333dc85f1fe66638.tar.bz2
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.
Diffstat (limited to 'Source/cmConfigureFileCommand.cxx')
-rw-r--r--Source/cmConfigureFileCommand.cxx18
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx
index 051fe28..d6f2b68 100644
--- a/Source/cmConfigureFileCommand.cxx
+++ b/Source/cmConfigureFileCommand.cxx
@@ -36,6 +36,17 @@ bool cmConfigureFileCommand
}
this->InputFile += inFile;
+ // If the input location is a directory, error out.
+ if(cmSystemTools::FileIsDirectory(this->InputFile.c_str()))
+ {
+ cmOStringStream e;
+ e << "input location\n"
+ << " " << this->InputFile << "\n"
+ << "is a directory but a file was expected.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+
const char* outFile = args[1].c_str();
if(!cmSystemTools::FileIsFullPath(outFile))
{
@@ -44,6 +55,13 @@ bool cmConfigureFileCommand
}
this->OutputFile += outFile;
+ // If the output location is already a directory put the file in it.
+ if(cmSystemTools::FileIsDirectory(this->OutputFile.c_str()))
+ {
+ 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