diff --git a/cmake/Modules/GitUtilities.cmake b/cmake/Modules/GitUtilities.cmake index bddc552a6..cad925bd2 100644 --- a/cmake/Modules/GitUtilities.cmake +++ b/cmake/Modules/GitUtilities.cmake @@ -50,7 +50,7 @@ function(git_working_tree_dirty variable) endif() endfunction() -function(git_summary variable) +function(git_subject variable) _git_easy_command(log -1 "--format=%h %s") endfunction() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 286a44f7c..b9c4cd15e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -150,6 +150,35 @@ set(SRB2_CONFIG_TESTERS OFF CACHE BOOL "Compile a build for testers.") set(SRB2_CONFIG_HOSTTESTERS OFF CACHE BOOL "Compile a build to host netgames for testers builds.") + +set(SRB2_CONFIG_SKIP_COMPTIME OFF CACHE BOOL + "Skip Comptime rebuild.") + +if(NOT SRB2_CONFIG_SKIP_COMPTIME) + # This updates the modification time for comptime.c at the + # end of building so when the build system is ran next time, + # that file gets flagged. comptime.c will always be rebuilt. + # + # This begs the question, why always rebuild comptime.c? + # Some things like the git commit must be checked each time + # the program is built. But the build system determines which + # files should be rebuilt before anything else. So + # comptime.c, which only needs to be rebuilt based on + # information known at build time, must be told to rebuild + # before that information can be ascertained. + add_custom_command( + TARGET SRB2SDL2 + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${CMAKE_CURRENT_SOURCE_DIR}/comptime.c + ) +endif() + +set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary") +add_custom_target(_SRB2_reconf ALL + COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/.. -P ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/Comptime.cmake + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.." +) +add_dependencies(SRB2SDL2 _SRB2_reconf) add_subdirectory(blua) add_subdirectory(blan) diff --git a/src/config.h.in b/src/config.h.in index bcd28add7..aa8cd4aa1 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -9,22 +9,7 @@ * variables, so you can insert them here too. */ -#ifdef CMAKECONFIG - -#define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}" -#define SRB2_COMP_BRANCH "${SRB2_COMP_BRANCH}" -#define SRB2_COMP_LASTCOMMIT "${SRB2_COMP_LASTCOMMIT}" -// 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 - -#endif - - -/* Manually defined asset hashes for non-CMake builds +/* Manually defined asset hashes * Last updated 2019 / 01 / 18 - Kart v1.0.2 - Main assets * Last updated 2020 / 08 / 30 - Kart v1.3 - patch.kart */ @@ -39,9 +24,24 @@ #define ASSET_HASH_PATCH_PK3 "00000000000000000000000000000000" #endif +#ifdef CMAKECONFIG + +#define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}" +#define SRB2_COMP_BRANCH "${SRB2_COMP_BRANCH}" +#define SRB2_COMP_LASTCOMMIT "${SRB2_COMP_LASTCOMMIT}" +// 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 + +#else + #define SRB2_COMP_LASTCOMMIT "" #define SRB2_COMP_REVISION "" #define SRB2_COMP_BRANCH "" #endif + #endif