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

Parse version from directory name if not a git repository. #142

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Changes from 1 commit
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
20 changes: 18 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,27 @@ endif(JSON_ENABLED)
# get the current git revision, if git is installed. Avoid warnings if it isn't
FIND_PACKAGE(Git)
IF(Git_FOUND)
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} rev-parse --git-dir WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE git_dir OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
IF(git_dir STREQUAL "${PROJECT_SOURCE_DIR}/.git")
SET(IS_GIT_REPO TRUE)
ELSE()
SET(IS_GIT_REPO FALSE)
ENDIF()
ELSE()
SET(IS_GIT_REPO FALSE)
ENDIF(Git_FOUND)

IF(IS_GIT_REPO)
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE revision OUTPUT_STRIP_TRAILING_WHITESPACE)
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 HEAD WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE tag OUTPUT_STRIP_TRAILING_WHITESPACE)
ELSE()
SET(revision GIT_NOT_FOUND)
ENDIF(Git_FOUND)
get_filename_component(dir_name ${PROJECT_SOURCE_DIR} NAME)
string(REGEX MATCH "-([0-9]+\\.[0-9]+\\.[0-9]+.*)$" version_match ${dir_name})
if(version_match)
SET(tag ${CMAKE_MATCH_1})
endif()
cgevans marked this conversation as resolved.
Show resolved Hide resolved
ENDIF(IS_GIT_REPO)


# return the current date as day/month/year
MACRO(CURRENT_DATE result)
Expand Down