diff --git a/cmake/Comptime.cmake b/cmake/Comptime.cmake index 3859c2aad..ddd79536e 100644 --- a/cmake/Comptime.cmake +++ b/cmake/Comptime.cmake @@ -1,3 +1,5 @@ +cmake_minimum_required(VERSION 3.3 FATAL_ERROR) + set(CMAKE_BINARY_DIR "${BINARY_DIR}") set(CMAKE_CURRENT_BINARY_DIR "${BINARY_DIR}") @@ -10,4 +12,18 @@ git_current_branch(SRB2_COMP_BRANCH) git_summary(SRB2_COMP_REVISION) git_working_tree_dirty(SRB2_COMP_UNCOMMITTED) +if("${CMAKE_BUILD_TYPE}" STREQUAL "") + set(CMAKE_BUILD_TYPE None) +endif() + +# These build types enable optimizations of some kind by default. +set(optimized_build_types "MINSIZEREL;RELEASE;RELWITHDEBINFO") + +string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type) +if("${build_type}" IN_LIST optimized_build_types) + set(SRB2_COMP_OPTIMIZED TRUE) +else() + set(SRB2_COMP_OPTIMIZED FALSE) +endif() + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/src/config.h") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 148d12ff4..7293393cb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -154,7 +154,7 @@ add_custom_command( # build time for accurate git information and before anything # that needs it, obviously. add_custom_target(_SRB2_reconf ALL - COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/.. -P ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/Comptime.cmake + 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) diff --git a/src/comptime.c b/src/comptime.c index 2baef79d6..74b810062 100644 --- a/src/comptime.c +++ b/src/comptime.c @@ -11,6 +11,8 @@ #include "config.h" const char *compbranch = SRB2_COMP_BRANCH; const char *comprevision = SRB2_COMP_REVISION; +const char *comptype = CMAKE_BUILD_TYPE; +const int compoptimized = SRB2_COMP_OPTIMIZED; #elif (defined(COMPVERSION)) #include "comptime.h" diff --git a/src/config.h.in b/src/config.h.in index d7b67cdce..77a205a74 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -20,6 +20,9 @@ #define COMPVERSION_UNCOMMITTED #endif +#define CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" +#cmakedefine01 SRB2_COMP_OPTIMIZED + #endif /* Manually defined asset hashes for non-CMake builds diff --git a/src/d_netcmd.c b/src/d_netcmd.c index df3b86bcf..5d3e00830 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4774,16 +4774,13 @@ static void Command_Version_f(void) else // 16-bit? 128-bit? CONS_Printf("Bits Unknown "); + CONS_Printf("%s ", comptype); + // No ASM? #ifdef NOASM CONS_Printf("\x85" "NOASM " "\x80"); #endif - // Debug build -#ifdef _DEBUG - CONS_Printf("\x85" "DEBUG " "\x80"); -#endif - // DEVELOP build #if defined(TESTERS) CONS_Printf("\x88" "TESTERS " "\x80"); diff --git a/src/doomdef.h b/src/doomdef.h index 09a5efa4a..72ba17a84 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -664,7 +664,8 @@ UINT32 quickncasehash (const char *p, size_t n) // Compile date and time and revision. extern const char *compdate, *comptime, *comprevision, *compbranch; -extern int compuncommitted; +extern int compuncommitted, compoptimized; +extern const char *comptype; // Disabled code and code under testing // None of these that are disabled in the normal build are guaranteed to work perfectly diff --git a/src/f_finale.c b/src/f_finale.c index bbac13838..36ca452f9 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1918,6 +1918,15 @@ void F_VersionDrawer(void) #else // Regular build addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, va("%s", VERSIONSTRING)); #endif + if (compoptimized) + { + addtext(V_ALLOWLOWERCASE|V_TRANSLUCENT, va("%s build", comptype)); + } + else + { + addtext(V_ALLOWLOWERCASE|V_ORANGEMAP, va("%s build (no optimizations)", comptype)); + } + if (compuncommitted) { addtext(V_REDMAP|V_STRINGDANCE, "! UNCOMMITTED CHANGES !");