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

allow compilation without git or when git fails #300

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions cmake/modules/GitVersion.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
function(git_get_version VERSION_VARIABLE)
string(TIMESTAMP TODAY "%Y.%m.%d")
set(${VERSION_VARIABLE} "0.0.0+${TODAY}" PARENT_SCOPE)

find_program(GIT_EXECUTABLE git)

if(NOT GIT_EXECUTABLE)
message(FATAL_ERROR "Git not found. Please install Git and make sure it is in your system's PATH.")
message(WARNING "Git not found, using fallback version.")
return()
endif()

execute_process(
Expand All @@ -15,7 +19,9 @@ function(git_get_version VERSION_VARIABLE)
)

if(NOT GIT_DESCRIBE_RESULT EQUAL 0)
message(FATAL_ERROR "Error running 'git describe': ${GIT_DESCRIBE_ERROR}")
message(INFO "Error running 'git describe': ${GIT_DESCRIBE_ERROR}")
message(WARNING "Git failed, using fallback version.")
return()
endif()

string(LENGTH "${VERSION_STRING}" VERSION_STRING_LENGTH)
Expand Down
Loading