-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathgit_version.cmake
39 lines (31 loc) · 1.32 KB
/
git_version.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
if(TARGET bmx_git_version)
return()
endif()
# Ensure the cmake targets and code symbols are bmx specific
set(GIT_VERSION_PROJECT_PREFIX "bmx_")
# Set the git release tag pattern to describe relative to
set(GIT_DESCRIBE_TAG_PATTERN "v${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
set(GIT_WORKING_DIR ${PROJECT_SOURCE_DIR})
# Set to ignore git_version errors if there is no .git directory
set(GIT_FAIL_IF_NONZERO_EXIT FALSE)
include(FetchContent)
set(git_version_deps_source "${PROJECT_SOURCE_DIR}/deps/cmake-git-version-tracking")
if(EXISTS ${git_version_deps_source})
FetchContent_Declare(bmx_git_version
SOURCE_DIR ${git_version_deps_source}
)
message("-- Build using git version source: ${git_version_deps_source}")
else()
FetchContent_Declare(bmx_git_version
GIT_REPOSITORY "https://github.com/andrew-hardin/cmake-git-version-tracking.git"
GIT_TAG "904dbda1336ba4b9a1415a68d5f203f576b696bb"
PATCH_COMMAND git clean -fdx
COMMAND git reset --hard
COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/git_version_904dbda.patch"
)
endif()
FetchContent_GetProperties(bmx_git_version)
if(NOT bmx_git_version_POPULATED)
FetchContent_Populate(bmx_git_version)
add_subdirectory(${bmx_git_version_SOURCE_DIR} ${bmx_git_version_BINARY_DIR})
endif()