mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
cmake: add COMPVERSION_UNCOMMITTED
This commit is contained in:
parent
4db2c48cc3
commit
d80db6f51d
4 changed files with 34 additions and 11 deletions
|
|
@ -117,20 +117,21 @@ set(SRB2_SDL2_EXE_NAME ringracers CACHE STRING "Executable binary output name")
|
|||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
|
||||
|
||||
add_subdirectory(src)
|
||||
if(NOT ${SRB2_CONFIG_DEV_BUILD})
|
||||
add_subdirectory(assets)
|
||||
endif()
|
||||
|
||||
## config.h generation
|
||||
set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
|
||||
include(GitUtilities)
|
||||
git_latest_commit(SRB2_COMP_COMMIT "${CMAKE_SOURCE_DIR}")
|
||||
git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}")
|
||||
git_working_tree_dirty(SRB2_COMP_UNCOMMITTED "${CMAKE_SOURCE_DIR}")
|
||||
set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}")
|
||||
set(SRB2_COMP_REVISION "${SRB2_COMP_COMMIT}")
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
|
||||
|
||||
add_subdirectory(src)
|
||||
if(NOT ${SRB2_CONFIG_DEV_BUILD})
|
||||
add_subdirectory(assets)
|
||||
endif()
|
||||
|
||||
##### PACKAGE CONFIGURATION #####
|
||||
|
||||
set(SRB2_CPACK_GENERATOR "" CACHE STRING "Generator to use for making a package. E.g., ZIP, TGZ, DragNDrop (OSX only). Leave blank for default generator.")
|
||||
|
|
|
|||
|
|
@ -41,3 +41,19 @@ function(git_latest_commit variable path)
|
|||
|
||||
set(${variable} "${output}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_working_tree_dirty variable path)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} "status" "--porcelain" "-uno"
|
||||
WORKING_DIRECTORY "${path}"
|
||||
RESULT_VARIABLE result
|
||||
OUTPUT_VARIABLE output
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
if(output STREQUAL "")
|
||||
set(${variable} FALSE PARENT_SCOPE)
|
||||
else()
|
||||
set(${variable} TRUE PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
|
@ -15,6 +15,12 @@ const char *comprevision = SRB2_COMP_REVISION;
|
|||
#elif (defined(COMPVERSION))
|
||||
#include "comptime.h"
|
||||
|
||||
#else
|
||||
const char *compbranch = "Unknown";
|
||||
const char *comprevision = "illegal";
|
||||
|
||||
#endif
|
||||
|
||||
const int compuncommitted =
|
||||
#if (defined(COMPVERSION_UNCOMMITTED))
|
||||
1;
|
||||
|
|
@ -22,11 +28,5 @@ const int compuncommitted =
|
|||
0;
|
||||
#endif
|
||||
|
||||
#else
|
||||
const char *compbranch = "Unknown";
|
||||
const char *comprevision = "illegal";
|
||||
|
||||
#endif
|
||||
|
||||
const char *compdate = __DATE__;
|
||||
const char *comptime = __TIME__;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,12 @@
|
|||
|
||||
#define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}"
|
||||
#define SRB2_COMP_BRANCH "${SRB2_COMP_BRANCH}"
|
||||
// This is done with configure_file instead of defines in order to avoid
|
||||
// recompiling the whole target whenever the working directory state changes
|
||||
#cmakedefine SRB2_COMP_UNCOMMITTED
|
||||
#ifdef SRB2_COMP_UNCOMMITTED
|
||||
#define COMPVERSION_UNCOMMITTED
|
||||
#endif
|
||||
|
||||
#define CMAKE_ASSETS_DIR "${CMAKE_SOURCE_DIR}/assets"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue