Skip to content

Commit

Permalink
Hardcode the project version
Browse files Browse the repository at this point in the history
Since the build version is actually the date the build was run, if it is
rebuilt on a different day it becomes erroneous. For example, since in
any distribution the build into the image will most likely occur after
the release, or even rebuild it regularly, the version will differ from
the release one, which can be misleading.

There is also a second part of the version - the commit hash, but if the
stable version is (re)built from the source archive (which is correct),
there is no git repo at all.

So now it will be specified manually in CMakeLists, so that it
unambiguously indicates the version of the game.

Also made PROJECT_VERSION a cache variable, so that it is possible to
arbitrarily specify the version via command line arguments. It will be
useful for CI.

Also add PROJECT_VERSION_INFO cache variable. This variable is empty by
default. If it contains anything, it will be added to the commit hash in
the version, for example:

20240105 (340f22c extra-info)

If the git repo is not available, only the string from the new variable
will be in parentheses.
  • Loading branch information
Gliese852 authored and Webster Sheets committed Jan 20, 2024
1 parent 6cb8e7b commit 9999f36
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ project(pioneer LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 17)

set(PROJECT_VERSION 20230203-dev
CACHE STRING "Version identifier for current compiled build")

set(PROJECT_VERSION_INFO ""
CACHE STRING "Additional version information (optional)")

# If both libGL.so and libOpenGL.so are found, default to the latter
# (former is a legacy name).
# Set OpenGL_GL_PREFERENCE=LEGACY to force it to use the former.
Expand Down Expand Up @@ -118,7 +124,9 @@ if (GIT_FOUND AND EXISTS ${PROJECT_SOURCE_DIR}/.git)
)
endif()

string(TIMESTAMP PROJECT_VERSION "%Y%m%d")
if(DEFINED PROJECT_VERSION_GIT)
string(JOIN " " PROJECT_VERSION_INFO ${PROJECT_VERSION_GIT} ${PROJECT_VERSION_INFO})
endif()

if (MINGW)
# Enable PRIxYY macros on MinGW
Expand Down
2 changes: 1 addition & 1 deletion buildopts.h.cmakein
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef BUILDOPTS_H
#define BUILDOPTS_H

#define PIONEER_EXTRAVERSION "@PROJECT_VERSION_GIT@"
#define PIONEER_EXTRAVERSION "@PROJECT_VERSION_INFO@"
#define PIONEER_VERSION "@PROJECT_VERSION@"
#define PIONEER_DATA_DIR "@PIONEER_DATA_RUNTIME_DIR@"
#define REMOTE_LUA_REPL_PORT @REMOTE_LUA_REPL_PORT@
Expand Down

0 comments on commit 9999f36

Please sign in to comment.