cmake: Build all deps and static link

Overhaul cmake build
This commit is contained in:
Eidolon 2022-11-05 03:58:19 -05:00 committed by James R
parent 340d3d53fb
commit 0677d59d51
14 changed files with 893 additions and 562 deletions

View file

@ -1,16 +1,10 @@
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
# Enable CCache early # Set up CMAKE path
set(SRB2_USE_CCACHE OFF CACHE BOOL "Use CCache") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
if (${SRB2_USE_CCACHE})
find_program(CCACHE_PROGRAM ccache) include(CMakeDependentOption)
if(CCACHE_PROGRAM) include(cmake/CPM.cmake)
message(STATUS "Found CCache: ${CCACHE_PROGRAM}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
else()
message(WARNING "You have specified to use CCACHE but it was not found. Object files will not be cached.")
endif()
endif()
file(STRINGS src/version.h SRB2_VERSION) file(STRINGS src/version.h SRB2_VERSION)
string(REGEX MATCH "[0-9]+\\.[0-9.]+" SRB2_VERSION ${SRB2_VERSION}) string(REGEX MATCH "[0-9]+\\.[0-9.]+" SRB2_VERSION ${SRB2_VERSION})
@ -19,117 +13,11 @@ string(REGEX MATCH "[0-9]+\\.[0-9.]+" SRB2_VERSION ${SRB2_VERSION})
# Version change is fine. # Version change is fine.
project(SRB2 project(SRB2
VERSION ${SRB2_VERSION} VERSION ${SRB2_VERSION}
LANGUAGES C) LANGUAGES C CXX)
if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) if(APPLE)
message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.") # DiscordRPC needs but does not properly specify ObjC
endif() enable_language(OBJC)
if ((${SRB2_USE_CCACHE}) AND (${CMAKE_C_COMPILER} MATCHES "clang"))
message(WARNING "Using clang and CCache: You may want to set environment variable CCACHE_CPP2=yes to prevent include errors during compile.")
endif()
# Set up CMAKE path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
### Useful functions
# Add sources from Sourcefile
function(target_sourcefile type)
file(STRINGS Sourcefile list
REGEX "[-0-9A-Za-z_]+\.${type}")
target_sources(SRB2SDL2 PRIVATE ${list})
endfunction()
# Macro to add OSX framework
macro(add_framework fwname appname)
find_library(FRAMEWORK_${fwname}
NAMES ${fwname}
PATHS ${CMAKE_OSX_SYSROOT}/System/Library
${CMAKE_OSX_SYSROOT}/Library
/System/Library
/Library
ATH_SUFFIXES Frameworks
NO_DEFAULT_PATH)
if( ${FRAMEWORK_${fwname}} STREQUAL FRAMEWORK_${fwname}-NOTFOUND)
MESSAGE(ERROR ": Framework ${fwname} not found")
else()
TARGET_LINK_LIBRARIES(${appname} PRIVATE "${FRAMEWORK_${fwname}}/${fwname}")
MESSAGE(STATUS "Framework ${fwname} found at ${FRAMEWORK_${fwname}}")
endif()
endmacro()
# Macro to copy Windows DLLs to Debug/Release folder for easy debugging
# Note: this is general purpose, we could copy anything. Just using for DLLs on MSVC though
macro(copy_files_to_build_dir target dlllist_var)
if(MSVC)
# http://stackoverflow.com/a/26983405/3064195
foreach(dlllist_item ${${dlllist_var}})
get_filename_component(dllname ${dlllist_item} NAME)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${dlllist_item}
$<TARGET_FILE_DIR:${target}>/${dllname}
)
endforeach()
endif()
endmacro()
# bitness check
set(SRB2_SYSTEM_BITS 0)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
message(STATUS "Target is 64-bit")
set(SRB2_SYSTEM_BITS 64)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
message(STATUS "Target is 32-bit")
set(SRB2_SYSTEM_BITS 32)
endif()
if(${SRB2_SYSTEM_BITS} EQUAL 0)
message(STATUS "Target bitness is unknown")
endif()
# OS macros
if (UNIX)
add_definitions(-DUNIXCOMMON)
endif()
if(CMAKE_COMPILER_IS_GNUCC)
find_program(OBJCOPY objcopy)
endif()
if(${CMAKE_SYSTEM} MATCHES "Linux")
add_definitions(-DLINUX)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
add_definitions(-DLINUX64)
endif()
endif()
if(${CMAKE_SYSTEM} MATCHES "Darwin")
add_definitions(-DMACOSX)
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
# Set EXE names so the assets CMakeLists can refer to its target
set(SRB2_SDL2_EXE_NAME ringracers CACHE STRING "Executable binary output name")
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
## config.h generation
set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
include(GitUtilities)
git_latest_commit(SRB2_COMP_COMMIT "${CMAKE_SOURCE_DIR}")
git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}")
git_working_tree_dirty(SRB2_COMP_UNCOMMITTED "${CMAKE_SOURCE_DIR}")
set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}")
set(SRB2_COMP_REVISION "${SRB2_COMP_COMMIT}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
add_subdirectory(src)
if(NOT ${SRB2_CONFIG_DEV_BUILD})
add_subdirectory(assets)
endif() endif()
##### PACKAGE CONFIGURATION ##### ##### PACKAGE CONFIGURATION #####
@ -137,11 +25,11 @@ endif()
set(SRB2_CPACK_GENERATOR "" CACHE STRING "Generator to use for making a package. E.g., ZIP, TGZ, DragNDrop (OSX only). Leave blank for default generator.") set(SRB2_CPACK_GENERATOR "" CACHE STRING "Generator to use for making a package. E.g., ZIP, TGZ, DragNDrop (OSX only). Leave blank for default generator.")
if("${SRB2_CPACK_GENERATOR}" STREQUAL "") if("${SRB2_CPACK_GENERATOR}" STREQUAL "")
if(${CMAKE_SYSTEM} MATCHES "Windows") if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
set(SRB2_CPACK_GENERATOR "ZIP") set(SRB2_CPACK_GENERATOR "ZIP")
elseif(${CMAKE_SYSTEM} MATCHES "Linux") elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
set(SRB2_CPACK_GENERATOR "TGZ") set(SRB2_CPACK_GENERATOR "TGZ")
elseif(${CMAKE_SYSTEM} MATCHES "Darwin") elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
set(SRB2_CPACK_GENERATOR "TGZ") set(SRB2_CPACK_GENERATOR "TGZ")
endif() endif()
endif() endif()
@ -157,3 +45,103 @@ set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}") set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}")
SET(CPACK_OUTPUT_FILE_PREFIX package) SET(CPACK_OUTPUT_FILE_PREFIX package)
include(CPack) include(CPack)
# Options
if("${CMAKE_SYSTEM_NAME}" MATCHES Linux)
set(SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT ON)
else()
set(SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT OFF)
endif()
option(
SRB2_CONFIG_SYSTEM_LIBRARIES
"Link dependencies using CMake's find_package and do not use internal builds"
${SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT}
)
# This option isn't recommended for distribution builds and probably won't work (yet).
cmake_dependent_option(
SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES
"Use dynamic libraries when compiling internal dependencies"
OFF "NOT SRB2_CONFIG_SYSTEM_LIBRARIES"
OFF
)
option(SRB2_CONFIG_HWRENDER "Enable hardware render (OpenGL) support" ON)
option(SRB2_CONFIG_STATIC_OPENGL "Enable static linking GL (do not do this)" OFF)
# Enable CCache early
set(SRB2_USE_CCACHE OFF CACHE BOOL "Use CCache")
if (${SRB2_USE_CCACHE})
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
message(STATUS "Found CCache: ${CCACHE_PROGRAM}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
else()
message(WARNING "You have specified to use CCACHE but it was not found. Object files will not be cached.")
endif()
endif()
# Dependencies
add_subdirectory(thirdparty)
if("${SRB2_CONFIG_SYSTEM_LIBRARIES}")
find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
find_package(SDL2 REQUIRED)
find_package(SDL2_mixer REQUIRED)
find_package(CURL REQUIRED)
find_package(OPENMPT REQUIRED)
find_package(GME REQUIRED)
find_package(DiscordRPC REQUIRED)
endif()
if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR})
message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.")
endif()
if ((${SRB2_USE_CCACHE}) AND (${CMAKE_C_COMPILER} MATCHES "clang"))
message(WARNING "Using clang and CCache: You may want to set environment variable CCACHE_CPP2=yes to prevent include errors during compile.")
endif()
# Add sources from Sourcefile
function(target_sourcefile type)
file(STRINGS Sourcefile list
REGEX "[-0-9A-Za-z_]+\.${type}")
target_sources(SRB2SDL2 PRIVATE ${list})
endfunction()
# bitness check
set(SRB2_SYSTEM_BITS 0)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
message(STATUS "Target is 64-bit")
set(SRB2_SYSTEM_BITS 64)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
message(STATUS "Target is 32-bit")
set(SRB2_SYSTEM_BITS 32)
endif()
if(${SRB2_SYSTEM_BITS} EQUAL 0)
message(STATUS "Target bitness is unknown")
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
# Set EXE names so the assets CMakeLists can refer to its target
set(SRB2_SDL2_EXE_NAME ringracers CACHE STRING "Executable binary output name")
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
add_subdirectory(src)
add_subdirectory(assets)
## config.h generation
set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
include(GitUtilities)
git_latest_commit(SRB2_COMP_COMMIT "${CMAKE_SOURCE_DIR}")
git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}")
git_working_tree_dirty(SRB2_COMP_UNCOMMITTED "${CMAKE_SOURCE_DIR}")
set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}")
set(SRB2_COMP_REVISION "${SRB2_COMP_COMMIT}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)

View file

@ -25,6 +25,7 @@ gfx.pk3;\
textures.pk3;\ textures.pk3;\
chars.pk3;\ chars.pk3;\
maps.pk3;\ maps.pk3;\
followers.pk3;\
patch.pk3" patch.pk3"
CACHE STRING "Asset filenames to apply MD5 checks. No spaces between entries!" CACHE STRING "Asset filenames to apply MD5 checks. No spaces between entries!"
) )

21
cmake/CPM.cmake Normal file
View file

@ -0,0 +1,21 @@
set(CPM_DOWNLOAD_VERSION 0.36.0)
if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()
# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
)
endif()
include(${CPM_DOWNLOAD_LOCATION})

View file

@ -21,3 +21,13 @@ find_library(DISCORDRPC_LIBRARY
set(DISCORDRPC_PROCESS_INCLUDES DISCORDRPC_INCLUDE_DIR) set(DISCORDRPC_PROCESS_INCLUDES DISCORDRPC_INCLUDE_DIR)
set(DISCORDRPC_PROCESS_LIBS DISCORDRPC_LIBRARY) set(DISCORDRPC_PROCESS_LIBS DISCORDRPC_LIBRARY)
libfind_process(DISCORDRPC) libfind_process(DISCORDRPC)
if(DISCORDRPC_FOUND AND NOT TARGET DiscordRPC::DiscordRPC)
add_library(DiscordRPC::DiscordRPC UNKNOWN IMPORTED)
set_target_properties(
DiscordRPC::DiscordRPC
PROPERTIES
IMPORTED_LOCATION "${DISCORDRPC_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${DISCORDRPC_INCLUDE_DIR}"
)
endif()

View file

@ -21,3 +21,13 @@ find_library(GME_LIBRARY
set(GME_PROCESS_INCLUDES GME_INCLUDE_DIR) set(GME_PROCESS_INCLUDES GME_INCLUDE_DIR)
set(GME_PROCESS_LIBS GME_LIBRARY) set(GME_PROCESS_LIBS GME_LIBRARY)
libfind_process(GME) libfind_process(GME)
if(GME_FOUND AND NOT TARGET gme)
add_library(gme UNKNOWN IMPORTED)
set_target_properties(
gme
PROPERTIES
IMPORTED_LOCATION "${GME_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${GME_INCLUDE_DIR}"
)
endif()

View file

@ -21,3 +21,13 @@ find_library(OPENMPT_LIBRARY
set(OPENMPT_PROCESS_INCLUDES OPENMPT_INCLUDE_DIR) set(OPENMPT_PROCESS_INCLUDES OPENMPT_INCLUDE_DIR)
set(OPENMPT_PROCESS_LIBS OPENMPT_LIBRARY) set(OPENMPT_PROCESS_LIBS OPENMPT_LIBRARY)
libfind_process(OPENMPT) libfind_process(OPENMPT)
if(OPENMPT_FOUND AND NOT TARGET openmpt)
add_library(openmpt UNKNOWN IMPORTED)
set_target_properties(
openmpt
PROPERTIES
IMPORTED_LOCATION "${OPENMPT_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${OPENMPT_INCLUDE_DIR}"
)
endif()

View file

@ -31,3 +31,13 @@ find_library(SDL2_LIBRARY
set(SDL2_PROCESS_INCLUDES SDL2_INCLUDE_DIR) set(SDL2_PROCESS_INCLUDES SDL2_INCLUDE_DIR)
set(SDL2_PROCESS_LIBS SDL2_LIBRARY) set(SDL2_PROCESS_LIBS SDL2_LIBRARY)
libfind_process(SDL2) libfind_process(SDL2)
if(SDL2_FOUND AND NOT TARGET SDL2::SDL2)
add_library(SDL2::SDL2 UNKNOWN IMPORTED)
set_target_properties(
SDL2::SDL2
PROPERTIES
IMPORTED_LOCATION "${SDL2_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
)
endif()

View file

@ -32,3 +32,13 @@ find_library(SDL2_MIXER_LIBRARY
set(SDL2_MIXER_PROCESS_INCLUDES SDL2_MIXER_INCLUDE_DIR) set(SDL2_MIXER_PROCESS_INCLUDES SDL2_MIXER_INCLUDE_DIR)
set(SDL2_MIXER_PROCESS_LIBS SDL2_MIXER_LIBRARY) set(SDL2_MIXER_PROCESS_LIBS SDL2_MIXER_LIBRARY)
libfind_process(SDL2_MIXER) libfind_process(SDL2_MIXER)
if(SDL2_MIXER_FOUND AND NOT TARGET SDL2_mixer::SDL2_mixer)
add_library(SDL2_mixer::SDL2_mixer UNKNOWN IMPORTED)
set_target_properties(
SDL2_mixer::SDL2_mixer
PROPERTIES
IMPORTED_LOCATION "${SDL2_MIXER_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_MIXER_INCLUDE_DIR}"
)
endif()

View file

@ -1,7 +1,10 @@
# SRB2 Core
add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32) add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32)
if("${CMAKE_COMPILER_IS_GNUCC}" AND "${CMAKE_SYSTEM_NAME}" MATCHES "Windows" AND NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
# On MinGW with internal libraries, link the standard library statically
target_link_options(SRB2SDL2 PRIVATE "-static")
endif()
# Core sources # Core sources
target_sourcefile(c) target_sourcefile(c)
target_sources(SRB2SDL2 PRIVATE comptime.c md5.c config.h.in) target_sources(SRB2SDL2 PRIVATE comptime.c md5.c config.h.in)
@ -11,109 +14,55 @@ set(SRB2_ASM_SOURCES vid_copy.s)
set(SRB2_NASM_SOURCES tmap_mmx.nas tmap.nas) set(SRB2_NASM_SOURCES tmap_mmx.nas tmap.nas)
### Configuration ### Configuration
set(SRB2_CONFIG_HAVE_PNG ON CACHE BOOL
"Enable PNG support. Depends on zlib, so will be disabled if you don't enable that too.")
set(SRB2_CONFIG_HAVE_ZLIB ON CACHE BOOL
"Enable zlib support.")
set(SRB2_CONFIG_HAVE_GME ON CACHE BOOL
"Enable GME support.")
set(SRB2_CONFIG_HAVE_DISCORDRPC OFF CACHE BOOL
"Enable Discord rich presence support.")
set(SRB2_CONFIG_HAVE_CURL ON CACHE BOOL
"Enable cURL support, used for downloading files via HTTP.")
set(SRB2_CONFIG_HAVE_OPENMPT ON CACHE BOOL
"Enable OpenMPT support.")
set(SRB2_CONFIG_HAVE_CURL ON CACHE BOOL
"Enable curl support.")
set(SRB2_CONFIG_HAVE_THREADS ON CACHE BOOL
"Enable multithreading support.")
if(${CMAKE_SYSTEM} MATCHES Windows)
set(SRB2_CONFIG_HAVE_MIXERX ON CACHE BOOL
"Enable SDL Mixer X support.")
else()
set(SRB2_CONFIG_HAVE_MIXERX OFF)
endif()
set(SRB2_CONFIG_HWRENDER ON CACHE BOOL
"Enable hardware rendering through OpenGL.")
set(SRB2_CONFIG_USEASM OFF CACHE BOOL set(SRB2_CONFIG_USEASM OFF CACHE BOOL
"Enable NASM tmap implementation for software mode speedup.") "Enable NASM tmap implementation for software mode speedup.")
set(SRB2_CONFIG_YASM OFF CACHE BOOL set(SRB2_CONFIG_YASM OFF CACHE BOOL
"Use YASM in place of NASM.") "Use YASM in place of NASM.")
set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL
"Use statically linked OpenGL. NOT RECOMMENDED.")
set(SRB2_CONFIG_DEV_BUILD OFF CACHE BOOL set(SRB2_CONFIG_DEV_BUILD OFF CACHE BOOL
"Compile a development build of SRB2Kart.") "Compile a development build of SRB2Kart.")
### use internal libraries?
if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only
set(SRB2_CONFIG_USE_INTERNAL_LIBRARIES OFF CACHE BOOL
"Use SRB2Kart's internal copies of required dependencies (SDL2, PNG, zlib, GME, OpenMPT, cURL).")
endif()
add_subdirectory(blua) add_subdirectory(blua)
if(${SRB2_CONFIG_HAVE_GME}) # OS macros
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) if (UNIX)
set(GME_FOUND ON) target_compile_definitions(SRB2SDL2 PRIVATE -DUNIXCOMMON)
set(GME_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/gme/include) 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) if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(GME_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/gme/win64 -lgme") target_compile_definitions(SRB2SDL2 PRIVATE -DLINUX64)
else() # 32-bit
set(GME_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/gme/win32 -lgme")
endif() endif()
else()
find_package(GME)
endif() endif()
if(${GME_FOUND})
set(SRB2_HAVE_GME ON) 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) target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_GME)
else() if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
message(WARNING "You have specified that GME is available but it was not found.") # this sucks but gme doesn't use modern cmake to delineate public headers
endif() target_include_directories(SRB2SDL2 PRIVATE "${libgme_SOURCE_DIR}")
endif() endif()
if(${SRB2_CONFIG_HAVE_OPENMPT}) target_link_libraries(SRB2SDL2 PRIVATE openmpt)
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(OPENMPT_FOUND ON)
set(OPENMPT_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/inc)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(OPENMPT_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libopenmpt/lib/x86_64/mingw -lopenmpt")
else() # 32-bit
set(OPENMPT_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libopenmpt/lib/x86/mingw -lopenmpt")
endif()
else()
find_package(OPENMPT)
endif()
if(${OPENMPT_FOUND})
set(SRB2_HAVE_OPENMPT ON)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_OPENMPT) target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_OPENMPT)
else()
message(WARNING "You have specified that OpenMPT is available but it was not found.")
endif()
endif()
if(${SRB2_CONFIG_HAVE_MIXERX}) target_link_libraries(SRB2SDL2 PRIVATE ZLIB::ZLIB PNG::PNG CURL::libcurl)
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_ZLIB -DHAVE_PNG -DHAVE_CURL -D_LARGEFILE64_SOURCE)
set(MIXERX_FOUND ON) target_sources(SRB2SDL2 PRIVATE apng.c)
set(MIXERX_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/include/SDL2)
if(${SRB2_SYSTEM_BITS} EQUAL 64) target_link_libraries(SRB2SDL2 PRIVATE DiscordRPC::DiscordRPC)
set(MIXERX_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDLMixerX/x86_64-w64-mingw32/lib -lSDL2_mixer_ext") target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_DISCORDRPC -DUSE_STUN)
else() # 32-bit target_sources(SRB2SDL2 PRIVATE discord.c stun.c)
set(MIXERX_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/lib -lSDL2_mixer_ext")
endif() set(SRB2_HAVE_THREADS ON)
else() target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_THREADS)
# No support for non-Windows (yet?)
#find_package(MIXERX)
message(WARNING "SDL Mixer X is not supported as an external library.")
set(MIXERX_FOUND OFF)
endif()
if(${MIXERX_FOUND})
set(SRB2_HAVE_MIXERX ON)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXERX)
else()
message(WARNING "You have specified that SDL Mixer X is available but it was not found.")
endif()
endif()
if(${SRB2_CONFIG_HAVE_DISCORDRPC}) if(${SRB2_CONFIG_HAVE_DISCORDRPC})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
@ -182,49 +131,32 @@ if(${SRB2_CONFIG_HAVE_PNG} AND ${SRB2_CONFIG_HAVE_ZLIB})
endif() endif()
endif() endif()
if(${SRB2_CONFIG_HAVE_CURL}) if("${SRB2_CONFIG_HWRENDER}")
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(CURL_FOUND ON)
set(CURL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/curl/include)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib64 -lcurl")
else() # 32-bit
set(CURL_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/curl/lib32 -lcurl")
endif()
else()
find_package(CURL)
endif()
if(${CURL_FOUND})
set(SRB2_HAVE_CURL ON)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_CURL)
else()
message(WARNING "You have specified that CURL is available but it was not found. SRB2Kart may not compile correctly.")
endif()
endif()
if(${SRB2_CONFIG_HAVE_THREADS})
set(SRB2_HAVE_THREADS ON)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_THREADS)
endif()
if(${SRB2_CONFIG_HWRENDER})
target_compile_definitions(SRB2SDL2 PRIVATE -DHWRENDER) target_compile_definitions(SRB2SDL2 PRIVATE -DHWRENDER)
add_subdirectory(hardware) add_subdirectory(hardware)
endif()
if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL}) if("${SRB2_CONFIG_STATIC_OPENGL}")
find_package(OpenGL) find_package(OpenGL)
if(${OPENGL_FOUND}) if(${OPENGL_FOUND})
target_compile_definitions(SRB2SDL2 PRIVATE -DHWRENDER)
target_compile_definitions(SRB2SDL2 PRIVATE -DSTATIC_OPENGL) target_compile_definitions(SRB2SDL2 PRIVATE -DSTATIC_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() endif()
endif()
# TODO: build this with the game
if(${CMAKE_SYSTEM} MATCHES Windows AND ${CMAKE_C_COMPILER_ID} MATCHES "GNU" AND ${SRB2_SYSTEM_BITS} EQUAL 32)
target_link_libraries(SRB2SDL2 PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../libs/drmingw/lib/win32/libexchndl.a"
"${CMAKE_CURRENT_SOURCE_DIR}/../libs/drmingw/lib/win32/libmgwhelp.a"
)
target_include_directories(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../libs/drmingw/include")
endif()
if(${SRB2_CONFIG_USEASM}) if(${SRB2_CONFIG_USEASM})
#SRB2_ASM_FLAGS can be used to pass flags to either nasm or yasm. #SRB2_ASM_FLAGS can be used to pass flags to either nasm or yasm.
if(${CMAKE_SYSTEM} MATCHES "Linux") if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
set(SRB2_ASM_FLAGS "-DLINUX ${SRB2_ASM_FLAGS}") set(SRB2_ASM_FLAGS "-DLINUX ${SRB2_ASM_FLAGS}")
endif() endif()
@ -240,7 +172,7 @@ if(${SRB2_CONFIG_USEASM})
set(SRB2_USEASM ON) set(SRB2_USEASM ON)
target_compile_definitions(SRB2SDL2 PRIVATE -DUSEASM) target_compile_definitions(SRB2SDL2 PRIVATE -DUSEASM)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3 -mfpmath=sse") target_compile_options(SRB2SDL2 PRIVATE -msse3 -mfpmath=sse)
target_sources(SRB2SDL2 PRIVATE ${SRB2_ASM_SOURCES} target_sources(SRB2SDL2 PRIVATE ${SRB2_ASM_SOURCES}
${SRB2_NASM_SOURCES}) ${SRB2_NASM_SOURCES})
@ -253,7 +185,7 @@ endif()
# If using CCACHE, then force it. # If using CCACHE, then force it.
# https://github.com/Cockatrice/Cockatrice/pull/3052/files # https://github.com/Cockatrice/Cockatrice/pull/3052/files
if (${CMAKE_SYSTEM} MATCHES "Darwin") if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE) get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE)
if(RULE_LAUNCH_COMPILE) if(RULE_LAUNCH_COMPILE)
MESSAGE(STATUS "Force enabling CCache usage under macOS") MESSAGE(STATUS "Force enabling CCache usage under macOS")
@ -275,35 +207,25 @@ endif()
# 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") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -mno-ms-bitfields) target_compile_options(SRB2SDL2 PRIVATE -mno-ms-bitfields)
target_compile_options(SRB2SDL2 PRIVATE -Wno-trigraphs)
endif() endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-absolute-value) target_compile_options(SRB2SDL2 PRIVATE -Wno-absolute-value)
endif() endif()
if(${SRB2_CONFIG_DEV_BUILD}) if(${SRB2_CONFIG_DEV_BUILD})
target_compile_definitions(SRB2SDL2 PRIVATE -DDEVELOP) target_compile_definitions(SRB2SDL2 PRIVATE -DDEVELOP)
endif() endif()
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-trigraphs)
target_compile_definitions(SRB2SDL2 PRIVATE -DCMAKECONFIG) target_compile_definitions(SRB2SDL2 PRIVATE -DCMAKECONFIG)
#add_library(SRB2Core STATIC add_subdirectory(sdl)
# ${SRB2_CORE_SOURCES} add_subdirectory(objects)
# ${SRB2_CORE_HEADERS}
# ${SRB2_CORE_RENDER_SOURCES}
# ${SRB2_CORE_GAME_SOURCES}
# ${SRB2_LUA_SOURCES}
# ${SRB2_LUA_HEADERS}
# ${SRB2_BLUA_SOURCES}
# ${SRB2_BLUA_HEADERS}
#)
## strip debug symbols into separate file when using gcc. # strip debug symbols into separate file when using gcc.
## to be consistent with Makefile, don't generate for OS X. # to be consistent with Makefile, don't generate for OS X.
if((CMAKE_COMPILER_IS_GNUCC) AND NOT (${CMAKE_SYSTEM} MATCHES Darwin)) 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) OR (${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo))
if(${CMAKE_BUILD_TYPE} MATCHES Debug) if(${CMAKE_BUILD_TYPE} MATCHES Debug)
set(OBJCOPY_ONLY_KEEP_DEBUG "--only-keep-debug") set(OBJCOPY_ONLY_KEEP_DEBUG "--only-keep-debug")
@ -316,10 +238,3 @@ if((CMAKE_COMPILER_IS_GNUCC) AND NOT (${CMAKE_SYSTEM} MATCHES Darwin))
) )
endif() endif()
endif() endif()
add_subdirectory(sdl)
add_subdirectory(objects)
if(NOT ${SRB2_SDL2_AVAILABLE})
message(FATAL_ERROR "There are no targets available to build an SRB2Kart executable. :(")
endif()

View file

@ -15,7 +15,7 @@
#ifdef HAVE_DISCORDRPC #ifdef HAVE_DISCORDRPC
#include "discord_rpc.h" #include <discord_rpc.h>
extern consvar_t cv_discordrp; extern consvar_t cv_discordrp;
extern consvar_t cv_discordstreamer; extern consvar_t cv_discordstreamer;

View file

@ -1,72 +1,25 @@
# Declare SDL2 interface sources # Declare SDL2 interface sources
if(NOT ${SRB2_CONFIG_HAVE_MIXERX})
set(SRB2_CONFIG_SDL2_USEMIXER ON CACHE BOOL "Use SDL2_mixer or regular sdl sound")
else()
set(SRB2_CONFIG_SDL2_USEMIXER OFF)
endif()
if(${SRB2_CONFIG_SDL2_USEMIXER})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(SDL2_MIXER_FOUND ON)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(SDL2_MIXER_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/x86_64-w64-mingw32/include/SDL2)
set(SDL2_MIXER_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/x86_64-w64-mingw32/lib -lSDL2_mixer")
else() # 32-bit
set(SDL2_MIXER_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/i686-w64-mingw32/include/SDL2)
set(SDL2_MIXER_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/i686-w64-mingw32/lib -lSDL2_mixer")
endif()
else()
find_package(SDL2_mixer)
endif()
if(${SDL2_MIXER_FOUND})
set(SRB2_HAVE_MIXER ON)
target_sources(SRB2SDL2 PRIVATE mixer_sound.c) target_sources(SRB2SDL2 PRIVATE mixer_sound.c)
else()
message(WARNING "You specified that SDL2_mixer is available, but it was not found. Falling back to sdl sound.")
target_sources(SRB2SDL2 PRIVATE sdl_sound.c)
endif()
elseif(${MIXERX_FOUND})
target_sources(SRB2SDL2 PRIVATE mixer_sound.c)
else()
target_sources(SRB2SDL2 PRIVATE sdl_sound.c)
endif()
target_sourcefile(c) target_sourcefile(c)
target_sources(SRB2SDL2 PRIVATE ogl_sdl.c) target_sources(SRB2SDL2 PRIVATE ogl_sdl.c)
if(${SRB2_CONFIG_HAVE_THREADS})
target_sources(SRB2SDL2 PRIVATE i_threads.c) target_sources(SRB2SDL2 PRIVATE i_threads.c)
endif()
# Dependency
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(SDL2_FOUND ON)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(SDL2_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/include/SDL2)
set(SDL2_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/lib -lSDL2")
else() # 32-bit
set(SDL2_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/include/SDL2)
set(SDL2_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/lib -lSDL2")
endif()
else()
find_package(SDL2)
endif()
if(${SDL2_FOUND})
if(${SRB2_USEASM}) if(${SRB2_USEASM})
set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES LANGUAGE C) set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES LANGUAGE C)
set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp") set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp")
endif() endif()
if(${CMAKE_SYSTEM} MATCHES Windows) if("${CMAKE_SYSTEM_NAME}" MATCHES Windows)
target_sources(SRB2SDL2 PRIVATE target_sources(SRB2SDL2 PRIVATE
../win32/win_dbg.c ../win32/win_dbg.c
../win32/Srb2win.rc) ../win32/Srb2win.rc)
endif() endif()
if(${CMAKE_SYSTEM} MATCHES Darwin) if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin)
set(MACOSX_BUNDLE_ICON_FILE Srb2mac.icns) set(MACOSX_BUNDLE_ICON_FILE Srb2mac.icns)
set_source_files_properties(macosx/Srb2mac.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") set_source_files_properties(macosx/Srb2mac.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
target_sources(SRB2SDL2 PRIVATE target_sources(SRB2SDL2 PRIVATE
@ -78,55 +31,43 @@ if(${SDL2_FOUND})
) )
endif() endif()
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME ringracers) if("${CMAKE_SYSTEM_NAME}" MATCHES Windows)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2win)
if(${CMAKE_SYSTEM} MATCHES Darwin) elseif("${CMAKE_SYSTEM_NAME}" MATCHES Linux)
find_library(CORE_LIB CoreFoundation) set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsdlsrb2)
target_link_libraries(SRB2SDL2 PRIVATE
${CORE_LIB}
SDL2
SDL2_mixer
${GME_LIBRARIES}
${OPENMPT_LIBRARIES}
${MIXERX_LIBRARIES}
${PNG_LIBRARIES}
${ZLIB_LIBRARIES}
${OPENGL_LIBRARIES}
${CURL_LIBRARIES}
${DISCORDRPC_LIBRARIES}
)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
else() else()
target_link_libraries(SRB2SDL2 PRIVATE set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2)
${SDL2_LIBRARIES}
${SDL2_MIXER_LIBRARIES}
${GME_LIBRARIES}
${OPENMPT_LIBRARIES}
${MIXERX_LIBRARIES}
${PNG_LIBRARIES}
${ZLIB_LIBRARIES}
${OPENGL_LIBRARIES}
${CURL_LIBRARIES}
${DISCORDRPC_LIBRARIES}
)
if(${CMAKE_SYSTEM} MATCHES Linux)
target_link_libraries(SRB2SDL2 PRIVATE
m
rt
)
endif()
endif() endif()
if(${CMAKE_SYSTEM} MATCHES Windows AND ${CMAKE_C_COMPILER_ID} MATCHES "GNU" AND ${SRB2_SYSTEM_BITS} EQUAL 32) if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin)
find_library(CORE_FOUNDATION_LIBRARY "CoreFoundation")
target_link_libraries(SRB2SDL2 PRIVATE target_link_libraries(SRB2SDL2 PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../../libs/drmingw/lib/win32/libexchndl.a" ${CORE_FOUNDATION_LIBRARY}
"${CMAKE_CURRENT_SOURCE_DIR}/../../libs/drmingw/lib/win32/libmgwhelp.a"
) )
target_include_directories(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../libs/drmingw/include")
endif()
#target_link_libraries(SRB2SDL2 PRIVATE SRB2Core) #target_link_libraries(SRB2SDL2 PRIVATE SRB2Core)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
# Configure the app bundle icon and plist properties
target_sources(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns")
set_target_properties(SRB2SDL2 PROPERTIES
MACOSX_BUNDLE_ICON_FILE "Srb2mac"
MACOSX_BUNDLE_BUNDLE_NAME "Dr. Robotnik's Ring Racers"
MACOSX_BUNDLE_BUNDLE_VERSION ${SRB2_VERSION}
RESOURCE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns"
)
endif()
if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}" AND NOT "${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}")
target_link_libraries(SRB2SDL2 PRIVATE SDL2::SDL2-static SDL2_mixer::SDL2_mixer-static)
else()
target_link_libraries(SRB2SDL2 PRIVATE SDL2::SDL2 SDL2_mixer::SDL2_mixer)
endif()
if("${CMAKE_SYSTEM_NAME}" MATCHES Linux)
target_link_libraries(SRB2SDL2 PRIVATE m rt)
endif()
if(${SRB2_USEASM}) if(${SRB2_USEASM})
if(${SRB2_CONFIG_YASM}) if(${SRB2_CONFIG_YASM})
@ -140,9 +81,7 @@ if(${SDL2_FOUND})
endif() endif()
endif() endif()
set_target_properties(SRB2SDL2 PROPERTIES VERSION ${SRB2_VERSION}) if("${CMAKE_SYSTEM_NAME}" MATCHES Windows)
if(${CMAKE_SYSTEM} MATCHES Windows)
target_link_libraries(SRB2SDL2 PRIVATE target_link_libraries(SRB2SDL2 PRIVATE
ws2_32 ws2_32
) )
@ -151,33 +90,15 @@ if(${SDL2_FOUND})
) )
endif() endif()
target_include_directories(SRB2SDL2 PRIVATE
${SDL2_INCLUDE_DIRS}
${SDL2_MIXER_INCLUDE_DIRS}
${GME_INCLUDE_DIRS}
${OPENMPT_INCLUDE_DIRS}
${MIXERX_INCLUDE_DIRS}
${PNG_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
${OPENGL_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS}
${DISCORDRPC_INCLUDE_DIRS}
)
if((${SRB2_HAVE_MIXER}) OR (${SRB2_HAVE_MIXERX}))
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER) target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER)
endif() target_compile_definitions(SRB2SDL2 PRIVATE -DDIRECTFULLSCREEN -DHAVE_SDL)
target_compile_definitions(SRB2SDL2 PRIVATE
-DDIRECTFULLSCREEN -DHAVE_SDL
-DHAVE_THREADS
)
#### Installation #### #### Installation ####
if(${CMAKE_SYSTEM} MATCHES Darwin) if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin)
install(TARGETS SRB2SDL2 install(TARGETS SRB2SDL2
BUNDLE DESTINATION . BUNDLE DESTINATION .
) )
set_property(TARGET SRB2SDL2 PROPERTY INSTALL_RPATH_USE_LINK_PATH ON)
else() else()
install(TARGETS SRB2SDL2 SRB2SDL2 install(TARGETS SRB2SDL2 SRB2SDL2
RUNTIME DESTINATION . RUNTIME DESTINATION .
@ -193,89 +114,6 @@ if(${SDL2_FOUND})
endif() endif()
endif() endif()
if(${CMAKE_SYSTEM} MATCHES Windows)
set(win_extra_dll_list "")
macro(getwinlib dllname defaultname)
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
if (${CMAKE_GENERATOR} STREQUAL "MinGW Makefiles")
if(${SRB2_SYSTEM_BITS} EQUAL 64)
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}"
HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/x86_64
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/bin
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/x86_64-w64-mingw32/bin
HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86_64/mingw
HINTS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/x86_64-w64-mingw32/bin
)
else()
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}"
HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/i686
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/bin
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/i686-w64-mingw32/bin
HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86/mingw
HINTS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/bin
)
endif()
else()
if(${SRB2_SYSTEM_BITS} EQUAL 64)
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}"
HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/x86_64
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/lib/x64
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/lib/x64
HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86_64/mingw
HINTS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/x86_64-w64-mingw32/bin
)
else()
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}"
HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/i686
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/lib/x86
HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/lib/x86
HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86/mingw
HINTS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/bin
)
endif()
endif()
list(APPEND win_extra_dll_list ${SRB2_SDL2_DLL_${dllname}})
else()
find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}")
list(APPEND win_extra_dll_list ${SRB2_SDL2_DLL_${dllname}})
endif()
endmacro()
getwinlib(SDL2 "SDL2.dll")
if(${SRB2_CONFIG_SDL2_USEMIXER})
getwinlib(SDL2_mixer "SDL2_mixer.dll")
getwinlib(libogg_0 "libogg-0.dll")
getwinlib(libvorbis_0 "libvorbis-0.dll")
getwinlib(libvorbisfile_3 "libvorbisfile-3.dll")
endif()
if(${SRB2_CONFIG_HAVE_GME})
getwinlib(libgme "libgme.dll")
endif()
if(${SRB2_CONFIG_HAVE_OPENMPT})
getwinlib(libopenmpt "libopenmpt.dll")
endif()
if(${SRB2_CONFIG_HAVE_MIXERX})
getwinlib(SDL2_mixer_ext "SDL2_mixer_ext.dll")
getwinlib(libfluidsynth-2 "libfluidsynth-2.dll")
getwinlib(libgcc_s_sjlj-1 "libgcc_s_sjlj-1.dll")
getwinlib(libstdc++-6 "libstdc++-6.dll")
endif()
if(${SRB2_CONFIG_HAVE_DISCORDRPC})
getwinlib(discord-rpc "discord-rpc.dll")
endif()
install(PROGRAMS
${win_extra_dll_list}
DESTINATION .
)
# We also want to copy those DLLs to build directories on MSVC.
# So we'll add a post_build step.
copy_files_to_build_dir(SRB2SDL2 win_extra_dll_list)
endif()
# Mac bundle fixup # Mac bundle fixup
# HACK: THIS IS IMPORTANT! See the escaped \${CMAKE_INSTALL_PREFIX}? This # HACK: THIS IS IMPORTANT! See the escaped \${CMAKE_INSTALL_PREFIX}? This
# makes it so that var is evaluated LATER during cpack, not right now! # makes it so that var is evaluated LATER during cpack, not right now!
@ -286,7 +124,7 @@ if(${SDL2_FOUND})
# is only available to us at this step. Read the link: ${CMAKE_INSTALL_PREFIX} at # is only available to us at this step. Read the link: ${CMAKE_INSTALL_PREFIX} at
# this current step points to the CMAKE build folder, NOT the folder that CPACK uses. # this current step points to the CMAKE build folder, NOT the folder that CPACK uses.
# Therefore, it makes sense to escape that var, but not the other. # Therefore, it makes sense to escape that var, but not the other.
if(${CMAKE_SYSTEM} MATCHES Darwin) if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin)
install(CODE " install(CODE "
include(BundleUtilities) include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${CPACK_PACKAGE_DESCRIPTION_SUMMARY}.app\" fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${CPACK_PACKAGE_DESCRIPTION_SUMMARY}.app\"
@ -297,7 +135,3 @@ if(${SDL2_FOUND})
endif() endif()
set(SRB2_SDL2_AVAILABLE YES PARENT_SCOPE) set(SRB2_SDL2_AVAILABLE YES PARENT_SCOPE)
else()
message(WARNING "SDL2 was not found, so the SDL2 target will not be available.")
set(SRB2_SDL2_AVAILABLE NO PARENT_SCOPE)
endif()

View file

@ -80,7 +80,7 @@ write netcode into the sound code, OKAY?
#endif #endif
#ifdef HAVE_GME #ifdef HAVE_GME
#include "gme/gme.h" #include <gme/gme.h>
#define GME_TREBLE 5.0f #define GME_TREBLE 5.0f
#define GME_BASS 1.0f #define GME_BASS 1.0f
#endif // HAVE_GME #endif // HAVE_GME

512
thirdparty/CMakeLists.txt vendored Normal file
View file

@ -0,0 +1,512 @@
macro(export)
endmacro()
if(SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES)
set(SRB2_INTERNAL_LIBRARY_TYPE SHARED)
set(NOT_SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES OFF)
else()
set(SRB2_INTERNAL_LIBRARY_TYPE STATIC)
set(NOT_SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES ON)
endif()
if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
CPMAddPackage(
NAME SDL2
VERSION 2.24.2
URL "https://github.com/libsdl-org/SDL/archive/refs/tags/release-2.24.2.zip"
EXCLUDE_FROM_ALL ON
OPTIONS
"BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}"
"SDL_SHARED ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}"
"SDL_STATIC ${NOT_SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}"
"SDL_TEST OFF"
"SDL2_DISABLE_SDL2MAIN ON"
"SDL2_DISABLE_INSTALL ON"
)
endif()
if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
CPMAddPackage(
NAME SDL2_mixer
VERSION 2.6.2
URL "https://github.com/libsdl-org/SDL_mixer/archive/refs/tags/release-2.6.2.zip"
EXCLUDE_FROM_ALL ON
OPTIONS
"BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}"
"SDL2MIXER_INSTALL OFF"
"SDL2MIXER_DEPS_SHARED OFF"
"SDL2MIXER_SAMPLES OFF"
"SDL2MIXER_VENDORED ON"
"SDL2MIXER_FLAC ON"
"SDL2MIXER_FLAC_LIBFLAC OFF"
"SDL2MIXER_FLAC_DRFLAC ON"
"SDL2MIXER_MOD OFF"
"SDL2MIXER_MP3 ON"
"SDL2MIXER_MP3_DRMP3 ON"
"SDL2MIXER_MIDI ON"
"SDL2MIXER_OPUS OFF"
"SDL2MIXER_VORBIS STB"
"SDL2MIXER_WAVE ON"
)
endif()
if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
CPMAddPackage(
NAME ZLIB
VERSION 1.2.13
URL "https://github.com/madler/zlib/archive/refs/tags/v1.2.13.zip"
EXCLUDE_FROM_ALL
OPTIONS
# The assembly optimizations are unmaintained and slated to be removed
"ASM686 Off"
"AMD64 Off"
"SKIP_INSTALL_ALL ON"
)
file(MAKE_DIRECTORY "${zlib_BINARY_DIR}/include")
file(COPY "${zlib_SOURCE_DIR}/zlib.h" DESTINATION "${zlib_BINARY_DIR}/include")
file(COPY "${zlib_BINARY_DIR}/zconf.h" DESTINATION "${zlib_BINARY_DIR}/include")
# honestly this should probably be built like png is
set_target_properties(zlib PROPERTIES EXCLUDE_FROM_ALL ON)
set_target_properties(minigzip PROPERTIES EXCLUDE_FROM_ALL ON)
set_target_properties(example PROPERTIES EXCLUDE_FROM_ALL ON)
# zlib cmake also adds these 64 targets separately
if(HAVE_OFF64_T)
set_target_properties(minigzip64 PROPERTIES EXCLUDE_FROM_ALL ON)
set_target_properties(example64 PROPERTIES EXCLUDE_FROM_ALL ON)
endif()
target_include_directories(zlib INTERFACE "${zlib_BINARY_DIR}/include")
target_include_directories(zlibstatic INTERFACE "${zlib_BINARY_DIR}/include")
if(SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES)
add_library(ZLIB::ZLIB ALIAS zlib)
else()
add_library(ZLIB::ZLIB ALIAS zlibstatic)
endif()
endif()
if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
CPMAddPackage(
NAME png
VERSION 1.6.38
URL "https://github.com/glennrp/libpng/archive/refs/tags/v1.6.38.zip"
# png cmake build is broken on msys/mingw32
DOWNLOAD_ONLY YES
)
if(png_ADDED)
# Since png's cmake build is broken, we're going to create a target manually
set(
PNG_SOURCES
png.h
pngconf.h
pngpriv.h
pngdebug.h
pnginfo.h
pngstruct.h
png.c
pngerror.c
pngget.c
pngmem.c
pngpread.c
pngread.c
pngrio.c
pngrtran.c
pngrutil.c
pngset.c
pngtrans.c
pngwio.c
pngwrite.c
pngwtran.c
pngwutil.c
)
list(TRANSFORM PNG_SOURCES PREPEND "${png_SOURCE_DIR}/")
add_custom_command(
OUTPUT "${png_BINARY_DIR}/include/png.h" "${png_BINARY_DIR}/include/pngconf.h"
COMMAND ${CMAKE_COMMAND} -E copy "${png_SOURCE_DIR}/png.h" "${png_SOURCE_DIR}/pngconf.h" "${png_BINARY_DIR}/include"
DEPENDS "${png_SOURCE_DIR}/png.h" "${png_SOURCE_DIR}/pngconf.h"
VERBATIM
)
add_custom_command(
OUTPUT "${png_BINARY_DIR}/include/pnglibconf.h"
COMMAND ${CMAKE_COMMAND} -E copy "${png_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt" "${png_BINARY_DIR}/include/pnglibconf.h"
DEPENDS "${png_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt"
VERBATIM
)
list(
APPEND PNG_SOURCES
"${png_BINARY_DIR}/include/png.h"
"${png_BINARY_DIR}/include/pngconf.h"
"${png_BINARY_DIR}/include/pnglibconf.h"
)
add_library(png "${SRB2_INTERNAL_LIBRARY_TYPE}" ${PNG_SOURCES})
# Disable ARM NEON since having it automatic breaks libpng external build on clang for some reason
target_compile_definitions(png PRIVATE -DPNG_ARM_NEON_OPT=0)
# The png includes need to be available to consumers
target_include_directories(png PUBLIC "${png_BINARY_DIR}/include")
# ... and these also need to be present only for png build
target_include_directories(png PRIVATE "${zlib_SOURCE_DIR}")
target_include_directories(png PRIVATE "${zlib_BINARY_DIR}")
target_include_directories(png PRIVATE "${png_BINARY_DIR}")
target_link_libraries(png PRIVATE ZLIB::ZLIB)
add_library(PNG::PNG ALIAS png)
endif()
endif()
if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
set(
internal_curl_options
"BUILD_CURL_EXE OFF"
"BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}"
"CURL_DISABLE_TESTS ON"
"HTTP_ONLY ON"
"CURL_DISABLE_CRYPTO_AUTH ON"
"CURL_DISABLE_NTLM ON"
"ENABLE_MANUAL OFF"
"ENABLE_THREADED_RESOLVER OFF"
"CURL_USE_LIBPSL OFF"
"CURL_USE_LIBSSH2 OFF"
"USE_LIBIDN2 OFF"
"CURL_ENABLE_EXPORT_TARGET OFF"
)
if(${CMAKE_SYSTEM} MATCHES Windows)
list(APPEND internal_curl_options "CURL_USE_OPENSSL OFF")
list(APPEND internal_curl_options "CURL_USE_SCHANNEL ON")
endif()
if(${CMAKE_SYSTEM} MATCHES Darwin)
list(APPEND internal_curl_options "CURL_USE_OPENSSL OFF")
list(APPEND internal_curl_options "CURL_USE_SECTRANSP ON")
endif()
if(${CMAKE_SYSTEM} MATCHES Linux)
list(APPEND internal_curl_options "CURL_USE_OPENSSL ON")
endif()
CPMAddPackage(
NAME curl
VERSION 7.86.0
URL "https://github.com/curl/curl/archive/refs/tags/curl-7_86_0.zip"
EXCLUDE_FROM_ALL ON
OPTIONS ${internal_curl_options}
)
endif()
if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
CPMAddPackage(
NAME openmpt
VERSION 0.4.30
URL "https://github.com/OpenMPT/openmpt/archive/refs/tags/libopenmpt-0.4.30.zip"
DOWNLOAD_ONLY ON
)
if(openmpt_ADDED)
set(
openmpt_SOURCES
# minimp3
# -DMPT_WITH_MINIMP3
include/minimp3/minimp3.c
common/mptStringParse.cpp
common/mptLibrary.cpp
common/Logging.cpp
common/Profiler.cpp
common/version.cpp
common/mptCPU.cpp
common/ComponentManager.cpp
common/mptOS.cpp
common/serialization_utils.cpp
common/mptStringFormat.cpp
common/FileReader.cpp
common/mptWine.cpp
common/mptPathString.cpp
common/mptAlloc.cpp
common/mptUUID.cpp
common/mptTime.cpp
common/mptString.cpp
common/mptFileIO.cpp
common/mptStringBuffer.cpp
common/mptRandom.cpp
common/mptIO.cpp
common/misc_util.cpp
common/mptCRC.h
common/mptLibrary.h
common/mptIO.h
common/version.h
common/stdafx.h
common/ComponentManager.h
common/Endianness.h
common/mptStringFormat.h
common/mptMutex.h
common/mptUUID.h
common/mptExceptionText.h
common/BuildSettings.h
common/mptAlloc.h
common/mptTime.h
common/FileReaderFwd.h
common/Logging.h
common/mptException.h
common/mptWine.h
common/mptStringBuffer.h
common/misc_util.h
common/mptBaseMacros.h
common/mptMemory.h
common/mptFileIO.h
common/serialization_utils.h
common/mptSpan.h
common/mptThread.h
common/FlagSet.h
common/mptString.h
common/mptStringParse.h
common/mptBaseUtils.h
common/mptRandom.h
common/CompilerDetect.h
common/FileReader.h
common/mptAssert.h
common/mptPathString.h
common/Profiler.h
common/mptOS.h
common/mptBaseTypes.h
common/mptCPU.h
common/mptBufferIO.h
common/versionNumber.h
soundlib/WAVTools.cpp
soundlib/ITTools.cpp
soundlib/AudioCriticalSection.cpp
soundlib/Load_stm.cpp
soundlib/MixerLoops.cpp
soundlib/Load_dbm.cpp
soundlib/ModChannel.cpp
soundlib/Load_gdm.cpp
soundlib/Snd_fx.cpp
soundlib/Load_mid.cpp
soundlib/mod_specifications.cpp
soundlib/Snd_flt.cpp
soundlib/Load_psm.cpp
soundlib/Load_far.cpp
soundlib/patternContainer.cpp
soundlib/Load_med.cpp
soundlib/Load_dmf.cpp
soundlib/Paula.cpp
soundlib/modcommand.cpp
soundlib/Message.cpp
soundlib/SoundFilePlayConfig.cpp
soundlib/Load_uax.cpp
soundlib/plugins/PlugInterface.cpp
soundlib/plugins/LFOPlugin.cpp
soundlib/plugins/PluginManager.cpp
soundlib/plugins/DigiBoosterEcho.cpp
soundlib/plugins/dmo/DMOPlugin.cpp
soundlib/plugins/dmo/Flanger.cpp
soundlib/plugins/dmo/Distortion.cpp
soundlib/plugins/dmo/ParamEq.cpp
soundlib/plugins/dmo/Gargle.cpp
soundlib/plugins/dmo/I3DL2Reverb.cpp
soundlib/plugins/dmo/Compressor.cpp
soundlib/plugins/dmo/WavesReverb.cpp
soundlib/plugins/dmo/Echo.cpp
soundlib/plugins/dmo/Chorus.cpp
soundlib/Load_ams.cpp
soundlib/tuningbase.cpp
soundlib/ContainerUMX.cpp
soundlib/Load_ptm.cpp
soundlib/ContainerXPK.cpp
soundlib/SampleFormatMP3.cpp
soundlib/tuning.cpp
soundlib/Sndfile.cpp
soundlib/ContainerMMCMP.cpp
soundlib/Load_amf.cpp
soundlib/Load_669.cpp
soundlib/modsmp_ctrl.cpp
soundlib/Load_mtm.cpp
soundlib/OggStream.cpp
soundlib/Load_plm.cpp
soundlib/Tables.cpp
soundlib/Load_c67.cpp
soundlib/Load_mod.cpp
soundlib/Load_sfx.cpp
soundlib/Sndmix.cpp
soundlib/load_j2b.cpp
soundlib/ModSequence.cpp
soundlib/SampleFormatFLAC.cpp
soundlib/ModInstrument.cpp
soundlib/Load_mo3.cpp
soundlib/ModSample.cpp
soundlib/Dlsbank.cpp
soundlib/Load_itp.cpp
soundlib/UpgradeModule.cpp
soundlib/MIDIMacros.cpp
soundlib/ContainerPP20.cpp
soundlib/RowVisitor.cpp
soundlib/Load_imf.cpp
soundlib/SampleFormatVorbis.cpp
soundlib/Load_dsm.cpp
soundlib/Load_mt2.cpp
soundlib/MixerSettings.cpp
soundlib/S3MTools.cpp
soundlib/Load_xm.cpp
soundlib/MIDIEvents.cpp
soundlib/pattern.cpp
soundlib/Load_digi.cpp
soundlib/Load_s3m.cpp
soundlib/tuningCollection.cpp
soundlib/SampleIO.cpp
soundlib/Dither.cpp
soundlib/Load_mdl.cpp
soundlib/OPL.cpp
soundlib/WindowedFIR.cpp
soundlib/SampleFormats.cpp
soundlib/Load_wav.cpp
soundlib/Load_it.cpp
soundlib/UMXTools.cpp
soundlib/Load_stp.cpp
soundlib/Load_okt.cpp
soundlib/Load_ult.cpp
soundlib/MixFuncTable.cpp
soundlib/SampleFormatOpus.cpp
soundlib/Fastmix.cpp
soundlib/Tagging.cpp
soundlib/ITCompression.cpp
soundlib/Load_dtm.cpp
soundlib/MPEGFrame.cpp
soundlib/XMTools.cpp
soundlib/SampleFormatMediaFoundation.cpp
soundlib/InstrumentExtensions.cpp
soundlib/MixerInterface.h
soundlib/SoundFilePlayConfig.h
soundlib/ModSample.h
soundlib/MIDIEvents.h
soundlib/ModSampleCopy.h
soundlib/patternContainer.h
soundlib/ChunkReader.h
soundlib/ITCompression.h
soundlib/Dither.h
soundlib/S3MTools.h
soundlib/MPEGFrame.h
soundlib/WAVTools.h
soundlib/mod_specifications.h
soundlib/ITTools.h
soundlib/RowVisitor.h
soundlib/plugins/PluginMixBuffer.h
soundlib/plugins/PluginStructs.h
soundlib/plugins/LFOPlugin.h
soundlib/plugins/PlugInterface.h
soundlib/plugins/DigiBoosterEcho.h
soundlib/plugins/OpCodes.h
soundlib/plugins/dmo/Echo.h
soundlib/plugins/dmo/I3DL2Reverb.h
soundlib/plugins/dmo/WavesReverb.h
soundlib/plugins/dmo/ParamEq.h
soundlib/plugins/dmo/Gargle.h
soundlib/plugins/dmo/DMOPlugin.h
soundlib/plugins/dmo/Chorus.h
soundlib/plugins/dmo/Compressor.h
soundlib/plugins/dmo/Distortion.h
soundlib/plugins/dmo/Flanger.h
soundlib/plugins/PluginManager.h
soundlib/SampleIO.h
soundlib/Container.h
soundlib/ModSequence.h
soundlib/UMXTools.h
soundlib/Message.h
soundlib/modcommand.h
soundlib/XMTools.h
soundlib/Snd_defs.h
soundlib/MixFuncTable.h
soundlib/pattern.h
soundlib/modsmp_ctrl.h
soundlib/Tagging.h
soundlib/tuningcollection.h
soundlib/Mixer.h
soundlib/FloatMixer.h
soundlib/AudioCriticalSection.h
soundlib/Tables.h
soundlib/tuningbase.h
soundlib/WindowedFIR.h
soundlib/Sndfile.h
soundlib/Paula.h
soundlib/ModInstrument.h
soundlib/Dlsbank.h
soundlib/IntMixer.h
soundlib/OPL.h
soundlib/Resampler.h
soundlib/ModChannel.h
soundlib/MixerSettings.h
soundlib/AudioReadTarget.h
soundlib/MixerLoops.h
soundlib/tuning.h
soundlib/MIDIMacros.h
soundlib/OggStream.h
soundlib/Loaders.h
soundlib/BitReader.h
soundlib/opal.h
sounddsp/AGC.cpp
sounddsp/EQ.cpp
sounddsp/DSP.cpp
sounddsp/Reverb.cpp
sounddsp/Reverb.h
sounddsp/EQ.h
sounddsp/DSP.h
sounddsp/AGC.h
libopenmpt/libopenmpt_c.cpp
libopenmpt/libopenmpt_cxx.cpp
libopenmpt/libopenmpt_impl.cpp
libopenmpt/libopenmpt_ext_impl.cpp
)
list(TRANSFORM openmpt_SOURCES PREPEND "${openmpt_SOURCE_DIR}/")
# -DLIBOPENMPT_BUILD
configure_file("openmpt_svn_version.h" "svn_version.h")
add_library(openmpt "${SRB2_INTERNAL_LIBRARY_TYPE}" ${openmpt_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/svn_version.h)
target_compile_features(openmpt PRIVATE cxx_std_11)
target_compile_definitions(openmpt PRIVATE -DLIBOPENMPT_BUILD)
target_include_directories(openmpt PRIVATE "${openmpt_SOURCE_DIR}/common")
target_include_directories(openmpt PRIVATE "${openmpt_SOURCE_DIR}/src")
target_include_directories(openmpt PRIVATE "${openmpt_SOURCE_DIR}/include")
target_include_directories(openmpt PRIVATE "${openmpt_SOURCE_DIR}")
target_include_directories(openmpt PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
# I wish this wasn't necessary, but it is
target_include_directories(openmpt PUBLIC "${openmpt_SOURCE_DIR}")
endif()
endif()
if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
CPMAddPackage(
NAME libgme
VERSION 0.6.3
URL "https://bitbucket.org/mpyne/game-music-emu/get/e76bdc0cb916e79aa540290e6edd0c445879d3ba.zip"
EXCLUDE_FROM_ALL ON
OPTIONS
"BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}"
"ENABLE_UBSAN OFF"
)
target_compile_features(gme PRIVATE cxx_std_11)
target_link_libraries(gme PRIVATE ZLIB::ZLIB)
endif()
if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
CPMAddPackage(
NAME DiscordRPC
VERSION 3.4.0
URL "https://github.com/discord/discord-rpc/archive/refs/tags/v3.4.0.zip"
EXCLUDE_FROM_ALL ON
OPTIONS
"BUILD_EXAMPLES OFF"
)
target_include_directories(discord-rpc INTERFACE "${DiscordRPC_SOURCE_DIR}/include")
add_library(DiscordRPC::DiscordRPC ALIAS discord-rpc)
endif()

10
thirdparty/openmpt_svn_version.h vendored Normal file
View file

@ -0,0 +1,10 @@
#pragma once
#define OPENMPT_VERSION_SVNVERSION "17963"
#define OPENMPT_VERSION_REVISION 17963
#define OPENMPT_VERSION_DIRTY 0
#define OPENMPT_VERSION_MIXEDREVISIONS 0
#define OPENMPT_VERSION_URL "https://source.openmpt.org/svn/openmpt/tags/libopenmpt-0.4.32"
#define OPENMPT_VERSION_DATE "2022-09-25T14:19:05.052596Z"
#define OPENMPT_VERSION_IS_PACKAGE 1