Skip to content

Commit

Permalink
Show the Git revision info in the title bar
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatyas committed Apr 1, 2024
1 parent 93debe7 commit 208dd7e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ endif()
# Set where the binary files will be built.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

include(SmwGitInfo)

#-----------------------------------------------------------------------------
#
# Platform-specific settings
Expand Down
23 changes: 23 additions & 0 deletions cmake/SmwGitInfo.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
find_package(Git)
if(GIT_FOUND)
execute_process(COMMAND
"${GIT_EXECUTABLE}"
--git-dir "${PROJECT_SOURCE_DIR}/.git"
--work-tree "${PROJECT_SOURCE_DIR}"
describe
--always
--dirty
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE SMW_GIT_REVISION
)
execute_process(COMMAND
"${GIT_EXECUTABLE}"
--git-dir "${PROJECT_SOURCE_DIR}/.git"
--work-tree "${PROJECT_SOURCE_DIR}"
log -1
--format=%cd
--date=short
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE SMW_GIT_DATE
)
endif()
4 changes: 4 additions & 0 deletions src/smw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ add_subdirectory(gamemodes)
add_subdirectory(ui)

target_compile_features(smw PUBLIC cxx_std_14)
target_compile_definitions(smw PRIVATE
GIT_REVISION="${SMW_GIT_REVISION}"
GIT_DATE="${SMW_GIT_DATE}"
)

if(NO_NETWORK)
target_compile_definitions(smw PRIVATE NETWORK_DISABLED)
Expand Down
2 changes: 1 addition & 1 deletion src/smw/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void main_game()
//currently this only sets the title, not the icon.
//setting the icon isn't implemented in sdl -> i'll ask on the mailing list
char title[128];
sprintf(title, "%s %s", TITLESTRING, VERSIONNUMBER);
sprintf(title, "%s %s %s %s", TITLESTRING, VERSIONNUMBER, GIT_REVISION, GIT_DATE);
gfx_settitle(title);
SDL_ShowCursor(SDL_DISABLE);

Expand Down

0 comments on commit 208dd7e

Please sign in to comment.