[Cmake-commits] CMake branch, master, updated. v3.11.0-rc1-37-g524696e

Kitware Robot kwrobot at kitware.com
Fri Feb 16 09:45:04 EST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, master has been updated
       via  524696ec1007408d5344ce08c1408a56be86b6eb (commit)
       via  e78e24f68cba269117ad5a321e1ec8503a5f1d29 (commit)
       via  602988e1e568048dd30e9e2213bc788f7c7ff708 (commit)
      from  d97c9ffb6c7189d5e617c1d69e8fe168e7813293 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=524696ec1007408d5344ce08c1408a56be86b6eb
commit 524696ec1007408d5344ce08c1408a56be86b6eb
Merge: d97c9ff e78e24f
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Feb 16 14:39:10 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Fri Feb 16 09:39:47 2018 -0500

    Merge topic 'file_cmd_touch'
    
    e78e24f6 Replaces execute_process calls to touch files with file(TOUCH) calls
    602988e1 Adds file(TOUCH) and file(TOUCH_NOCREATE) sub-commands
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1705


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e78e24f68cba269117ad5a321e1ec8503a5f1d29
commit e78e24f68cba269117ad5a321e1ec8503a5f1d29
Author:     Shane Parris <shane.lee.parris at gmail.com>
AuthorDate: Fri Jan 26 13:42:44 2018 -0500
Commit:     Shane Parris <shane.lee.parris at gmail.com>
CommitDate: Thu Feb 15 10:54:38 2018 -0500

    Replaces execute_process calls to touch files with file(TOUCH) calls

diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake
index 7331fb2..e5dbcd9 100644
--- a/Modules/ExternalData.cmake
+++ b/Modules/ExternalData.cmake
@@ -1133,7 +1133,7 @@ if("${ExternalData_ACTION}" STREQUAL "fetch")
 
   if(file_up_to_date)
     # Touch the file to convince the build system it is up to date.
-    execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${file}")
+    file(TOUCH "${file}")
   else()
     _ExternalData_link_or_copy("${obj}" "${file}")
   endif()
diff --git a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt
index 2e6a5bd..f9c52b7 100644
--- a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt
+++ b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt
@@ -45,8 +45,7 @@ file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}")
 # - Change a resource files listed in the .qrc file
 # - Rebuild
 execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
-execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resPlain/input.txt")
-execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resGen/input.txt")
+file(TOUCH "${rccDepBD}/resPlain/input.txt" "${rccDepBD}/resGen/input.txt")
 execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
 if (result)
   message(SEND_ERROR "Second build of rccDepends failed.")
@@ -97,8 +96,7 @@ file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}")
 # - Change a newly added resource files listed in the .qrc file
 # - Rebuild
 execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
-execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resPlain/inputAdded.txt")
-execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${rccDepBD}/resGen/inputAdded.txt")
+file(TOUCH "${rccDepBD}/resPlain/inputAdded.txt" "${rccDepBD}/resGen/inputAdded.txt")
 execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
 if (result)
   message(SEND_ERROR "Fourth build of rccDepends failed.")
diff --git a/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake b/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake
index 45766a0..96be54b 100644
--- a/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake
+++ b/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake
@@ -16,8 +16,7 @@ set(fileNames)
 foreach(e ${fileExtensions})
   set(currentFile "${CMAKE_CURRENT_BINARY_DIR}/foo.${e}")
   list(APPEND fileNames ${currentFile})
-  execute_process(COMMAND ${CMAKE_COMMAND} -E touch
-    "${currentFile}")
+  file(TOUCH "${currentFile}")
   string(TOUPPER ${e} eUC)
   set_source_files_properties("${currentFile}"
     PROPERTIES

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=602988e1e568048dd30e9e2213bc788f7c7ff708
commit 602988e1e568048dd30e9e2213bc788f7c7ff708
Author:     Shane Parris <shane.lee.parris at gmail.com>
AuthorDate: Fri Jan 26 13:42:35 2018 -0500
Commit:     Shane Parris <shane.lee.parris at gmail.com>
CommitDate: Thu Feb 15 10:54:18 2018 -0500

    Adds file(TOUCH) and file(TOUCH_NOCREATE) sub-commands

diff --git a/Help/command/file.rst b/Help/command/file.rst
index 5ce86e5..5e18077 100644
--- a/Help/command/file.rst
+++ b/Help/command/file.rst
@@ -285,6 +285,23 @@ If neither ``TLS`` option is given CMake will check variables
 
 ::
 
+  file(TOUCH [<files>...])
+  file(TOUCH_NOCREATE [<files>...])
+
+Create a file with no content if it does not yet exist. If the file already
+exists, its access and/or modification will be updated to the time when the
+function call is executed.
+
+Use TOUCH_NOCREATE to touch a file if it exists but not create it. If a file
+does not exist it will be silently ignored.
+
+With TOUCH and TOUCH_NOCREATE the contents of an existing file will not be
+modified.
+
+------------------------------------------------------------------------------
+
+::
+
   file(TIMESTAMP <filename> <variable> [<format>] [UTC])
 
 Compute a string representation of the modification time of ``<filename>``
diff --git a/Help/release/dev/file_cmd_touch.rst b/Help/release/dev/file_cmd_touch.rst
new file mode 100644
index 0000000..b1b1e3c
--- /dev/null
+++ b/Help/release/dev/file_cmd_touch.rst
@@ -0,0 +1,6 @@
+file_cmd_touch
+------------------
+
+* The :command:`file(TOUCH)` and :command:`file(TOUCH_NOCREATE)` commands
+  were added to expose TOUCH functionality without having to use CMake's
+  command-line tool mode with :command:`execute_process`.
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index d3dcc01..8492c17 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -160,6 +160,12 @@ bool cmFileCommand::InitialPass(std::vector<std::string> const& args,
   if (subCommand == "TO_NATIVE_PATH") {
     return this->HandleCMakePathCommand(args, true);
   }
+  if (subCommand == "TOUCH") {
+    return this->HandleTouchCommand(args, true);
+  }
+  if (subCommand == "TOUCH_NOCREATE") {
+    return this->HandleTouchCommand(args, false);
+  }
   if (subCommand == "TIMESTAMP") {
     return this->HandleTimestampCommand(args);
   }
@@ -905,6 +911,38 @@ bool cmFileCommand::HandleMakeDirectoryCommand(
   return true;
 }
 
+bool cmFileCommand::HandleTouchCommand(std::vector<std::string> const& args,
+                                       bool create)
+{
+  // File command has at least one argument
+  assert(args.size() > 1);
+
+  std::vector<std::string>::const_iterator i = args.begin();
+
+  i++; // Get rid of subcommand
+
+  for (; i != args.end(); ++i) {
+    std::string tfile = *i;
+    if (!cmsys::SystemTools::FileIsFullPath(tfile)) {
+      tfile = this->Makefile->GetCurrentSourceDirectory();
+      tfile += "/" + *i;
+    }
+    if (!this->Makefile->CanIWriteThisFile(tfile)) {
+      std::string e =
+        "attempted to touch a file: " + tfile + " in a source directory.";
+      this->SetError(e);
+      cmSystemTools::SetFatalErrorOccured();
+      return false;
+    }
+    if (!cmSystemTools::Touch(tfile, create)) {
+      std::string error = "problem touching file: " + tfile;
+      this->SetError(error);
+      return false;
+    }
+  }
+  return true;
+}
+
 bool cmFileCommand::HandleDifferentCommand(
   std::vector<std::string> const& args)
 {
diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h
index 17269f3..719dca2 100644
--- a/Source/cmFileCommand.h
+++ b/Source/cmFileCommand.h
@@ -39,6 +39,7 @@ protected:
   bool HandleHashCommand(std::vector<std::string> const& args);
   bool HandleStringsCommand(std::vector<std::string> const& args);
   bool HandleGlobCommand(std::vector<std::string> const& args, bool recurse);
+  bool HandleTouchCommand(std::vector<std::string> const& args, bool create);
   bool HandleMakeDirectoryCommand(std::vector<std::string> const& args);
 
   bool HandleRelativePathCommand(std::vector<std::string> const& args);
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 0988c3c..e7d92d4 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -689,8 +689,6 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
     // Touch file
     if (args[1] == "touch_nocreate" && args.size() > 2) {
       for (std::string::size_type cc = 2; cc < args.size(); cc++) {
-        // Complain if the file could not be removed, still exists,
-        // and the -f option was not given.
         if (!cmSystemTools::Touch(args[cc], false)) {
           return 1;
         }
diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake
index 3be4fb7..9a72333 100644
--- a/Tests/RunCMake/file/RunCMakeTest.cmake
+++ b/Tests/RunCMake/file/RunCMakeTest.cmake
@@ -5,6 +5,9 @@ run_cmake(DOWNLOAD-unused-argument)
 run_cmake(DOWNLOAD-httpheader-not-set)
 run_cmake(DOWNLOAD-netrc-bad)
 run_cmake(DOWNLOAD-pass-not-set)
+run_cmake(TOUCH)
+run_cmake(TOUCH-error-in-source-directory)
+run_cmake(TOUCH-error-missing-directory)
 run_cmake(UPLOAD-unused-argument)
 run_cmake(UPLOAD-httpheader-not-set)
 run_cmake(UPLOAD-netrc-bad)
diff --git a/Tests/RunCMake/file/TOUCH-error-in-source-directory-result.txt b/Tests/RunCMake/file/TOUCH-error-in-source-directory-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/file/TOUCH-error-in-source-directory-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/TOUCH-error-in-source-directory-stderr.txt b/Tests/RunCMake/file/TOUCH-error-in-source-directory-stderr.txt
new file mode 100644
index 0000000..f899c75
--- /dev/null
+++ b/Tests/RunCMake/file/TOUCH-error-in-source-directory-stderr.txt
@@ -0,0 +1 @@
+.*file attempted to touch a file:
diff --git a/Tests/RunCMake/file/TOUCH-error-in-source-directory.cmake b/Tests/RunCMake/file/TOUCH-error-in-source-directory.cmake
new file mode 100644
index 0000000..9aa7c56
--- /dev/null
+++ b/Tests/RunCMake/file/TOUCH-error-in-source-directory.cmake
@@ -0,0 +1,2 @@
+set(CMAKE_DISABLE_SOURCE_CHANGES ON)
+file(TOUCH "${CMAKE_CURRENT_SOURCE_DIR}/touch_test")
diff --git a/Tests/RunCMake/file/TOUCH-error-missing-directory-result.txt b/Tests/RunCMake/file/TOUCH-error-missing-directory-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/file/TOUCH-error-missing-directory-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/TOUCH-error-missing-directory-stderr.txt b/Tests/RunCMake/file/TOUCH-error-missing-directory-stderr.txt
new file mode 100644
index 0000000..f52e11a
--- /dev/null
+++ b/Tests/RunCMake/file/TOUCH-error-missing-directory-stderr.txt
@@ -0,0 +1 @@
+.*file problem touching file:
diff --git a/Tests/RunCMake/file/TOUCH-error-missing-directory.cmake b/Tests/RunCMake/file/TOUCH-error-missing-directory.cmake
new file mode 100644
index 0000000..0cfb8d9
--- /dev/null
+++ b/Tests/RunCMake/file/TOUCH-error-missing-directory.cmake
@@ -0,0 +1 @@
+file(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/missing/directory/file.to-touch")
diff --git a/Tests/RunCMake/file/TOUCH-result.txt b/Tests/RunCMake/file/TOUCH-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/file/TOUCH-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/TOUCH-stderr.txt b/Tests/RunCMake/file/TOUCH-stderr.txt
new file mode 100644
index 0000000..9f31676
--- /dev/null
+++ b/Tests/RunCMake/file/TOUCH-stderr.txt
@@ -0,0 +1,9 @@
+^CMake Error at TOUCH\.cmake:[0-9]+ \(file\):
+  file must be called with at least two arguments\.
+Call Stack \(most recent call first\):
+  CMakeLists\.txt:[0-9]+ \(include\)
++
+CMake Error at TOUCH\.cmake:[0-9]+ \(file\):
+  file must be called with at least two arguments\.
+Call Stack \(most recent call first\):
+  CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/file/TOUCH.cmake b/Tests/RunCMake/file/TOUCH.cmake
new file mode 100644
index 0000000..8931eb5
--- /dev/null
+++ b/Tests/RunCMake/file/TOUCH.cmake
@@ -0,0 +1,16 @@
+set(file "${CMAKE_CURRENT_BINARY_DIR}/file-to-touch")
+
+file(REMOVE "${file}")
+file(TOUCH_NOCREATE "${file}")
+if(EXISTS "${file}")
+  message(FATAL_ERROR "error: TOUCH_NOCREATE created a file!")
+endif()
+
+file(TOUCH "${file}")
+if(NOT EXISTS "${file}")
+  message(FATAL_ERROR "error: TOUCH did not create a file!")
+endif()
+file(REMOVE "${file}")
+
+file(TOUCH)
+file(TOUCH_NOCREATE)

-----------------------------------------------------------------------

Summary of changes:
 Help/command/file.rst                              |   17 +++++++++
 Help/release/dev/file_cmd_touch.rst                |    6 ++++
 Modules/ExternalData.cmake                         |    2 +-
 Source/cmFileCommand.cxx                           |   38 ++++++++++++++++++++
 Source/cmFileCommand.h                             |    1 +
 Source/cmcmd.cxx                                   |    2 --
 Tests/QtAutogen/RerunRccDepends/CMakeLists.txt     |    6 ++--
 .../RunCMake/VS10Project/VsCSharpCustomTags.cmake  |    3 +-
 Tests/RunCMake/file/RunCMakeTest.cmake             |    3 ++
 .../TOUCH-error-in-source-directory-result.txt}    |    0
 .../TOUCH-error-in-source-directory-stderr.txt     |    1 +
 .../file/TOUCH-error-in-source-directory.cmake     |    2 ++
 .../TOUCH-error-missing-directory-result.txt}      |    0
 .../file/TOUCH-error-missing-directory-stderr.txt  |    1 +
 .../file/TOUCH-error-missing-directory.cmake       |    1 +
 .../TOUCH-result.txt}                              |    0
 Tests/RunCMake/file/TOUCH-stderr.txt               |    9 +++++
 Tests/RunCMake/file/TOUCH.cmake                    |   16 +++++++++
 18 files changed, 99 insertions(+), 9 deletions(-)
 create mode 100644 Help/release/dev/file_cmd_touch.rst
 copy Tests/RunCMake/{Android/BadSYSROOT-result.txt => file/TOUCH-error-in-source-directory-result.txt} (100%)
 create mode 100644 Tests/RunCMake/file/TOUCH-error-in-source-directory-stderr.txt
 create mode 100644 Tests/RunCMake/file/TOUCH-error-in-source-directory.cmake
 copy Tests/RunCMake/{Android/BadSYSROOT-result.txt => file/TOUCH-error-missing-directory-result.txt} (100%)
 create mode 100644 Tests/RunCMake/file/TOUCH-error-missing-directory-stderr.txt
 create mode 100644 Tests/RunCMake/file/TOUCH-error-missing-directory.cmake
 copy Tests/RunCMake/{Android/BadSYSROOT-result.txt => file/TOUCH-result.txt} (100%)
 create mode 100644 Tests/RunCMake/file/TOUCH-stderr.txt
 create mode 100644 Tests/RunCMake/file/TOUCH.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list