summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt3
-rw-r--r--cmake/modules/GitRevParse.cmake14
-rw-r--r--kurator/CMakeLists.txt5
-rw-r--r--kurator/src/Title.cpp3
-rw-r--r--kurator/src/version.cpp.conf8
-rw-r--r--kurator/src/version.h10
-rw-r--r--version.txt.conf1
7 files changed, 44 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 145635f..fe35ab7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,9 +8,12 @@ find_package(EnTT 3 REQUIRED)
find_package(nlohmann_json 3 REQUIRED)
find_package(raylib 4 REQUIRED)
include(AddResources)
+include(GitRevParse)
+git_rev_parse(KURATOR_VERSION)
add_subdirectory(campaign)
add_subdirectory(contrib)
add_subdirectory(kurator)
add_subdirectory(sim)
add_subdirectory(stats)
add_subdirectory(universe)
+configure_file(version.txt.conf "${CMAKE_CURRENT_BINARY_DIR}/version.txt" @ONLY)
diff --git a/cmake/modules/GitRevParse.cmake b/cmake/modules/GitRevParse.cmake
new file mode 100644
index 0000000..9005d65
--- /dev/null
+++ b/cmake/modules/GitRevParse.cmake
@@ -0,0 +1,14 @@
+function(git_rev_parse VAR)
+ execute_process(
+ COMMAND git rev-parse --short HEAD
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ RESULT_VARIABLE PARSE_RESULT
+ OUTPUT_VARIABLE PARSE_OUTPUT
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ if(NOT PARSE_RESULT)
+ set(${VAR} ${PARSE_OUTPUT} PARENT_SCOPE)
+ else()
+ set(${VAR} "Unknown" PARENT_SCOPE)
+ endif()
+endfunction()
diff --git a/kurator/CMakeLists.txt b/kurator/CMakeLists.txt
index 2fd6c55..7add534 100644
--- a/kurator/CMakeLists.txt
+++ b/kurator/CMakeLists.txt
@@ -27,6 +27,11 @@ target_link_libraries(
PRIVATE stats
PRIVATE universe
)
+configure_file(src/version.cpp.conf "${CMAKE_CURRENT_BINARY_DIR}/version.cpp" @ONLY)
+target_sources(
+ ${PROJECT_NAME}
+ PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/version.cpp"
+)
add_resources(
kurator_resources FILES
resources/skybox.png
diff --git a/kurator/src/Title.cpp b/kurator/src/Title.cpp
index 2801799..e5d2e2f 100644
--- a/kurator/src/Title.cpp
+++ b/kurator/src/Title.cpp
@@ -8,6 +8,7 @@
#include "SceneBuilder.h"
#include "Session.h"
+#include "version.h"
namespace kurator
@@ -45,6 +46,8 @@ Title::draw() const
const int width = GetScreenWidth();
const int title = MeasureText(text, 20);
DrawText(text, (width - title) / 2, 100, 20, GRAY);
+ const int height = GetScreenHeight();
+ DrawText(VERSION, 10, height - 15, 10, DARKGRAY);
}
diff --git a/kurator/src/version.cpp.conf b/kurator/src/version.cpp.conf
new file mode 100644
index 0000000..a6d0aa0
--- /dev/null
+++ b/kurator/src/version.cpp.conf
@@ -0,0 +1,8 @@
+namespace kurator
+{
+
+
+const char* VERSION {"@KURATOR_VERSION@"};
+
+
+} // namespace kurator
diff --git a/kurator/src/version.h b/kurator/src/version.h
new file mode 100644
index 0000000..cf58629
--- /dev/null
+++ b/kurator/src/version.h
@@ -0,0 +1,10 @@
+#pragma once
+
+namespace kurator
+{
+
+
+extern const char* VERSION;
+
+
+} // namespace kurator
diff --git a/version.txt.conf b/version.txt.conf
new file mode 100644
index 0000000..926d433
--- /dev/null
+++ b/version.txt.conf
@@ -0,0 +1 @@
+@KURATOR_VERSION@