[Cmake-commits] [cmake-commits] king committed cmConfigureFileCommand.cxx 1.36 1.37 cmConfigureFileCommand.h 1.26 1.27

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Sep 16 15:09:44 EDT 2009


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv4525/Source

Modified Files:
	cmConfigureFileCommand.cxx cmConfigureFileCommand.h 
Log Message:
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.


Index: cmConfigureFileCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmConfigureFileCommand.cxx,v
retrieving revision 1.36
retrieving revision 1.37
diff -C 2 -d -r1.36 -r1.37
*** cmConfigureFileCommand.cxx	16 Sep 2009 19:09:29 -0000	1.36
--- cmConfigureFileCommand.cxx	16 Sep 2009 19:09:42 -0000	1.37
***************
*** 37,40 ****
--- 37,51 ----
    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))
***************
*** 45,48 ****
--- 56,66 ----
    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()) )
      {

Index: cmConfigureFileCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmConfigureFileCommand.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -C 2 -d -r1.26 -r1.27
*** cmConfigureFileCommand.h	16 Sep 2009 19:09:29 -0000	1.26
--- cmConfigureFileCommand.h	16 Sep 2009 19:09:42 -0000	1.27
***************
*** 67,72 ****
--- 67,75 ----
          "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 "



More information about the Cmake-commits mailing list