diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmConfigureFileCommand.cxx | 18 | ||||
-rw-r--r-- | Source/cmConfigureFileCommand.h | 3 |
2 files changed, 21 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 diff --git a/Source/cmConfigureFileCommand.h b/Source/cmConfigureFileCommand.h index 58ce10a..da93ec9 100644 --- a/Source/cmConfigureFileCommand.h +++ b/Source/cmConfigureFileCommand.h @@ -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. " "\n" "This command replaces any variables in the input file referenced as " "${VAR} or @VAR@ with their values as determined by CMake. If a " |