Files
wine-access/cmake/GenerateVersion.cmake
T

29 lines
1.4 KiB
CMake

# Refresh on every build, including incremental builds after a commit or edit.
# configure_file only changes the header when the embedded identity changes.
file(READ "${SOURCE_DIR}/VERSION" releaseVersion)
string(STRIP "${releaseVersion}" releaseVersion)
if(NOT releaseVersion MATCHES "^[0-9][0-9][0-9][0-9][.][0-9][0-9][.][0-9][0-9]$")
message(FATAL_ERROR "VERSION must contain a date in YYYY.MM.DD format")
endif()
set(gitRevision "unavailable")
set(gitModified "false")
set(buildSuffix "")
find_package(Git QUIET)
# Do not accidentally identify a source archive as its enclosing repository.
if(GIT_FOUND AND EXISTS "${SOURCE_DIR}/.git")
execute_process(COMMAND "${GIT_EXECUTABLE}" rev-parse --short=12 HEAD
WORKING_DIRECTORY "${SOURCE_DIR}" RESULT_VARIABLE revisionResult
OUTPUT_VARIABLE revision OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
execute_process(COMMAND "${GIT_EXECUTABLE}" status --porcelain --untracked-files=normal
WORKING_DIRECTORY "${SOURCE_DIR}" RESULT_VARIABLE statusResult
OUTPUT_VARIABLE status OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
if(revisionResult EQUAL 0 AND revision MATCHES "^[0-9a-f]+$")
set(gitRevision "${revision}")
endif()
if(statusResult EQUAL 0 AND NOT status STREQUAL "")
set(gitModified "true")
set(buildSuffix ", modified")
endif()
endif()
configure_file("${SOURCE_DIR}/cmake/version.h.in" "${OUTPUT_FILE}" @ONLY)