Fix version file generation

This commit is contained in:
Matthias Hochsteger 2020-07-25 08:41:17 +02:00
parent 68f5605866
commit fa1a5d11ee

View File

@ -3,16 +3,20 @@ if(NOT BDIR)
endif() endif()
find_package(Git REQUIRED) find_package(Git REQUIRED)
execute_process(COMMAND git describe --tags --match "v[0-9]*" --long --dirty WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} OUTPUT_VARIABLE git_version_string RESULT_VARIABLE status ERROR_QUIET)
if(GIT_FOUND AND IS_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../.git) if(status AND NOT status EQUAL 0)
execute_process(COMMAND git describe --tags --match "v[0-9]*" --long --dirty WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} OUTPUT_VARIABLE git_version_string)
else()
# for source package files (generated for ubuntu builds on launchpad) read the version from version.txt
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/../version.txt) if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/../version.txt)
file(READ ${CMAKE_CURRENT_LIST_DIR}/../version.txt git_version_string ) # for source package files (generated for ubuntu builds on launchpad) read the version from version.txt
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/../version.txt)
file(READ ${CMAKE_CURRENT_LIST_DIR}/../version.txt git_version_string )
else()
get_filename_component(git_version_string ${CMAKE_CURRENT_LIST_DIR}/.. NAME)
string(REGEX REPLACE "^netgen(.*)" "\\1" git_version_string "${git_version_string}")
endif()
else() else()
get_filename_component(git_version_string ${CMAKE_CURRENT_LIST_DIR}/.. NAME) MESSAGE(WARNING "Could not determine git-version from source code - assuming 6.2.0.0")
string(REGEX REPLACE "^netgen(.*)" "\\1" git_version_string "${git_version_string}") set(git_version_string "v6.2.0.0")
endif() endif()
endif() endif()