2021-07-05 00:12:01 +00:00
|
|
|
if (EXISTS ${PROJECT_TOP}/VERSION)
|
|
|
|
file(READ ${PROJECT_TOP}/VERSION GIT_REV)
|
|
|
|
else()
|
|
|
|
execute_process(
|
|
|
|
COMMAND git describe --always --abbrev=10 --dirty=+ --tags
|
|
|
|
WORKING_DIRECTORY "${PROJECT_TOP}"
|
|
|
|
OUTPUT_VARIABLE GIT_REV
|
|
|
|
ERROR_QUIET)
|
|
|
|
endif()
|
|
|
|
|
2020-10-08 15:17:20 +00:00
|
|
|
|
2020-12-08 16:00:40 +00:00
|
|
|
if ("${GIT_REV}" STREQUAL "")
|
2021-07-05 00:12:01 +00:00
|
|
|
set(GIT_REV "UNKNOWN")
|
2020-10-08 15:17:20 +00:00
|
|
|
endif()
|
|
|
|
|
2020-12-08 16:00:40 +00:00
|
|
|
string(STRIP "${GIT_REV}" GIT_VERSION)
|
2020-10-08 16:09:45 +00:00
|
|
|
set(BUILD_VERSION "const char * BUILD_VERSION = \"${GIT_VERSION}\";")
|
|
|
|
|
|
|
|
if(EXISTS "${CMAKE_BINARY_DIR}/version.c")
|
|
|
|
file(READ ${CMAKE_BINARY_DIR}/version.c BUILD_VERSION_)
|
|
|
|
else()
|
|
|
|
set(BUILD_VERSION_ "")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NOT "${BUILD_VERSION}" STREQUAL "${BUILD_VERSION_}")
|
|
|
|
file(WRITE ${CMAKE_BINARY_DIR}/version.c "${BUILD_VERSION}")
|
|
|
|
file(WRITE ${CMAKE_BINARY_DIR}/VERSION "${GIT_VERSION}")
|
2020-10-08 15:17:20 +00:00
|
|
|
endif()
|