aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorAoife Fey <[email protected]>2023-02-09 14:19:43 -0700
committerGitHub <[email protected]>2023-02-09 13:19:43 -0800
commit3ce537d474bbde645017ecbcc3255c9a2d9432fe (patch)
tree7a5f15fae9eee7a1127e67369150331ee4c749a6 /CMakeLists.txt
parent8695aa49a5f5d62782217d2380b037d18e7a7460 (diff)
Allow finding index file when built as a submodule (#819)
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt15
1 files changed, 13 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 92cc138a..74eeb9fd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1206,7 +1206,18 @@ set(BACKENDS "${BACKENDS} Null")
find_package(Git)
-if(ALSOFT_UPDATE_BUILD_VERSION AND GIT_FOUND AND EXISTS "${OpenAL_SOURCE_DIR}/.git/index")
+if(ALSOFT_UPDATE_BUILD_VERSION AND GIT_FOUND AND EXISTS "${OpenAL_SOURCE_DIR}/.git")
+ set(GIT_DIR "${OpenAL_SOURCE_DIR}/.git")
+
+ # Check if this is a submodule, if it is then find the .git directory
+ if(NOT IS_DIRECTORY "${OpenAL_SOURCE_DIR}/.git")
+ file(READ ${GIT_DIR} submodule)
+ string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE ${submodule})
+ string(STRIP ${GIT_DIR_RELATIVE} GIT_DIR_RELATIVE)
+ get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
+ get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
+ endif()
+
# Get the current working branch and its latest abbreviated commit hash
add_custom_command(OUTPUT "${OpenAL_BINARY_DIR}/version_witness.txt"
BYPRODUCTS "${OpenAL_BINARY_DIR}/version.h"
@@ -1216,7 +1227,7 @@ if(ALSOFT_UPDATE_BUILD_VERSION AND GIT_FOUND AND EXISTS "${OpenAL_SOURCE_DIR}/.g
COMMAND ${CMAKE_COMMAND} -E touch "${OpenAL_BINARY_DIR}/version_witness.txt"
WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}"
MAIN_DEPENDENCY "${OpenAL_SOURCE_DIR}/version.h.in"
- DEPENDS "${OpenAL_SOURCE_DIR}/.git/index" "${OpenAL_SOURCE_DIR}/version.cmake"
+ DEPENDS "${GIT_DIR}/index" "${OpenAL_SOURCE_DIR}/version.cmake"
VERBATIM
)