mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-10 18:12:46 +00:00
(This commit does not compile. Sound test and tunes command code needs to be ported after this.) This is a big one. Here's the rundown: The old music system was very direct, much of the time just a proxy to the real sound API in i_sound.h. You could change the music on command, but there wasn't a consistent way to prevent some music from playing over others. P_RestoreMusic is one example of needing to address this problem. The jingles system was intended as another solution. Furthermore, sound test (Stereo) has its own needs. I am removing all of that. Music handling in general is now a very deliberate system, kind of similar to jingles. In the new system, "tunes" are registered. The tune stores info such as whether it should loop or fade out. Most of the configuration is intended to be initialized only ONCE. Tunes can be mapped to an actual music lump. They can be remapped at any time too. Tunes are also configured with a priority number. This determines which tune is heard, if multiple are supposed to be playing at a time. You can even tell a tune how long it should play, so it's unnecessary to track this with bespoke timers.
632 lines
17 KiB
CMake
632 lines
17 KiB
CMake
add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32
|
|
comptime.c
|
|
cxxutil.hpp
|
|
md5.c
|
|
config.h.in
|
|
string.c
|
|
d_main.c
|
|
d_clisrv.c
|
|
d_net.c
|
|
d_netfil.c
|
|
d_netcmd.c
|
|
dehacked.c
|
|
deh_soc.c
|
|
deh_lua.c
|
|
deh_tables.c
|
|
z_zone.c
|
|
f_finale.c
|
|
f_wipe.c
|
|
g_demo.c
|
|
g_game.c
|
|
g_input.c
|
|
g_party.cpp
|
|
am_map.c
|
|
command.c
|
|
console.c
|
|
font.c
|
|
hu_stuff.c
|
|
i_time.c
|
|
i_video_common.cpp
|
|
y_inter.c
|
|
st_stuff.c
|
|
m_aatree.c
|
|
m_anigif.c
|
|
m_argv.c
|
|
m_bbox.c
|
|
m_cheat.c
|
|
m_cond.c
|
|
m_easing.c
|
|
m_fixed.c
|
|
m_memcpy.c
|
|
m_misc.cpp
|
|
m_perfstats.c
|
|
m_random.c
|
|
m_queue.c
|
|
info.c
|
|
p_ceilng.c
|
|
p_enemy.c
|
|
p_floor.c
|
|
p_inter.c
|
|
p_lights.c
|
|
p_loop.c
|
|
p_map.c
|
|
p_mapthing.cpp
|
|
p_maputl.c
|
|
p_mobj.c
|
|
p_polyobj.c
|
|
p_saveg.c
|
|
p_setup.c
|
|
p_sight.c
|
|
p_spec.c
|
|
p_telept.c
|
|
p_tick.c
|
|
p_user.c
|
|
p_slopes.c
|
|
tables.c
|
|
r_bsp.cpp
|
|
r_data.c
|
|
r_debug.cpp
|
|
r_debug_parser.cpp
|
|
r_draw.c
|
|
r_fps.c
|
|
r_main.c
|
|
r_plane.c
|
|
r_segs.cpp
|
|
r_skins.c
|
|
r_sky.c
|
|
r_splats.c
|
|
r_spritefx.cpp
|
|
r_things.c
|
|
r_bbox.c
|
|
r_textures.c
|
|
r_textures_dups.cpp
|
|
r_patch.cpp
|
|
r_patchrotation.c
|
|
r_picformats.c
|
|
r_portal.c
|
|
screen.c
|
|
taglist.c
|
|
v_draw.cpp
|
|
v_video.cpp
|
|
s_sound.c
|
|
sounds.c
|
|
w_wad.c
|
|
filesrch.c
|
|
mserv.c
|
|
http-mserv.c
|
|
i_tcp.c
|
|
lzf.c
|
|
vid_copy.s
|
|
lua_script.c
|
|
lua_baselib.c
|
|
lua_mathlib.c
|
|
lua_hooklib.c
|
|
lua_consolelib.c
|
|
lua_infolib.c
|
|
lua_mobjlib.c
|
|
lua_playerlib.c
|
|
lua_skinlib.c
|
|
lua_thinkerlib.c
|
|
lua_maplib.c
|
|
lua_taglib.c
|
|
lua_polyobjlib.c
|
|
lua_blockmaplib.c
|
|
lua_hudlib.c
|
|
lua_hudlib_drawlist.c
|
|
k_kart.c
|
|
k_respawn.c
|
|
k_collide.cpp
|
|
k_color.c
|
|
k_race.c
|
|
k_battle.c
|
|
k_pwrlv.c
|
|
k_waypoint.cpp
|
|
k_pathfind.c
|
|
k_bheap.c
|
|
k_bot.c
|
|
k_botitem.c
|
|
k_botsearch.c
|
|
k_grandprix.c
|
|
k_boss.c
|
|
k_hud.c
|
|
k_hud_track.cpp
|
|
k_menufunc.c
|
|
k_menudraw.c
|
|
k_terrain.c
|
|
k_brightmap.c
|
|
k_terrain.c
|
|
k_director.c
|
|
k_follower.c
|
|
k_profiles.c
|
|
k_specialstage.c
|
|
k_roulette.c
|
|
k_podium.c
|
|
k_rank.c
|
|
k_vote.c
|
|
k_serverstats.c
|
|
k_zvote.c
|
|
k_mapuser.c
|
|
k_powerup.cpp
|
|
k_hitlag.c
|
|
music.cpp
|
|
music_manager.cpp
|
|
)
|
|
|
|
if(SRB2_CONFIG_ENABLE_WEBM_MOVIES)
|
|
target_sources(SRB2SDL2 PRIVATE m_avrecorder.cpp)
|
|
endif()
|
|
|
|
# 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
|
|
)
|
|
|
|
# config.h is generated by this command. It should be done at
|
|
# 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} -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)
|
|
|
|
if("${CMAKE_COMPILER_IS_GNUCC}" AND "${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
|
|
target_link_options(SRB2SDL2 PRIVATE "-Wl,--disable-dynamicbase")
|
|
if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}" AND NOT "${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}")
|
|
# On MinGW with internal libraries, link the standard library statically
|
|
target_link_options(SRB2SDL2 PRIVATE "-static")
|
|
endif()
|
|
endif()
|
|
|
|
target_compile_features(SRB2SDL2 PRIVATE c_std_11 cxx_std_17)
|
|
|
|
set(SRB2_ASM_SOURCES vid_copy.s)
|
|
|
|
set(SRB2_NASM_SOURCES tmap_mmx.nas tmap.nas)
|
|
|
|
### Configuration
|
|
set(SRB2_CONFIG_USEASM OFF CACHE BOOL
|
|
"Enable NASM tmap implementation for software mode speedup.")
|
|
set(SRB2_CONFIG_YASM OFF CACHE BOOL
|
|
"Use YASM in place of NASM.")
|
|
set(SRB2_CONFIG_DEV_BUILD OFF CACHE BOOL
|
|
"Compile a development build of Dr Robotnik's Ring Racers.")
|
|
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.")
|
|
|
|
add_subdirectory(blua)
|
|
|
|
# OS macros
|
|
if (UNIX)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DUNIXCOMMON)
|
|
endif()
|
|
|
|
if(CMAKE_COMPILER_IS_GNUCC)
|
|
find_program(OBJCOPY objcopy)
|
|
endif()
|
|
|
|
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DLINUX)
|
|
if(${SRB2_SYSTEM_BITS} EQUAL 64)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DLINUX64)
|
|
endif()
|
|
endif()
|
|
|
|
if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DMACOSX)
|
|
endif()
|
|
|
|
target_link_libraries(SRB2SDL2 PRIVATE gme)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_GME)
|
|
if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
|
|
# this sucks but gme doesn't use modern cmake to delineate public headers
|
|
target_include_directories(SRB2SDL2 PRIVATE "${libgme_SOURCE_DIR}")
|
|
endif()
|
|
|
|
target_link_libraries(SRB2SDL2 PRIVATE ZLIB::ZLIB PNG::PNG CURL::libcurl)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_ZLIB -DHAVE_PNG -DHAVE_CURL -D_LARGEFILE64_SOURCE)
|
|
target_sources(SRB2SDL2 PRIVATE apng.c)
|
|
|
|
target_link_libraries(SRB2SDL2 PRIVATE DiscordRPC::DiscordRPC)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_DISCORDRPC -DUSE_STUN)
|
|
target_sources(SRB2SDL2 PRIVATE discord.c stun.cpp)
|
|
|
|
target_link_libraries(SRB2SDL2 PRIVATE tcbrindle::span)
|
|
target_link_libraries(SRB2SDL2 PRIVATE glm)
|
|
target_link_libraries(SRB2SDL2 PRIVATE stb_rect_pack)
|
|
target_link_libraries(SRB2SDL2 PRIVATE stb_vorbis)
|
|
target_link_libraries(SRB2SDL2 PRIVATE xmp-lite::xmp-lite)
|
|
target_link_libraries(SRB2SDL2 PRIVATE glad::glad)
|
|
target_link_libraries(SRB2SDL2 PRIVATE fmt)
|
|
target_link_libraries(SRB2SDL2 PRIVATE imgui::imgui)
|
|
if(SRB2_CONFIG_ENABLE_WEBM_MOVIES)
|
|
target_link_libraries(SRB2SDL2 PRIVATE webm::libwebm webm::libvpx)
|
|
target_link_libraries(SRB2SDL2 PRIVATE libyuv::libyuv)
|
|
target_link_libraries(SRB2SDL2 PRIVATE Vorbis::vorbis Vorbis::vorbisenc)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DSRB2_CONFIG_ENABLE_WEBM_MOVIES)
|
|
endif()
|
|
|
|
target_link_libraries(SRB2SDL2 PRIVATE nlohmann_json::nlohmann_json)
|
|
|
|
set(SRB2_HAVE_THREADS ON)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_THREADS)
|
|
|
|
if(${SRB2_CONFIG_HAVE_DISCORDRPC})
|
|
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
|
|
set(DISCORDRPC_FOUND ON)
|
|
if(${SRB2_SYSTEM_BITS} EQUAL 64)
|
|
set(DISCORDRPC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/discord-rpc/win64-dynamic/include)
|
|
set(DISCORDRPC_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/discord-rpc/win64-dynamic/lib -ldiscord-rpc")
|
|
else() # 32-bit
|
|
set(DISCORDRPC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/discord-rpc/win32-dynamic/include)
|
|
set(DISCORDRPC_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/discord-rpc/win32-dynamic/lib -ldiscord-rpc")
|
|
endif()
|
|
else()
|
|
find_package(DiscordRPC)
|
|
endif()
|
|
if(${DISCORDRPC_FOUND})
|
|
set(SRB2_HAVE_DISCORDRPC ON)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_DISCORDRPC)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DUSE_STUN)
|
|
target_sources(SRB2SDL2 PRIVATE discord.c stun.cpp)
|
|
else()
|
|
message(WARNING "You have specified that Discord Rich Presence is available but it was not found.")
|
|
endif()
|
|
endif()
|
|
|
|
if(${SRB2_CONFIG_HAVE_ZLIB})
|
|
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
|
|
set(ZLIB_FOUND ON)
|
|
set(ZLIB_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/zlib)
|
|
if(${SRB2_SYSTEM_BITS} EQUAL 64)
|
|
set(ZLIB_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/zlib/win32 -lz64")
|
|
else() # 32-bit
|
|
set(ZLIB_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/zlib/win32 -lz32")
|
|
endif()
|
|
else()
|
|
find_package(ZLIB)
|
|
endif()
|
|
if(${ZLIB_FOUND})
|
|
set(SRB2_HAVE_ZLIB ON)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_ZLIB)
|
|
else()
|
|
message(WARNING "You have specified that ZLIB is available but it was not found. Dr Robotnik's Ring Racers may not compile correctly.")
|
|
endif()
|
|
endif()
|
|
|
|
if(${SRB2_CONFIG_HAVE_PNG} AND ${SRB2_CONFIG_HAVE_ZLIB})
|
|
if (${ZLIB_FOUND})
|
|
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
|
|
set(PNG_FOUND ON)
|
|
set(PNG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/libpng-src)
|
|
if(${SRB2_SYSTEM_BITS} EQUAL 64)
|
|
set(PNG_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libpng-src/projects -lpng64")
|
|
else() # 32-bit
|
|
set(PNG_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libpng-src/projects -lpng32")
|
|
endif()
|
|
else()
|
|
find_package(PNG)
|
|
endif()
|
|
if(${PNG_FOUND})
|
|
set(SRB2_HAVE_PNG ON)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_PNG)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -D_LARGEFILE64_SOURCE)
|
|
target_sources(SRB2SDL2 PRIVATE apng.c)
|
|
else()
|
|
message(WARNING "You have specified that PNG is available but it was not found. Dr Robotnik's Ring Racers may not compile correctly.")
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
if("${SRB2_CONFIG_HWRENDER}")
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DHWRENDER)
|
|
add_subdirectory(hardware)
|
|
|
|
if("${SRB2_CONFIG_STATIC_OPENGL}")
|
|
find_package(OpenGL)
|
|
if(${OPENGL_FOUND})
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DSTATIC_OPENGL)
|
|
else()
|
|
message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.")
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
if(${SRB2_CONFIG_USEASM})
|
|
#SRB2_ASM_FLAGS can be used to pass flags to either nasm or yasm.
|
|
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
|
set(SRB2_ASM_FLAGS "-DLINUX ${SRB2_ASM_FLAGS}")
|
|
endif()
|
|
|
|
if(${SRB2_CONFIG_YASM})
|
|
set(CMAKE_ASM_YASM_SOURCE_FILE_EXTENSIONS ${CMAKE_ASM_YASM_SOURCE_FILE_EXTENSIONS} nas)
|
|
set(CMAKE_ASM_YASM_FLAGS "${SRB2_ASM_FLAGS}" CACHE STRING "Flags used by the assembler during all build types.")
|
|
enable_language(ASM_YASM)
|
|
else()
|
|
set(CMAKE_ASM_NASM_SOURCE_FILE_EXTENSIONS ${CMAKE_ASM_NASM_SOURCE_FILE_EXTENSIONS} nas)
|
|
set(CMAKE_ASM_NASM_FLAGS "${SRB2_ASM_FLAGS}" CACHE STRING "Flags used by the assembler during all build types.")
|
|
enable_language(ASM_NASM)
|
|
endif()
|
|
|
|
set(SRB2_USEASM ON)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DUSEASM)
|
|
target_compile_options(SRB2SDL2 PRIVATE -msse3 -mfpmath=sse)
|
|
|
|
target_sources(SRB2SDL2 PRIVATE ${SRB2_ASM_SOURCES}
|
|
${SRB2_NASM_SOURCES})
|
|
else()
|
|
set(SRB2_USEASM OFF)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DNONX86 -DNORUSEASM)
|
|
endif()
|
|
|
|
# Targets
|
|
|
|
# If using CCACHE, then force it.
|
|
# https://github.com/Cockatrice/Cockatrice/pull/3052/files
|
|
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
|
|
get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE)
|
|
if(RULE_LAUNCH_COMPILE)
|
|
MESSAGE(STATUS "Force enabling CCache usage under macOS")
|
|
# Set up wrapper scripts
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/launch-c.in ${CMAKE_BINARY_DIR}/launch-c)
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/launch-cxx.in ${CMAKE_BINARY_DIR}/launch-cxx)
|
|
execute_process(COMMAND chmod a+rx
|
|
"${CMAKE_BINARY_DIR}/launch-c"
|
|
"${CMAKE_BINARY_DIR}/launch-cxx")
|
|
|
|
# Set Xcode project attributes to route compilation through our scripts
|
|
set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c")
|
|
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx")
|
|
set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c")
|
|
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx")
|
|
endif()
|
|
endif()
|
|
|
|
# Compatibility flag with later versions of GCC
|
|
# We should really fix our code to not need this
|
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
|
target_compile_options(SRB2SDL2 PRIVATE -mno-ms-bitfields)
|
|
endif()
|
|
|
|
# Compiler warnings configuration
|
|
target_compile_options(SRB2SDL2 PRIVATE
|
|
# Using generator expressions to handle per-language compile options
|
|
|
|
# C, GNU
|
|
# This is a direct translation from versions.mk
|
|
$<$<AND:$<COMPILE_LANGUAGE:C>,$<C_COMPILER_ID:GNU>>:
|
|
-Wall
|
|
-Wno-trigraphs
|
|
-W # Was controlled by RELAXWARNINGS
|
|
-pedantic
|
|
-Wfloat-equal
|
|
-Wundef
|
|
-Wpointer-arith
|
|
-Wbad-function-cast
|
|
-Wcast-qual
|
|
-Wcast-align # Was controlled by NOCASTALIGNWARN
|
|
-Wwrite-strings
|
|
-Wsign-compare
|
|
-Wmissing-prototypes
|
|
-Wmissing-declarations
|
|
-Wmissing-noreturn
|
|
-Wnested-externs
|
|
-Winline
|
|
-Wformat-y2k
|
|
-Wformat-security
|
|
|
|
$<$<VERSION_LESS:$<C_COMPILER_VERSION>,2.9.5>:
|
|
-Wno-div-by-zero
|
|
-Wendif-labels
|
|
-Wdisabled-optimization
|
|
>
|
|
|
|
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.0.0>:
|
|
-Wold-style-definition
|
|
-Wmissing-field-initializers
|
|
>
|
|
|
|
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.1.0>:
|
|
-Wshadow
|
|
>
|
|
|
|
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.3.0>:
|
|
-funit-at-a-time
|
|
-Wlogical-op
|
|
>
|
|
|
|
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.5.0>:
|
|
-Wlogical-op
|
|
-Wno-error=array-bounds
|
|
>
|
|
|
|
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,4.6.0>:
|
|
-Wno-suggest-attribute=noreturn
|
|
-Wno-error=suggest-attribute=noreturn
|
|
>
|
|
|
|
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,5.4.0>:
|
|
-Wno-logical-op
|
|
-Wno-error=logical-op
|
|
>
|
|
|
|
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,6.1.0>:
|
|
-Wno-tautological-compare
|
|
-Wno-error=tautological-compare
|
|
>
|
|
|
|
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,7.1.0>:
|
|
-Wno-error=format-overflow=2
|
|
-Wimplicit-fallthrough=4
|
|
>
|
|
|
|
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,8.1.0>:
|
|
-Wno-error=format-overflow
|
|
-Wno-error=stringop-truncation
|
|
-Wno-error=stringop-overflow
|
|
-Wno-format-overflow
|
|
-Wno-stringop-truncation
|
|
-Wno-stringop-overflow
|
|
-Wno-error=multistatement-macros
|
|
>
|
|
|
|
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,9.1.0>:
|
|
-Wno-error=address-of-packed-member
|
|
>
|
|
>
|
|
|
|
# C, Clang and Apple Clang
|
|
$<$<AND:$<COMPILE_LANGUAGE:C>,$<OR:$<C_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:Clang>>>:
|
|
-Wall
|
|
-Wno-absolute-value
|
|
-Wno-trigraphs
|
|
-Wno-error=non-literal-null-conversion
|
|
-Wno-error=constant-conversion
|
|
-Wno-error=unused-but-set-variable
|
|
>
|
|
|
|
# C, MSVC
|
|
$<$<AND:$<COMPILE_LANGUAGE:C>,$<C_COMPILER_ID:MSVC>>:
|
|
# All warnings at and before Visual Studio 2019 RTM
|
|
# https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warnings-by-compiler-version?view=msvc-170
|
|
/Wv:19.20.27004.0
|
|
>
|
|
|
|
# C++, GNU, Clang and Apple Clang
|
|
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:Clang>>>:
|
|
-Wall
|
|
>
|
|
|
|
# C++, MSVC
|
|
$<$<AND:$<COMPILE_LANGUAGE:C>,$<C_COMPILER_ID:MSVC>>:
|
|
/Wv:19.20.27004.0
|
|
>
|
|
|
|
# GNU
|
|
$<$<C_COMPILER_ID:GNU>:
|
|
-fmax-errors=5
|
|
>
|
|
)
|
|
if(SRB2_CONFIG_ERRORMODE)
|
|
target_compile_options(SRB2SDL2 PRIVATE
|
|
$<$<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:AppleClang>,$<C_COMPILER_ID:Clang>>:
|
|
-Werror
|
|
>
|
|
|
|
$<$<C_COMPILER_ID:MSVC>:
|
|
/WX
|
|
>
|
|
)
|
|
endif()
|
|
|
|
# Link warnings configuration
|
|
target_link_options(SRB2SDL2 PRIVATE
|
|
$<$<C_COMPILER_ID:GNU>:
|
|
# -Wl,--as-needed - Was controlled by NOLDWARNING
|
|
>
|
|
)
|
|
|
|
if(${SRB2_CONFIG_DEV_BUILD})
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DDEVELOP)
|
|
endif()
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DCMAKECONFIG)
|
|
|
|
# Misc. build options from Makefiles
|
|
if(SRB2_CONFIG_DEBUGMODE)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DZDEBUG -DPARANOIA -DRANGECHECK -DPACKETDROP)
|
|
endif()
|
|
if(SRB2_CONFIG_TESTERS)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DTESTERS)
|
|
endif()
|
|
if(SRB2_CONFIG_HOSTTESTERS)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DHOSTTESTERS)
|
|
endif()
|
|
if(SRB2_CONFIG_MOBJCONSISTANCY)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DMOBJCONSISTANCY)
|
|
endif()
|
|
if(SRB2_CONFIG_PACKETDROP)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DPACKETDROP)
|
|
endif()
|
|
if(SRB2_CONFIG_ZDEBUG)
|
|
target_compile_definitions(SRB2SDL2 PRIVATE -DZDEBUG)
|
|
endif()
|
|
if(SRB2_CONFIG_PROFILEMODE AND "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
|
|
target_compile_options(SRB2SDL2 PRIVATE -pg)
|
|
target_link_options(SRB2SDL2 PRIVATE -pg)
|
|
endif()
|
|
if(SRB2_CONFIG_ASAN)
|
|
target_compile_options(SRB2SDL2 PRIVATE -fsanitize=address)
|
|
target_link_options(SRB2SDL2 PRIVATE -fsanitize=address)
|
|
endif()
|
|
|
|
add_subdirectory(audio)
|
|
add_subdirectory(core)
|
|
add_subdirectory(hwr2)
|
|
add_subdirectory(io)
|
|
add_subdirectory(sdl)
|
|
add_subdirectory(objects)
|
|
add_subdirectory(acs)
|
|
add_subdirectory(rhi)
|
|
add_subdirectory(monocypher)
|
|
if(SRB2_CONFIG_ENABLE_TESTS)
|
|
add_subdirectory(tests)
|
|
endif()
|
|
add_subdirectory(menus)
|
|
if(SRB2_CONFIG_ENABLE_WEBM_MOVIES)
|
|
add_subdirectory(media)
|
|
endif()
|
|
add_subdirectory(hud)
|
|
|
|
# strip debug symbols into separate file when using gcc.
|
|
# to be consistent with Makefile, don't generate for OS X.
|
|
if((CMAKE_COMPILER_IS_GNUCC) AND NOT ("${CMAKE_SYSTEM_NAME}" MATCHES Darwin))
|
|
if((${CMAKE_BUILD_TYPE} MATCHES Debug) OR (${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo))
|
|
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
|
|
set(OBJCOPY_ONLY_KEEP_DEBUG "--only-keep-debug")
|
|
endif()
|
|
message(STATUS "Will make separate debug symbols in *.debug")
|
|
add_custom_command(TARGET SRB2SDL2 POST_BUILD
|
|
COMMAND ${OBJCOPY} ${OBJCOPY_ONLY_KEEP_DEBUG} $<TARGET_FILE:SRB2SDL2> $<TARGET_FILE:SRB2SDL2>.debug
|
|
COMMAND ${OBJCOPY} --strip-debug $<TARGET_FILE:SRB2SDL2>
|
|
COMMAND ${OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE:SRB2SDL2>.debug $<TARGET_FILE:SRB2SDL2>
|
|
)
|
|
endif()
|
|
endif()
|
|
|
|
# copy DLLs to bin/ directory if building internal shared on windows
|
|
if("${CMAKE_SYSTEM_NAME}" STREQUAL Windows AND NOT "${SRB2_CONFIG_INTERNAL_LIBRARIES}" AND "${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}")
|
|
set(ADDITIONAL_DLLS "")
|
|
if("${CMAKE_C_COMPILER_ID}" STREQUAL GNU)
|
|
# also copy implicitly linked system libraries
|
|
get_filename_component(MINGW_BIN_PATH ${CMAKE_CXX_COMPILER} PATH)
|
|
list(APPEND ADDITIONAL_DLLS
|
|
"libgcc_s_dw2-1.dll"
|
|
"libstdc++-6.dll"
|
|
"libwinpthread-1.dll"
|
|
)
|
|
list(TRANSFORM ADDITIONAL_DLLS PREPEND "${MINGW_BIN_PATH}/")
|
|
endif()
|
|
add_custom_command(TARGET SRB2SDL2 POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
$<TARGET_RUNTIME_DLLS:SRB2SDL2>
|
|
${ADDITIONAL_DLLS}
|
|
|
|
$<TARGET_FILE_DIR:SRB2SDL2>
|
|
COMMAND_EXPAND_LISTS
|
|
COMMENT "Copying runtime DLLs"
|
|
)
|
|
endif()
|