compare git version with .version
@@ -39,6 +39,15 @@ if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
list(GET PROJECT_VERSION_LIST 1 PROJECT_VERSION_MINOR)
list(GET PROJECT_VERSION_LIST 2 PROJECT_VERSION_PATCH)
set(__detect_version 1)
+ set(__version_str "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
+ if(EXISTS "${PROJECT_SOURCE_DIR}/.version")
+ file(READ "${PROJECT_SOURCE_DIR}/.version" __version_file)
+ if(NOT __version_str STREQUAL __version_file)
+ message(STATUS "Rewrite ${PROJECT_SOURCE_DIR}/.version with ${__version_str}")
+ endif()
+ else()
+ file(WRITE "${PROJECT_SOURCE_DIR}/.version" ${__version_str})
+ endif()
else()
message(STATUS "Fail to extract version's parts from \"${PROJECT_VERSION}\"")
endif()
