Use VERSION variable in cmake to specify version number more cleanly

This commit is contained in:
def 2020-09-24 17:06:03 +02:00
parent ebb4e3debe
commit 1a17feff12

View file

@ -97,6 +97,7 @@ option(CLIENT "Compile client" ON)
option(DOWNLOAD_GTEST "Download and compile GTest" ${AUTO_DEPENDENCIES_DEFAULT})
option(STEAM "Build the Steam release version" OFF)
option(PREFER_BUNDLED_LIBS "Prefer bundled libraries over system libraries" ${AUTO_DEPENDENCIES_DEFAULT})
option(VERSION "Specify version string" ${PROJECT_VERSION})
option(DEV "Don't generate stuff necessary for packaging" OFF)
set(OpenGL_GL_PREFERENCE LEGACY)
@ -2217,11 +2218,7 @@ set(CPACK_SOURCE_GENERATOR ZIP TGZ TBZ2 TXZ)
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
if(VERSION_PATCH STREQUAL "0")
set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR})
else()
set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
endif()
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
if(TARGET_OS AND TARGET_BITS)
@ -2619,6 +2616,9 @@ foreach(target ${TARGETS_OWN})
if(INFORM_UPDATE)
target_compile_definitions(${target} PRIVATE CONF_INFORM_UPDATE)
endif()
if(VERSION)
target_compile_definitions(${target} PRIVATE GAME_RELEASE_VERSION="${VERSION}")
endif()
endforeach()
foreach(target ${TARGETS_DEP})