CMAKE:fixup bunch of stuff
- Add saturnpak, saturnjoin, screenfbo settings - Add libbacktrace stuff (hope thats correct) - set openmpt, discordrpc and libbacktrace as optional libs - move asset hashes to d_main, fixing CMAKECONFIG (which fixes commit stuff) - propely handle md5 sources - set "-rdynamic" and "-g" (-g1 on non debug builds) so libbacktrace can get proper backtraces
This commit is contained in:
1 parent
903fffe934
commit
2bc73180bb
7 files changed
+95
-42
No files matched your search
+9
-2
@@ -86,6 +86,12 @@ set(SRB2_CONFIG_ASSET_DIRECTORY "" CACHE PATH "Path to directory that contains a
|
||||
option(SRB2_CONFIG_LTO "Enable link time optimizations, improves performance at the cost of longer link times." ON)
|
||||
option(SRB2_CONFIG_TIDY "Enable clang tiny, checks compiled code for issues at the cost of longer compile times." OFF)
|
||||
|
||||
# man i suck at explaining lmao
|
||||
option(SRB2_CONFIG_SATURNPAK "Enable Saturn specific special packet. Required for using the newer resynch system" ON)
|
||||
option(SRB2_CONFIG_SATURNJOIN "Enable Saturn specific allowjoin toggle." ON)
|
||||
option(SRB2_CONFIG_SCREENFBO "Enable hardware render (OpenGL) FBO downsampling support" ON)
|
||||
option(SRB2_CONFIG_LIBBACKTRACE "Enable using libbacktrace for crashlogs" ON)
|
||||
|
||||
#if(SRB2_CONFIG_ENABLE_TESTS)
|
||||
# https://github.com/catchorg/Catch2
|
||||
# CPMAddPackage(
|
||||
@@ -137,9 +143,10 @@ if("${SRB2_CONFIG_SYSTEM_LIBRARIES}")
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(SDL2_mixer REQUIRED)
|
||||
find_package(CURL REQUIRED)
|
||||
find_package(OPENMPT REQUIRED)
|
||||
find_package(OPENMPT OPTIONAL)
|
||||
find_package(GME REQUIRED)
|
||||
find_package(DiscordRPC REQUIRED)
|
||||
find_package(DiscordRPC OPTIONAL)
|
||||
find_package(libbacktrace OPTIONAL)
|
||||
endif()
|
||||
|
||||
if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR})
|
||||
|
||||
@@ -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()
|
||||
@@ -1,3 +1,4 @@
|
||||
/cscope.out
|
||||
*.json
|
||||
*.idx
|
||||
config.h
|
||||
+24
-1
@@ -37,6 +37,8 @@ endif()
|
||||
target_sourcefile(c)
|
||||
target_sources(SRB2SDL2 PRIVATE comptime.c config.h.in)
|
||||
|
||||
target_sources(SRB2SDL2 PRIVATE md5.c md5.h)
|
||||
|
||||
### Configuration
|
||||
set(SRB2_CONFIG_DEV_BUILD OFF CACHE BOOL
|
||||
"Compile a development build of SRB2Kart.")
|
||||
@@ -91,6 +93,7 @@ add_subdirectory(core)
|
||||
# OS macros
|
||||
if (UNIX)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DUNIXCOMMON)
|
||||
target_link_libraries(SRB2SDL2 PRIVATE -rdynamic) # Use -rdynamic so a backtrace log shows function names
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
@@ -108,6 +111,7 @@ if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DMACOSX)
|
||||
endif()
|
||||
|
||||
# add toggle for this
|
||||
target_link_libraries(SRB2SDL2 PRIVATE openmpt)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_OPENMPT)
|
||||
|
||||
@@ -121,6 +125,11 @@ if(SRB2_CONFIG_ENABLE_DISCORDRPC)
|
||||
target_sources(SRB2SDL2 PRIVATE discord.c)
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_LIBBACKTRACE})
|
||||
target_link_libraries(SRB2SDL2 PRIVATE libbacktrace)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_LIBBACKTRACE)
|
||||
endif()
|
||||
|
||||
set(SRB2_HAVE_THREADS ON)
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_THREADS)
|
||||
|
||||
@@ -226,8 +235,10 @@ target_compile_options(SRB2SDL2 PRIVATE -fwrapv)
|
||||
|
||||
if (${CMAKE_BUILD_TYPE} MATCHES Debug)
|
||||
target_compile_options(SRB2SDL2 PRIVATE -O0)
|
||||
target_compile_options(SRB2SDL2 PRIVATE -g)
|
||||
else()
|
||||
target_compile_options(SRB2SDL2 PRIVATE -O3)
|
||||
target_compile_options(SRB2SDL2 PRIVATE -g1) #should be enough for libbacktrace
|
||||
endif()
|
||||
|
||||
# Compiler warnings configuration
|
||||
@@ -361,7 +372,7 @@ target_link_options(SRB2SDL2 PRIVATE
|
||||
if(${SRB2_CONFIG_DEV_BUILD})
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DDEVELOP)
|
||||
endif()
|
||||
#target_compile_definitions(SRB2SDL2 PRIVATE -DCMAKECONFIG) #TODO: fix this
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DCMAKECONFIG)
|
||||
|
||||
# Misc. build options from Makefiles
|
||||
if(SRB2_CONFIG_DEBUGMODE)
|
||||
@@ -385,6 +396,18 @@ if(SRB2_CONFIG_LTO AND NOT SRB2_CONFIG_DEBUGMODE)
|
||||
set_property(TARGET SRB2SDL2 PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_SCREENFBO} AND NOT ${SRB2_CONFIG_STATIC_OPENGL})
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DUSE_FBO_OGL)
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_SATURNPAK})
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DDOSATURNPAK)
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_SATURNJOIN})
|
||||
target_compile_definitions(SRB2SDL2 PRIVATE -DDOSATURNJOIN)
|
||||
endif()
|
||||
|
||||
# strip debug symbols into separate file when using gcc or clang.
|
||||
# to be consistent with Makefile, don't generate for OS X.
|
||||
if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND NOT ("${CMAKE_SYSTEM_NAME}" MATCHES Darwin))
|
||||
|
||||
@@ -20,7 +20,6 @@ i_tcp.c
|
||||
i_time.c
|
||||
info.c
|
||||
lzf.c
|
||||
md5.c
|
||||
m_aatree.c
|
||||
m_anigif.c
|
||||
m_argv.c
|
||||
|
||||
+3
-38
@@ -11,21 +11,6 @@
|
||||
|
||||
#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_BRANCH "${SRB2_COMP_BRANCH}"
|
||||
|
||||
@@ -33,30 +18,10 @@
|
||||
|
||||
#else
|
||||
|
||||
/* 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
|
||||
*/
|
||||
#define SRB2_COMP_REVISION ""
|
||||
#define SRB2_COMP_BRANCH ""
|
||||
|
||||
// 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
|
||||
#define CMAKE_ASSETS_DIR ""
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -80,6 +80,31 @@
|
||||
#include "lua_script.h"
|
||||
#include "m_random.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
|
||||
#include "config.h"
|
||||
#else
|
||||
|
||||
Reference in new issue
Block a user