Skip to content

Commit 6e890ec

Browse files
committed
[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
1 parent 0775131 commit 6e890ec

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
@@ -2135,6 +2135,13 @@ function(setup_dependency_debugging name)
21352135
set_target_properties(${name} PROPERTIES RULE_LAUNCH_COMPILE ${sandbox_command})
21362136
endfunction()
21372137

2138+
# If the sources at the given `path` are under version control, set `out_var`
2139+
# to the the path of a file which will be modified when the VCS revision
2140+
# changes, attempting to create that file if it does not exist; if no such
2141+
# file exists and one cannot be created, instead set `out_var` to the
2142+
# empty string.
2143+
#
2144+
# If the sources are not under version control, do not define `out_var`.
21382145
function(find_first_existing_vc_file path out_var)
21392146
if(NOT EXISTS "${path}")
21402147
return()
@@ -2156,6 +2163,7 @@ function(find_first_existing_vc_file path out_var)
21562163
RESULT_VARIABLE touch_head_result
21572164
ERROR_QUIET)
21582165
if (NOT touch_head_result EQUAL 0)
2166+
set(${out_var} "" PARENT_SCOPE)
21592167
return()
21602168
endif()
21612169
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)