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,10 +3,10 @@ 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) if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/../version.txt)
else()
# for source package files (generated for ubuntu builds on launchpad) read the version from version.txt # 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 ) file(READ ${CMAKE_CURRENT_LIST_DIR}/../version.txt git_version_string )
@ -14,6 +14,10 @@ else()
get_filename_component(git_version_string ${CMAKE_CURRENT_LIST_DIR}/.. NAME) get_filename_component(git_version_string ${CMAKE_CURRENT_LIST_DIR}/.. NAME)
string(REGEX REPLACE "^netgen(.*)" "\\1" git_version_string "${git_version_string}") string(REGEX REPLACE "^netgen(.*)" "\\1" git_version_string "${git_version_string}")
endif() endif()
else()
MESSAGE(WARNING "Could not determine git-version from source code - assuming 6.2.0.0")
set(git_version_string "v6.2.0.0")
endif()
endif() endif()
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" NETGEN_VERSION_MAJOR "${git_version_string}") string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" NETGEN_VERSION_MAJOR "${git_version_string}")