diff --git a/CMakeLists.txt b/CMakeLists.txt index d29e0ac1..b22d72e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,10 +35,13 @@ execute_process( WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE GIT_COMMIT_HASH RESULT_VARIABLE GIT_COMMAND_SUCCESS - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) if (GIT_COMMAND_SUCCESS EQUAL 0) set(SNITCH_FULL_VERSION "${PROJECT_VERSION}.${GIT_COMMIT_HASH}") +else() + set(SNITCH_FULL_VERSION "${PROJECT_VERSION}") endif() # Create configure file to store CMake build parameter diff --git a/snitch/meson.build b/snitch/meson.build index 14c62409..4883014b 100644 --- a/snitch/meson.build +++ b/snitch/meson.build @@ -1,7 +1,13 @@ version = meson.project_version() vers = version.split('.') -git_hash = run_command(find_program('git'), 'log', '-1', '--format=%h', check:true).stdout().strip() +git_command = run_command(find_program('git'), 'log', '-1', '--format=%h', check: false) +if git_command.returncode() == 0 + git_hash = git_command.stdout().strip() + full_version = version + '.' + git_hash +else + full_version = version +endif conf_data = configuration_data({ 'PROJECT_VERSION' : version, @@ -9,7 +15,7 @@ conf_data = configuration_data({ 'PROJECT_VERSION_MINOR' : vers[1], 'PROJECT_VERSION_PATCH' : vers[2], - 'SNITCH_FULL_VERSION' : version + '.' + git_hash, + 'SNITCH_FULL_VERSION' : full_version, 'SNITCH_MAX_TEST_CASES' : get_option('max_test_cases'), 'SNITCH_MAX_NESTED_SECTIONS' : get_option('max_nested_sections'),