mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-11 07:10:36 +00:00
638fb25b47
This rewrites the version info using lokid's approach of compiling it into a .cpp file that gets generated as part of the build (*not* during the configure stage). Among other things, this means that changing the version no longer invalidates ccache or cmake dependencies, and because it depends on `.git/index` git commits will cause the version to be regenerated, making the commit tag more reliable (currently if you rebuild without running cmake your git commit tag doesn't update).
22 lines
1001 B
CMake
22 lines
1001 B
CMake
|
|
find_package(Git QUIET)
|
|
if(GIT_FOUND OR Git_FOUND)
|
|
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"
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/../.git/index")
|
|
else()
|
|
message(WARNING "Git was not found! Setting version to to nogit")
|
|
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")
|