more cmake fixups

- skip asset install for linux
- pass fwrapv flag
- fix asset hash stuff
- pass rdynamic flag
- add saturn specific stuff, saturnpak, saturnjoin, libbacktrace and fix screen fbo stuff
This commit is contained in:
Alug committed 2026-01-21 19:09:50 +01:00
1 parent f7bbde3982
commit cb2c65e9d9
7 files changed
+116 -49

No files matched your search

+1
View File
@@ -77,6 +77,7 @@ endif()
# OS macros # OS macros
if (UNIX) if (UNIX)
add_definitions(-DUNIXCOMMON) add_definitions(-DUNIXCOMMON)
add_link_options(-rdynamic) # Use -rdynamic so a backtrace log shows function names
endif() endif()
if(CMAKE_COMPILER_IS_GNUCC) if(CMAKE_COMPILER_IS_GNUCC)
+5
View File
@@ -1,5 +1,10 @@
## Assets Target Configuration ## ## Assets Target Configuration ##
if(${CMAKE_SYSTEM} MATCHES Linux)
# Asset installation isn't part of the Linux target
return()
endif()
# For prepending the current source path, later # For prepending the current source path, later
FUNCTION(PREPEND var prefix) FUNCTION(PREPEND var prefix)
SET(listVar "") SET(listVar "")
+33
View File
@@ -0,0 +1,33 @@
include(LibFindMacros)
libfind_pkg_check_modules(LIBBACKTRACE_PKGCONF LIBBACKTRACE)
find_path(LIBBACKTRACE_INCLUDE_DIR
NAMES backtrace.h
PATHS
${LIBBACKTRACE_PKGCONF_INCLUDE_DIRS}
"/usr/include"
"/usr/local/include"
)
find_library(LIBBACKTRACE_LIBRARY
NAMES backtrace
PATHS
${LIBBACKTRACE_PKGCONF_LIBRARY_DIRS}
"/usr/lib"
"/usr/local/lib"
)
set(LIBBACKTRACE_PROCESS_INCLUDES LIBBACKTRACE_INCLUDE_DIR)
set(LIBBACKTRACE_PROCESS_LIBS LIBBACKTRACE_LIBRARY)
libfind_process(LIBBACKTRACE)
if(LIBBACKTRACE_FOUND AND NOT TARGET libbacktrace)
add_library(libbacktrace UNKNOWN IMPORTED)
set_target_properties(
libbacktrace
PROPERTIES
IMPORTED_LOCATION "${LIBBACKTRACE_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${LIBBACKTRACE_INCLUDE_DIR}"
)
endif()
+44 -11
View File
@@ -240,11 +240,19 @@ set(SRB2_CONFIG_HWRENDER ON CACHE BOOL
"Enable hardware rendering through OpenGL.") "Enable hardware rendering through OpenGL.")
set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL
"Use statically linked OpenGL. NOT RECOMMENDED.") "Use statically linked OpenGL. NOT RECOMMENDED.")
set(SRB2_CONFIG_USE_FBO_OGL ON CACHE BOOL set(SRB2_CONFIG_SCREENFBO ON CACHE BOOL
"Enable OpenGL FBO Downsampling support.") "Enable hardware renderer (OpenGL) FBO downsampling support")
set(SRB2_CONFIG_DEDICATED OFF CACHE BOOL set(SRB2_CONFIG_DEDICATED OFF CACHE BOOL
"Build a dedicated server.") "Build a dedicated server.")
set(SRB2_CONFIG_SATURNPAK ON CACHE BOOL
"Enable Saturn specific special packet. Required for using the newer resynch system")
set(SRB2_CONFIG_SATURNJOIN ON CACHE BOOL
"Enable Saturn specific allowjoin toggle.")
set(SRB2_CONFIG_LIBBACKTRACE ON CACHE BOOL
"Enable using libbacktrace for crashlogs")
if(${SRB2_CONFIG_DEDICATED}) if(${SRB2_CONFIG_DEDICATED})
set(SRB2_CONFIG_HAVE_GME NO) set(SRB2_CONFIG_HAVE_GME NO)
set(SRB2_CONFIG_HAVE_OPENMPT NO) set(SRB2_CONFIG_HAVE_OPENMPT NO)
@@ -483,6 +491,27 @@ if(${SRB2_CONFIG_HAVE_CURL})
endif() endif()
endif() endif()
if(${SRB2_CONFIG_LIBBACKTRACE})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(LIBBACKTRACE_FOUND ON)
set(LIBBACKTRACE_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/libbacktrace/include)
set(LIBBACKTRACE_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libbacktrace/lib/x86_64 -lbacktrace")
else() # 32-bit
message(WARNING "libbacktrace is unsupported on 32-bit builds.")
endif()
else()
find_package(libbacktrace)
endif()
if(${LIBBACKTRACE_FOUND})
set(SRB2_HAVE_LIBBACKTRACE ON)
add_definitions(-DHAVE_LIBBACKTRACE)
add_compile_options(-g)
else()
message(WARNING "You have specified that libbacktrace is available but it was not found.")
endif()
endif()
if(${SRB2_CONFIG_HWRENDER}) if(${SRB2_CONFIG_HWRENDER})
add_definitions(-DHWRENDER) add_definitions(-DHWRENDER)
set(SRB2_HWRENDER_SOURCES set(SRB2_HWRENDER_SOURCES
@@ -536,29 +565,33 @@ if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL})
else() else()
message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.") message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.")
endif() endif()
endif()
if(${SRB2_CONFIG_HWRENDER}) if(${SRB2_CONFIG_SCREENFBO})
if(${SRB2_CONFIG_USE_FBO_OGL})
set(SRB2_USE_FBO_OGL ON)
add_definitions(-DUSE_FBO_OGL) add_definitions(-DUSE_FBO_OGL)
endif() endif()
endif() endif()
if(${SRB2_CONFIG_SATURNPAK})
add_definitions(-DDOSATURNPAK)
endif()
if(${SRB2_CONFIG_SATURNJOIN})
add_definitions(-DDOSATURNJOIN)
endif()
# Targets # Targets
# Compatibility flag with later versions of GCC # Compatibility flag with later versions of GCC
# We should really fix our code to not need this # We should really fix our code to not need this
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|x64|amd64|AMD64|em64t|EM64T)") if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|x64|amd64|AMD64|em64t|EM64T)")
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -mno-ms-bitfields) add_compile_options(-mno-ms-bitfields)
endif() endif()
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-trigraphs) add_compile_options(-Wno-trigraphs)
endif() endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") # TODO: fix prng and P_CreateBlockmap overflow at some point
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-absolute-value) add_compile_options(-fwrapv)
endif()
add_definitions(-DCMAKECONFIG) add_definitions(-DCMAKECONFIG)
+3 -38
View File
@@ -11,21 +11,6 @@
#ifdef CMAKECONFIG #ifdef CMAKECONFIG
// Base SRB2 hashes
#define ASSET_HASH_SRB2_SRB "${SRB2_ASSET_srb2.srb_HASH}"
#ifdef USE_PATCH_DTA
#define ASSET_HASH_PATCH_DTA "${SRB2_ASSET_patch.dta_HASH}"
#endif
// SRB2Kart-specific hashes
#define ASSET_HASH_GFX_KART "${SRB2_ASSET_gfx.kart_HASH}"
#define ASSET_HASH_TEXTURES_KART "${SRB2_ASSET_textures.kart_HASH}"
#define ASSET_HASH_CHARS_KART "${SRB2_ASSET_chars.kart_HASH}"
#define ASSET_HASH_MAPS_KART "${SRB2_ASSET_maps.kart_HASH}"
#ifdef USE_PATCH_KART
#define ASSET_HASH_PATCH_KART "00000000000000000000000000000000"
#endif
#define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}" #define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}"
#define SRB2_COMP_BRANCH "${SRB2_COMP_BRANCH}" #define SRB2_COMP_BRANCH "${SRB2_COMP_BRANCH}"
@@ -33,30 +18,10 @@
#else #else
/* Manually defined asset hashes for non-CMake builds #define SRB2_COMP_REVISION ""
* Last updated 2015 / 05 / 03 - SRB2 v2.1.15 - srb2.srb #define SRB2_COMP_BRANCH ""
* Last updated 2018 / 12 / 23 - SRB2 v2.1.22 - patch.dta
* Last updated 2019 / 01 / 18 - Kart v1.0.2 - Main assets
* Last updated 2020 / 08 / 30 - Kart v1.3 - patch.kart
* Last updated 2022 / 08 / 16 - Kart v1.4 - Main assets
* Last updated 2022 / 08 / 19 - Kart v1.5 - gfx.kart
* Last updated 2022 / 11 / 01 - Kart v1.6 - gfx.kart, maps.kart
*/
// Base SRB2 hashes #define CMAKE_ASSETS_DIR ""
#define ASSET_HASH_SRB2_SRB "c1b9577687f8a795104aef4600720ea7"
#ifdef USE_PATCH_DTA
#define ASSET_HASH_PATCH_DTA "b04fd9624bfd94dc96dcf4f400f7deb4"
#endif
// SRB2Kart-specific hashes
#define ASSET_HASH_GFX_KART "06f86ee16136eb8a7043b15001797034"
#define ASSET_HASH_TEXTURES_KART "abb53d56aba47c3a8cb0f764da1c8b80"
#define ASSET_HASH_CHARS_KART "e2c428347dde52858a3dacd29fc5b964"
#define ASSET_HASH_MAPS_KART "d051e55141ba736582228c456953cd98"
#ifdef USE_PATCH_KART
#define ASSET_HASH_PATCH_KART "00000000000000000000000000000000"
#endif
#endif #endif
#endif #endif
+25
View File
@@ -80,6 +80,31 @@
#include "lua_script.h" #include "lua_script.h"
/* Manually defined asset hashes for non-CMake builds
* Last updated 2015 / 05 / 03 - SRB2 v2.1.15 - srb2.srb
* Last updated 2018 / 12 / 23 - SRB2 v2.1.22 - patch.dta
* Last updated 2019 / 01 / 18 - Kart v1.0.2 - Main assets
* Last updated 2020 / 08 / 30 - Kart v1.3 - patch.kart
* Last updated 2022 / 08 / 16 - Kart v1.4 - Main assets
* Last updated 2022 / 08 / 19 - Kart v1.5 - gfx.kart
* Last updated 2022 / 11 / 01 - Kart v1.6 - gfx.kart, maps.kart
*/
// Base SRB2 hashes
#define ASSET_HASH_SRB2_SRB "c1b9577687f8a795104aef4600720ea7"
#ifdef USE_PATCH_DTA
#define ASSET_HASH_PATCH_DTA "b04fd9624bfd94dc96dcf4f400f7deb4"
#endif
// SRB2Kart-specific hashes
#define ASSET_HASH_GFX_KART "06f86ee16136eb8a7043b15001797034"
#define ASSET_HASH_TEXTURES_KART "abb53d56aba47c3a8cb0f764da1c8b80"
#define ASSET_HASH_CHARS_KART "e2c428347dde52858a3dacd29fc5b964"
#define ASSET_HASH_MAPS_KART "d051e55141ba736582228c456953cd98"
#ifdef USE_PATCH_KART
#define ASSET_HASH_PATCH_KART "00000000000000000000000000000000"
#endif
#ifdef CMAKECONFIG #ifdef CMAKECONFIG
#include "config.h" #include "config.h"
#else #else
+5
View File
@@ -165,6 +165,11 @@ if(${SDL2_FOUND})
${DISCORDRPC_LIBRARIES} ${DISCORDRPC_LIBRARIES}
) )
if(${SRB2_HAVE_LIBBACKTRACE})
target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES})
endif()
if(${CMAKE_SYSTEM} MATCHES Linux) if(${CMAKE_SYSTEM} MATCHES Linux)
target_link_libraries(SRB2SDL2 PRIVATE target_link_libraries(SRB2SDL2 PRIVATE
m m