Skip to content

Commit ed6f19f

Browse files
committed
Add git tag-based version display
- Local/dev builds show "Development" in window title - Tagged builds show the git tag (e.g., "v1.2.0") - Version is determined at CMake configure time via git describe
1 parent d00ffb2 commit ed6f19f

3 files changed

Lines changed: 44 additions & 5 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,41 @@ set(VERSION_MAJOR "1")
1111
set(VERSION_MINOR "1")
1212
set(VERSION_PATCH "0")
1313

14+
# Determine version string from git
15+
# - If HEAD is exactly on a tag: use the tag (e.g., "v1.2.0")
16+
# - Otherwise: use "Development"
17+
find_package(Git QUIET)
18+
if(GIT_FOUND)
19+
# Check if we're exactly on a tag
20+
execute_process(
21+
COMMAND ${GIT_EXECUTABLE} describe --tags --exact-match
22+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
23+
OUTPUT_VARIABLE GIT_TAG
24+
OUTPUT_STRIP_TRAILING_WHITESPACE
25+
ERROR_QUIET
26+
RESULT_VARIABLE GIT_TAG_RESULT
27+
)
28+
if(GIT_TAG_RESULT EQUAL 0)
29+
# We're on a tag - use it as version
30+
set(EDITOR_VERSION_STRING "${GIT_TAG}")
31+
else()
32+
# Not on a tag - development build
33+
set(EDITOR_VERSION_STRING "Development")
34+
endif()
35+
else()
36+
# Git not found - fallback
37+
set(EDITOR_VERSION_STRING "Development")
38+
endif()
39+
40+
message(STATUS "Editor version: ${EDITOR_VERSION_STRING}")
41+
42+
# Generate version header
43+
configure_file(
44+
${CMAKE_SOURCE_DIR}/src/version.h.in
45+
${CMAKE_BINARY_DIR}/generated/version.h
46+
@ONLY
47+
)
48+
1449
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR})
1550

1651

@@ -223,7 +258,7 @@ elseif (UNIX)
223258
elseif (MSVC)
224259
target_compile_definitions(${RKT_EXE_NAME} PUBLIC -DEMGUI_WIN32)
225260
endif ()
226-
target_include_directories(${RKT_EXE_NAME} PUBLIC ${RKT_PROJECT_INCLUDES})
261+
target_include_directories(${RKT_EXE_NAME} PUBLIC ${RKT_PROJECT_INCLUDES} ${CMAKE_BINARY_DIR}/generated)
227262
target_link_libraries(${RKT_EXE_NAME} ${RKT_PROJECT_LIBS})
228263

229264
# compile the nibs

‎src/Editor.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#pragma once
22

33
#include <emgui/Types.h>
4+
#include "version.h"
45

56
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
67

8+
// Version string with padding for window title display
9+
#define EDITOR_VERSION _T(" " EDITOR_VERSION_STRING " ")
10+
711
void Editor_create(void);
812
void Editor_destroy(void);
913
void Editor_init(void);
@@ -22,7 +26,3 @@ bool Editor_needsSave(void);
2226
void Editor_setLoadedFilename(const text_t* filename);
2327
struct TrackData* Editor_getTrackData(void);
2428
text_t** Editor_getRecentFiles(void);
25-
26-
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
27-
28-
#define EDITOR_VERSION _T(" 1.2 Beta 1 ")

‎src/version.h.in‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Auto-generated by CMake - do not edit
2+
#pragma once
3+
4+
#define EDITOR_VERSION_STRING "@EDITOR_VERSION_STRING@"

0 commit comments

Comments
 (0)