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

Jonas Hahnfeld via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 5 04:10:43 PST 2020


Hahnfeld created this revision.
Hahnfeld added reviewers: pdhaliwal, tstellar.
Herald added a subscriber: mgorny.
Hahnfeld requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Set the return variable to "" in `find_first_existing_vc_file` to
say that there is a repository, but no file to depend on. This works
transparently for all other callers that handle undefinedness and
equality to an empty string the same way.

Use the knowledge to avoid depending on `__FakeVCSRevision.h` if there
is no git repository at all (for example when building a release) as
there is no point in regenerating an empty `VCSRevision.h`.


Repository:
  rG LLVM Github Monorepo

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
@@ -2156,6 +2156,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.309731.patch
Type: text/x-patch
Size: 959 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201205/6d644c2e/attachment.bin>


More information about the llvm-commits mailing list