Skip to content

Commit d104e58

Browse files
hahnjotstellar
authored andcommitted
[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 6e890ec)
1 parent f5f8d86 commit d104e58

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,6 +2102,13 @@ function(setup_dependency_debugging name)
21022102
set_target_properties(${name} PROPERTIES RULE_LAUNCH_COMPILE ${sandbox_command})
21032103
endfunction()
21042104

2105+
# If the sources at the given `path` are under version control, set `out_var`
2106+
# to the the path of a file which will be modified when the VCS revision
2107+
# changes, attempting to create that file if it does not exist; if no such
2108+
# file exists and one cannot be created, instead set `out_var` to the
2109+
# empty string.
2110+
#
2111+
# If the sources are not under version control, do not define `out_var`.
21052112
function(find_first_existing_vc_file path out_var)
21062113
if(NOT EXISTS "${path}")
21072114
return()
@@ -2123,6 +2130,7 @@ function(find_first_existing_vc_file path out_var)
21232130
RESULT_VARIABLE touch_head_result
21242131
ERROR_QUIET)
21252132
if (NOT touch_head_result EQUAL 0)
2133+
set(${out_var} "" PARENT_SCOPE)
21262134
return()
21272135
endif()
21282136
endif()

llvm/include/llvm/Support/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if(LLVM_APPEND_VC_REV)
1111
# A fake version file and is not expected to exist. It is being used to
1212
# force regeneration of VCSRevision.h for source directory with no write
1313
# permission available.
14-
if (NOT llvm_vc)
14+
if (llvm_vc STREQUAL "")
1515
set(fake_version_inc "${CMAKE_CURRENT_BINARY_DIR}/__FakeVCSRevision.h")
1616
endif()
1717
endif()

0 commit comments

Comments
 (0)