Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer named tags to Git revision hashes for LDC verison. #498

Merged
merged 1 commit into from
Oct 9, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,21 @@ set(LDC_GENERATED
# Gather source files.
#
include(GetGitRevisionDescription)
get_git_head_revision(REFSPEC HASH)
if(NOT HASH STREQUAL "GITDIR-NOTFOUND")
string(SUBSTRING "${HASH}" 0 6 LDC_VERSION)
git_get_exact_tag(TAG)
if(NOT TAG MATCHES "NOTFOUND")
if(TAG MATCHES "v[0-9].*")
# For a version tag, remove the leading 'v'.
string(SUBSTRING "${TAG}" 1 -1 LDC_VERSION)
else()
set(LDC_VERSION "${TAG}")
endif()
else()
get_git_head_revision(REFSPEC HASH)
if(NOT HASH STREQUAL "GITDIR-NOTFOUND")
string(SUBSTRING "${HASH}" 0 6 LDC_VERSION)
endif()
endif()
message(STATUS "LDC version identifier: ${LDC_VERSION}")
configure_file(driver/ldc-version.cpp.in driver/ldc-version.cpp)

# Also add the header files to the build so that they are available in IDE
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/GetGitRevisionDescription.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,6 @@ function(git_describe _var)
endfunction()

function(git_get_exact_tag _var)
git_describe(out --exact-match ${ARGN})
git_describe(out --exact-match --tag ${ARGN})
set(${_var} "${out}" PARENT_SCOPE)
endfunction()