[PATCH] D92718: [CMake] Avoid __FakeVCSRevision.h with no git repository

Jonas Hahnfeld via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 15 12:13:02 PST 2020


Hahnfeld updated this revision to Diff 311989.
Hahnfeld added a comment.

Add comment for `find_first_existing_vc_file`, thanks @scott.linder.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92718/new/

https://reviews.llvm.org/D92718

Files:
  llvm/cmake/modules/AddLLVM.cmake
  llvm/include/llvm/Support/CMakeLists.txt


Index: llvm/include/llvm/Support/CMakeLists.txt
===================================================================
--- llvm/include/llvm/Support/CMakeLists.txt
+++ llvm/include/llvm/Support/CMakeLists.txt
@@ -11,7 +11,7 @@
   # A fake version file and is not expected to exist. It is being used to
   # force regeneration of VCSRevision.h for source directory with no write
   # permission available.
-  if (NOT llvm_vc)
+  if (llvm_vc STREQUAL "")
     set(fake_version_inc "${CMAKE_CURRENT_BINARY_DIR}/__FakeVCSRevision.h")
   endif()
 endif()
Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -2135,6 +2135,13 @@
   set_target_properties(${name} PROPERTIES RULE_LAUNCH_COMPILE ${sandbox_command})
 endfunction()
 
+# If the sources at the given `path` are under version control, set `out_var`
+# to the the path of a file which will be modified when the VCS revision
+# changes, attempting to create that file if it does not exist; if no such
+# file exists and one cannot be created, instead set `out_var` to the
+# empty string.
+#
+# If the sources are not under version control, do not define `out_var`.
 function(find_first_existing_vc_file path out_var)
   if(NOT EXISTS "${path}")
     return()
@@ -2156,6 +2163,7 @@
           RESULT_VARIABLE touch_head_result
           ERROR_QUIET)
         if (NOT touch_head_result EQUAL 0)
+          set(${out_var} "" PARENT_SCOPE)
           return()
         endif()
       endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92718.311989.patch
Type: text/x-patch
Size: 1571 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201215/4670b9c1/attachment.bin>


More information about the llvm-commits mailing list