mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge pull request #7186 from infclass/for-ddnet2
CMake: Revert versioning (move it back to version.h)
This commit is contained in:
commit
971fa6d024
|
@ -5,16 +5,29 @@ if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.15)
|
|||
message(WARNING "Building for macOS < 10.15 is not supported")
|
||||
endif()
|
||||
|
||||
# Set version if not explicitly set
|
||||
set(DDNET_NETWORK_VERSION 17.2.1)
|
||||
file(STRINGS src/game/version.h VERSION_LINE
|
||||
LIMIT_COUNT 1
|
||||
REGEX "^#define GAME_RELEASE_VERSION "
|
||||
)
|
||||
|
||||
if(NOT VERSION)
|
||||
set(VERSION ${DDNET_NETWORK_VERSION})
|
||||
if(VERSION_LINE MATCHES "\"([0-9]+)\\.([0-9]+)\\.([0-9]+)\"")
|
||||
set(VERSION_MAJOR ${CMAKE_MATCH_1})
|
||||
set(VERSION_MINOR ${CMAKE_MATCH_2})
|
||||
set(VERSION_PATCH ${CMAKE_MATCH_3})
|
||||
elseif(VERSION_LINE MATCHES "\"([0-9]+)\\.([0-9]+)\"")
|
||||
set(VERSION_MAJOR ${CMAKE_MATCH_1})
|
||||
set(VERSION_MINOR ${CMAKE_MATCH_2})
|
||||
set(VERSION_PATCH "0")
|
||||
else()
|
||||
message(FATAL_ERROR "Couldn't parse version from src/game/version.h")
|
||||
endif()
|
||||
|
||||
project(DDNet
|
||||
VERSION ${VERSION}
|
||||
)
|
||||
# Extra support for CMake pre-3.0
|
||||
if(VERSION_PATCH STREQUAL "0")
|
||||
project(DDNet VERSION ${VERSION_MAJOR}.${VERSION_MINOR})
|
||||
else()
|
||||
project(DDNet VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
|
||||
endif()
|
||||
|
||||
set(ORIGINAL_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
|
||||
set(ORIGINAL_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
|
||||
|
@ -116,6 +129,11 @@ if(TEST_MYSQL)
|
|||
set(MYSQL ON)
|
||||
endif()
|
||||
|
||||
# Set version if not explicitly set
|
||||
if(NOT VERSION)
|
||||
set(VERSION ${PROJECT_VERSION})
|
||||
endif()
|
||||
|
||||
set(OpenGL_GL_PREFERENCE LEGACY)
|
||||
|
||||
# Set the default build type to Release
|
||||
|
@ -144,44 +162,10 @@ if(IPO)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
function(get_network_version_number VERSION OUTPUT)
|
||||
string(REPLACE "." ";" VERSION_LIST ${VERSION})
|
||||
|
||||
list(LENGTH VERSION_LIST VERSION_LIST_LENGTH)
|
||||
if("${VERSION_LIST_LENGTH}" GREATER 2)
|
||||
list(GET VERSION_LIST 2 NET_VERSION_PATCH)
|
||||
else()
|
||||
set(NET_VERSION_PATCH 0)
|
||||
endif()
|
||||
if("${VERSION_LIST_LENGTH}" GREATER 1)
|
||||
list(GET VERSION_LIST 1 NET_VERSION_MINOR)
|
||||
else()
|
||||
set(NET_VERSION_MINOR 0)
|
||||
endif()
|
||||
if("${VERSION_LIST_LENGTH}" GREATER 0)
|
||||
list(GET VERSION_LIST 0 NET_VERSION_MAJOR)
|
||||
else()
|
||||
message(SEND_ERROR "Invalid network version \"${VERSION}\"")
|
||||
set(NET_VERSION_MAJOR 0)
|
||||
endif()
|
||||
|
||||
if("0${NET_VERSION_PATCH}" GREATER 9)
|
||||
message(SEND_ERROR "Invalid net patch version (the version is \"${VERSION}\", the patch part must be in range 0-9 if set)")
|
||||
endif()
|
||||
if("0${NET_VERSION_MINOR}" GREATER 99)
|
||||
message(SEND_ERROR "Invalid net minor version (the version is \"${VERSION}\", the minor part must be in range 0-99)")
|
||||
endif()
|
||||
if("0${NET_VERSION_MINOR}" GREATER 9)
|
||||
set(NETWORK_VERSION ${NET_VERSION_MAJOR}${NET_VERSION_MINOR}${NET_VERSION_PATCH})
|
||||
else()
|
||||
set(NETWORK_VERSION ${NET_VERSION_MAJOR}0${NET_VERSION_MINOR}${NET_VERSION_PATCH})
|
||||
endif()
|
||||
set(${OUTPUT} ${NETWORK_VERSION} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
get_network_version_number("${DDNET_NETWORK_VERSION}" DDNET_VERSION_NUMBER)
|
||||
|
||||
configure_file(src/game/version.h.in ${PROJECT_BINARY_DIR}/src/game/version.h)
|
||||
if(NOT "${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
# Remove version.h generated by previous build code
|
||||
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/src/game/version.h)
|
||||
endif()
|
||||
|
||||
set(SERVER_EXECUTABLE DDNet-Server CACHE STRING "Name of the built server executable")
|
||||
set(CLIENT_EXECUTABLE DDNet CACHE STRING "Name of the build client executable")
|
||||
|
@ -403,7 +387,7 @@ function(set_glob VAR GLOBBING EXTS DIRECTORY) # ...
|
|||
endfunction()
|
||||
|
||||
function(set_src VAR GLOBBING DIRECTORY) # ...
|
||||
set_glob(${VAR} ${GLOBBING} "c;cpp;h;h.in" ${DIRECTORY} ${ARGN})
|
||||
set_glob(${VAR} ${GLOBBING} "c;cpp;h" ${DIRECTORY} ${ARGN})
|
||||
set(${VAR} ${${VAR}} PARENT_SCOPE)
|
||||
set(CHECKSUM_SRC ${CHECKSUM_SRC} ${${VAR}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
@ -2020,7 +2004,7 @@ set_src(GAME_SHARED GLOB src/game
|
|||
teamscore.h
|
||||
tuning.h
|
||||
variables.h
|
||||
version.h.in
|
||||
version.h
|
||||
voting.h
|
||||
)
|
||||
# A bit hacky, but these are needed to register all the UUIDs, even for stuff
|
||||
|
@ -2047,7 +2031,6 @@ set(GAME_GENERATED_SHARED
|
|||
src/game/generated/protocol.h
|
||||
src/game/generated/protocol7.h
|
||||
src/game/generated/protocolglue.h
|
||||
src/game/version.h
|
||||
)
|
||||
set(DEPS ${DEP_JSON} ${DEP_MD5} ${ZLIB_DEP})
|
||||
|
||||
|
@ -2921,7 +2904,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})
|
||||
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
||||
set(CPACK_PACKAGE_VERSION ${VERSION})
|
||||
set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
|
||||
|
||||
if(TARGET_OS AND TARGET_BITS)
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
||||
#ifndef GAME_VERSION_H
|
||||
#define GAME_VERSION_H
|
||||
|
||||
#define GAME_RELEASE_VERSION "${PROJECT_VERSION}"
|
||||
#ifndef GAME_RELEASE_VERSION
|
||||
#define GAME_RELEASE_VERSION "17.2.1"
|
||||
#endif
|
||||
#define GAME_VERSION "0.6.4, " GAME_RELEASE_VERSION
|
||||
#define GAME_NETVERSION "0.6 626fce9a778df4d4"
|
||||
#define DDNET_VERSION_NUMBER ${DDNET_VERSION_NUMBER}
|
||||
#define DDNET_VERSION_NUMBER 17021
|
||||
extern const char *GIT_SHORTREV_HASH;
|
||||
#define GAME_NAME "DDNet"
|
||||
#endif
|
Loading…
Reference in a new issue