aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Hahnfeld <hahnjo@hahnjo.de>2020-12-05 12:52:38 +0100
committerTom Stellard <tstellar@redhat.com>2020-12-17 10:51:20 -0500
commitd104e582838fd73d6ef565788f11617eccab87e2 (patch)
tree0bcc39e8ddf16b116383a088d450cf14fe9b35a3
parentf5f8d86dc4c91ef492b919edf98335d4d09188a8 (diff)
downloadllvm-d104e582838fd73d6ef565788f11617eccab87e2.zip
llvm-d104e582838fd73d6ef565788f11617eccab87e2.tar.gz
llvm-d104e582838fd73d6ef565788f11617eccab87e2.tar.bz2
[CMake] Avoid __FakeVCSRevision.h with no git repository
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. Differential Revision: https://reviews.llvm.org/D92718 (cherry picked from commit 6e890ec7beb0874464a0af9f84e41a987f968b23)
-rw-r--r--llvm/cmake/modules/AddLLVM.cmake8
-rw-r--r--llvm/include/llvm/Support/CMakeLists.txt2
2 files changed, 9 insertions, 1 deletions
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 333167b..b74adc1 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -2102,6 +2102,13 @@ function(setup_dependency_debugging name)
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()
@@ -2123,6 +2130,7 @@ function(find_first_existing_vc_file path out_var)
RESULT_VARIABLE touch_head_result
ERROR_QUIET)
if (NOT touch_head_result EQUAL 0)
+ set(${out_var} "" PARENT_SCOPE)
return()
endif()
endif()
diff --git a/llvm/include/llvm/Support/CMakeLists.txt b/llvm/include/llvm/Support/CMakeLists.txt
index da8a4da..69f6a15 100644
--- a/llvm/include/llvm/Support/CMakeLists.txt
+++ b/llvm/include/llvm/Support/CMakeLists.txt
@@ -11,7 +11,7 @@ if(LLVM_APPEND_VC_REV)
# 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()