2019-12-12 02:32:27 +00:00
|
|
|
|
|
|
|
find_package(Git QUIET)
|
2020-03-01 13:42:44 +00:00
|
|
|
set(GIT_INDEX_FILE "${PROJECT_SOURCE_DIR}/.git/index")
|
|
|
|
if(EXISTS ${GIT_INDEX_FILE} AND GIT_FOUND OR Git_FOUND)
|
2019-12-12 02:32:27 +00:00
|
|
|
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp"
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
"-D" "GIT=${GIT_EXECUTABLE}"
|
|
|
|
"-D" "SRC=${CMAKE_CURRENT_SOURCE_DIR}/constants/version.cpp.in"
|
|
|
|
"-D" "DEST=${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp"
|
|
|
|
"-P" "${CMAKE_CURRENT_LIST_DIR}/GenVersion.cmake"
|
|
|
|
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/constants/version.cpp.in"
|
2020-03-01 13:42:44 +00:00
|
|
|
"${GIT_INDEX_FILE}")
|
2019-12-12 02:32:27 +00:00
|
|
|
else()
|
2020-03-01 13:42:44 +00:00
|
|
|
message(STATUS "Git was not found! Setting version to to nogit")
|
2019-12-12 02:32:27 +00:00
|
|
|
set(VERSIONTAG "nogit")
|
|
|
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/constants/version.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_custom_target(genversion DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp")
|