Browse Source

Merge topic 'cmp0168-populate-nondeclare-regression' into release-3.30

cbb727ca6b FetchContent: Don't update verify script timestamp if it doesn't change
795e7b44f2 Help: file(CONFIGURE) only updates output file timestamp if it changes

Acked-by: Kitware Robot <[email protected]>
Merge-request: !9799
Craig Scott 1 year ago
parent
commit
126e0ad429
2 changed files with 6 additions and 2 deletions
  1. 3 1
      Help/command/file.rst
  2. 3 1
      Modules/ExternalProject/shared_internal_commands.cmake

+ 3 - 1
Help/command/file.rst

@@ -302,7 +302,9 @@ Writing
   variable values referenced as ``@VAR@`` or ``${VAR}`` contained therein. The
   substitution rules behave the same as the :command:`configure_file` command.
   In order to match :command:`configure_file`'s behavior, generator expressions
-  are not supported for both ``OUTPUT`` and ``CONTENT``.
+  are not supported for both ``OUTPUT`` and ``CONTENT``, and the output file
+  is only modified and its timestamp updated if the content is changed or the
+  file previously didn't exist.
 
   The arguments are:
 

+ 3 - 1
Modules/ExternalProject/shared_internal_commands.cmake

@@ -1221,7 +1221,9 @@ hash=${hash}
         endif ()
         set(comment "Performing download step (${steps}) for '${name}'")
         # already verified by 'download_script'
-        file(WRITE "${verify_script}" "")
+        # We use file(CONFIGURE) instead of file(WRITE) to avoid updating the
+        # timestamp when the file already existed and was empty.
+        file(CONFIGURE OUTPUT "${verify_script}" CONTENT "")
 
         # Rather than adding everything to the RepositoryInfo.txt file, it is
         # more robust to just depend on the download script. That way, we will