[PATCH] D35377: [CMAKE] PR33717 When LLVM_APPEND_VC_REV = OFF, only create VCSRevision.h if it doesn't already exist.
don hinton via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 13 19:21:59 PDT 2017
hintonda updated this revision to Diff 106580.
hintonda added a comment.
- Handle VCSRevision.h correctly when toggling LLVM_APPEND_VC_REV.
https://reviews.llvm.org/D35377
Files:
include/llvm/Support/CMakeLists.txt
Index: include/llvm/Support/CMakeLists.txt
===================================================================
--- include/llvm/Support/CMakeLists.txt
+++ include/llvm/Support/CMakeLists.txt
@@ -42,6 +42,20 @@
if(DEFINED llvm_vc)
# Create custom target to generate the VC revision include.
+
+ # If version_inc exists and is empty, remove it so that
+ # get_svn_script will fire.
+ file(WRITE "${version_inc}.txt" "")
+ execute_process(COMMAND ${CMAKE_COMMAND} -E compare_files
+ "${version_inc}.txt" "${version_inc}"
+ RESULT_VARIABLE files_not_equal
+ OUTPUT_QUIET
+ ERROR_QUIET)
+ file(REMOVE "${version_inc}.txt")
+ if(NOT files_not_equal)
+ file(REMOVE "${version_inc}")
+ endif()
+
add_custom_command(OUTPUT "${version_inc}"
DEPENDS "${llvm_vc}" "${get_svn_script}"
COMMAND
@@ -55,7 +69,12 @@
PROPERTIES GENERATED TRUE
HEADER_FILE_ONLY TRUE)
else()
- file(WRITE "${version_inc}" "")
+ # Ensure ${version_inc} is an empty file.
+ file(WRITE "${version_inc}.txt" "")
+ # Copy the file only if it has changed.
+ execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ "${version_inc}.txt" "${version_inc}")
+ file(REMOVE "${version_inc}.txt")
endif()
add_custom_target(llvm_vcsrevision_h DEPENDS "${version_inc}")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35377.106580.patch
Type: text/x-patch
Size: 1301 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170714/0695fd6b/attachment.bin>
More information about the llvm-commits
mailing list