[cmake-commits] king committed cmAddCustomCommandCommand.cxx 1.31 1.32 cmAddCustomCommandCommand.h 1.23 1.24 cmAddCustomTargetCommand.cxx 1.22 1.23 cmAddCustomTargetCommand.h 1.18 1.19 cmMakefile.cxx 1.352 1.353 cmMakefile.h 1.190 1.191

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Sep 28 11:30:50 EDT 2006


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

Modified Files:
	cmAddCustomCommandCommand.cxx cmAddCustomCommandCommand.h 
	cmAddCustomTargetCommand.cxx cmAddCustomTargetCommand.h 
	cmMakefile.cxx cmMakefile.h 
Log Message:
ENH: Added VERBATIM option to ADD_CUSTOM_COMMAND and ADD_CUSTOM_TARGET commands.  This option enables full escaping of custom command arguments on all platforms.  See bug#3786.


Index: cmAddCustomTargetCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAddCustomTargetCommand.cxx,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cmAddCustomTargetCommand.cxx	13 Sep 2006 15:39:46 -0000	1.22
+++ cmAddCustomTargetCommand.cxx	28 Sep 2006 15:30:46 -0000	1.23
@@ -58,12 +58,14 @@
   // Accumulate dependencies.
   std::vector<std::string> depends;
   std::string working_directory;
+  bool verbatim = false;
 
   // Keep track of parser state.
   enum tdoing {
     doing_command,
     doing_depends,
-    doing_working_directory
+    doing_working_directory,
+    doing_verbatim
   };
   tdoing doing = doing_command;
 
@@ -92,6 +94,11 @@
       {
       doing = doing_working_directory;
       }
+    else if(copy == "VERBATIM")
+      {
+      doing = doing_verbatim;
+      verbatim = true;
+      }
     else if(copy == "COMMAND")
       {
       doing = doing_command;
@@ -141,10 +148,11 @@
     }
 
   // Add the utility target to the makefile.
+  bool escapeOldStyle = !verbatim;
   const char* no_output = 0;
   this->Makefile->AddUtilityCommand(args[0].c_str(), all, no_output,
                                     working_directory.c_str(), depends,
-                                    commandLines);
+                                    commandLines, escapeOldStyle);
 
   return true;
 }

Index: cmAddCustomTargetCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAddCustomTargetCommand.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- cmAddCustomTargetCommand.h	18 Aug 2006 12:57:17 -0000	1.18
+++ cmAddCustomTargetCommand.h	28 Sep 2006 15:30:46 -0000	1.19
@@ -65,8 +65,8 @@
     return
       "  ADD_CUSTOM_TARGET(Name [ALL] [command1 [args1...]]\n"
       "                    [COMMAND command2 [args2...] ...]\n"
-      "                    [DEPENDS depend depend depend ... ])\n"
-      "                    [WORKING_DIRECTORY dir]\n"
+      "                    [DEPENDS depend depend depend ... ]\n"
+      "                    [WORKING_DIRECTORY dir] [VERBATIM])\n"
       "Adds a target with the given name that executes the given commands. "
       "The target has no output file and is ALWAYS CONSIDERED OUT OF DATE "
       "even if the commands try to create a file with the name of the "
@@ -82,7 +82,15 @@
       "If WORKING_DIRECTORY is set, then the command will be run in that "
       "directory. "
       "Dependencies listed with the DEPENDS argument may reference files "
-      "and outputs of custom commands created with ADD_CUSTOM_COMMAND.";
+      "and outputs of custom commands created with ADD_CUSTOM_COMMAND.\n"
+      "If VERBATIM is given then all the arguments to the commands will be "
+      "passed exactly as specified no matter the build tool used. "
+      "Note that one level of escapes is still used by the CMake language "
+      "processor before ADD_CUSTOM_TARGET even sees the arguments. "
+      "Use of VERBATIM is recommended as it enables correct behavior. "
+      "When VERBATIM is not given the behavior is platform specific. "
+      "In the future VERBATIM may be enabled by default. The only reason "
+      "it is an option is to preserve compatibility with older CMake code.";
     }
   
   cmTypeMacro(cmAddCustomTargetCommand, cmCommand);

Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.190
retrieving revision 1.191
diff -u -d -r1.190 -r1.191
--- cmMakefile.h	9 Jul 2006 17:19:36 -0000	1.190
+++ cmMakefile.h	28 Sep 2006 15:30:47 -0000	1.191
@@ -143,19 +143,22 @@
                                 const std::vector<std::string>& depends,
                                 const cmCustomCommandLines& commandLines,
                                 cmTarget::CustomCommandType type,
-                                const char* comment, const char* workingDir);
+                                const char* comment, const char* workingDir,
+                                bool escapeOldStyle = true);
   void AddCustomCommandToOutput(const std::vector<std::string>& outputs,
                                 const std::vector<std::string>& depends,
                                 const char* main_dependency,
                                 const cmCustomCommandLines& commandLines,
                                 const char* comment, const char* workingDir,
-                                bool replace = false);
+                                bool replace = false,
+                                bool escapeOldStyle = true);
   void AddCustomCommandToOutput(const char* output,
                                 const std::vector<std::string>& depends,
                                 const char* main_dependency,
                                 const cmCustomCommandLines& commandLines,
                                 const char* comment, const char* workingDir,
-                                bool replace = false);
+                                bool replace = false,
+                                bool escapeOldStyle = true);
   void AddCustomCommandOldStyle(const char* target,
                                 const std::vector<std::string>& outputs,
                                 const std::vector<std::string>& depends,
@@ -192,7 +195,8 @@
                          const char* output,
                          const char* workingDirectory,
                          const std::vector<std::string>& depends,
-                         const cmCustomCommandLines& commandLines);
+                         const cmCustomCommandLines& commandLines,
+                         bool escapeOldStyle = true);
 
   /**
    * Add a link library to the build.

Index: cmAddCustomCommandCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAddCustomCommandCommand.cxx,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- cmAddCustomCommandCommand.cxx	11 Apr 2006 15:06:18 -0000	1.31
+++ cmAddCustomCommandCommand.cxx	28 Sep 2006 15:30:46 -0000	1.32
@@ -35,6 +35,7 @@
   std::string source, target, comment, main_dependency,
     working;
   std::vector<std::string> depends, outputs, output;
+  bool verbatim = false;
 
   // Accumulate one command line at a time.
   cmCustomCommandLine currentLine;
@@ -90,6 +91,10 @@
       {
       cctype = cmTarget::POST_BUILD;
       }
+    else if(copy == "VERBATIM")
+      {
+      verbatim = true;
+      }
     else if(copy == "TARGET")
       {
       doing = doing_target;
@@ -211,28 +216,31 @@
     }
 
   // Choose which mode of the command to use.
+  bool escapeOldStyle = !verbatim;
   if(source.empty() && output.empty())
     {
     // Source is empty, use the target.
     std::vector<std::string> no_depends;
     this->Makefile->AddCustomCommandToTarget(target.c_str(), no_depends,
-                                         commandLines, cctype,
-                                         comment.c_str(), working.c_str());
+                                             commandLines, cctype,
+                                             comment.c_str(), working.c_str(),
+                                             escapeOldStyle);
     }
   else if(target.empty())
     {
     // Target is empty, use the output.
     this->Makefile->AddCustomCommandToOutput(output, depends,
-                                         main_dependency.c_str(),
-                                         commandLines, comment.c_str(),
-                                         working.c_str());
+                                             main_dependency.c_str(),
+                                             commandLines, comment.c_str(),
+                                             working.c_str(), false,
+                                             escapeOldStyle);
     }
   else
     {
     // Use the old-style mode for backward compatibility.
     this->Makefile->AddCustomCommandOldStyle(target.c_str(), outputs, depends,
-                                         source.c_str(), commandLines,
-                                         comment.c_str());
+                                             source.c_str(), commandLines,
+                                             comment.c_str());
     }
   return true;
 }

Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.352
retrieving revision 1.353
diff -u -d -r1.352 -r1.353
--- cmMakefile.cxx	26 Aug 2006 18:43:08 -0000	1.352
+++ cmMakefile.cxx	28 Sep 2006 15:30:46 -0000	1.353
@@ -554,7 +554,8 @@
                                      const cmCustomCommandLines& commandLines,
                                      cmTarget::CustomCommandType type,
                                      const char* comment,
-                                     const char* workingDir)
+                                     const char* workingDir,
+                                     bool escapeOldStyle)
 {
   // Find the target to which to add the custom command.
   cmTargets::iterator ti = this->Targets.find(target);
@@ -563,6 +564,7 @@
     // Add the command to the appropriate build step for the target.
     std::vector<std::string> no_output;
     cmCustomCommand cc(no_output, depends, commandLines, comment, workingDir);
+    cc.SetEscapeOldStyle(escapeOldStyle);
     switch(type)
       {
       case cmTarget::PRE_BUILD:
@@ -598,7 +600,8 @@
                                      const cmCustomCommandLines& commandLines,
                                      const char* comment,
                                      const char* workingDir,
-                                     bool replace)
+                                     bool replace,
+                                     bool escapeOldStyle)
 {
   // Make sure there is at least one output.
   if(outputs.empty())
@@ -686,6 +689,7 @@
     cmCustomCommand* cc =
       new cmCustomCommand(outputs, depends2, commandLines,
                           comment, workingDir);
+    cc->SetEscapeOldStyle(escapeOldStyle);
     file->SetCustomCommand(cc);
     }
 }
@@ -698,13 +702,14 @@
                                      const cmCustomCommandLines& commandLines,
                                      const char* comment,
                                      const char* workingDir,
-                                     bool replace)
+                                     bool replace,
+                                     bool escapeOldStyle)
 {
   std::vector<std::string> outputs;
   outputs.push_back(output);
   this->AddCustomCommandToOutput(outputs, depends, main_dependency,
                                  commandLines, comment, workingDir,
-                                 replace);
+                                 replace, escapeOldStyle);
 }
 
 //----------------------------------------------------------------------------
@@ -819,7 +824,8 @@
                                    const char* output,
                                    const char* workingDirectory,
                                    const std::vector<std::string>& depends,
-                                   const cmCustomCommandLines& commandLines)
+                                   const cmCustomCommandLines& commandLines,
+                                   bool escapeOldStyle)
 {
   // Create a target instance for this utility.
   cmTarget target;
@@ -833,6 +839,7 @@
     outputs.push_back(output);
     }
   cmCustomCommand cc(outputs, depends, commandLines, 0, workingDirectory);
+  cc.SetEscapeOldStyle(escapeOldStyle);
   target.GetPostBuildCommands().push_back(cc);
 
   // Add the target to the set of targets.

Index: cmAddCustomCommandCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAddCustomCommandCommand.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- cmAddCustomCommandCommand.h	15 Jun 2006 14:51:41 -0000	1.23
+++ cmAddCustomCommandCommand.h	28 Sep 2006 15:30:46 -0000	1.24
@@ -72,7 +72,7 @@
       "                     [MAIN_DEPENDENCY depend]\n"
       "                     [DEPENDS [depends...]]\n"
       "                     [WORKING_DIRECTORY dir]\n"
-      "                     [COMMENT comment])\n"
+      "                     [COMMENT comment] [VERBATIM])\n"
       "This defines a new command that can be executed during the build "
       "process. The outputs named should be listed as source files in the "
       "target for which they are to be generated. "
@@ -93,7 +93,7 @@
       "                     COMMAND command1 [ARGS] [args1...]\n"
       "                     [COMMAND command2 [ARGS] [args2...] ...]\n"
       "                     [WORKING_DIRECTORY dir]\n"
-      "                     [COMMENT comment])\n"
+      "                     [COMMENT comment] [VERBATIM])\n"
       "This defines a new command that will be associated with "
       "building the specified target. When the command will "
       "happen is determined by which of the following is specified:\n"
@@ -104,7 +104,15 @@
       "Studio 7 or later. For all other generators PRE_BUILD "
       "will be treated as PRE_LINK. "
       "If WORKING_DIRECTORY is specified the command will be executed "
-      "in the directory given.";
+      "in the directory given.\n"
+      "If VERBATIM is given then all the arguments to the commands will be "
+      "passed exactly as specified no matter the build tool used. "
+      "Note that one level of escapes is still used by the CMake language "
+      "processor before ADD_CUSTOM_TARGET even sees the arguments. "
+      "Use of VERBATIM is recommended as it enables correct behavior. "
+      "When VERBATIM is not given the behavior is platform specific. "
+      "In the future VERBATIM may be enabled by default. The only reason "
+      "it is an option is to preserve compatibility with older CMake code.";
     }
   
   cmTypeMacro(cmAddCustomCommandCommand, cmCommand);



More information about the Cmake-commits mailing list