From 53ba7b9a5aef16366ce84ee1a7ec1376d36e57db Mon Sep 17 00:00:00 2001 From: Jan Palus Date: Mon, 7 Nov 2022 18:42:21 +0100 Subject: [PATCH] build: restrict `git describe` to top level source directory fix version determination when building neovim from release tarball extracted within another git repository --- cmake/GenerateVersion.cmake | 2 +- src/nvim/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/GenerateVersion.cmake b/cmake/GenerateVersion.cmake index 7ce6ee430e..8cea39e4de 100644 --- a/cmake/GenerateVersion.cmake +++ b/cmake/GenerateVersion.cmake @@ -2,7 +2,7 @@ set(NVIM_VERSION "v${NVIM_VERSION_MAJOR}.${NVIM_VERSION_MINOR}.${NVIM_VERSION_PATCH}${NVIM_VERSION_PRERELEASE}") execute_process( - COMMAND git describe --first-parent --dirty --always + COMMAND git --git-dir=${NVIM_SOURCE_DIR}/.git --work-tree=${NVIM_SOURCE_DIR} describe --first-parent --dirty --always OUTPUT_VARIABLE GIT_TAG OUTPUT_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE RES) diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 6511fe6fbb..5a64128bcb 100755 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -206,6 +206,7 @@ add_custom_target(update_version_stamp -DNVIM_VERSION_PATCH=${NVIM_VERSION_PATCH} -DNVIM_VERSION_PRERELEASE=${NVIM_VERSION_PRERELEASE} -DOUTPUT=${NVIM_VERSION_GIT_H} + -DNVIM_SOURCE_DIR=${CMAKE_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/cmake/GenerateVersion.cmake BYPRODUCTS ${NVIM_VERSION_GIT_H})