cmake: Build all deps and static link

This commit is contained in:
Eidolon 2022-10-10 22:20:59 -05:00
parent 896a7609a7
commit a015be2a54
11 changed files with 818 additions and 560 deletions

View file

@ -1,4 +1,68 @@
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
# Set up CMAKE path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
include(CMakeDependentOption)
include(cmake/CPM.cmake)
file(STRINGS src/version.h SRB2_VERSION)
string(REGEX MATCH "[0-9]+\\.[0-9.]+" SRB2_VERSION ${SRB2_VERSION})
# DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string.
# Version change is fine.
project(SRB2
VERSION ${SRB2_VERSION}
LANGUAGES C CXX)
##### PACKAGE CONFIGURATION #####
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("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
set(SRB2_CPACK_GENERATOR "ZIP")
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
set(SRB2_CPACK_GENERATOR "TGZ")
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
set(SRB2_CPACK_GENERATOR "TGZ")
endif()
endif()
set(CPACK_GENERATOR ${SRB2_CPACK_GENERATOR})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2" CACHE STRING "Program name for display purposes")
set(CPACK_PACKAGE_VENDOR "Sonic Team Jr." CACHE STRING "Vendor name for display purposes")
#set(CPACK_PACKAGE_DESCRIPTION_FILE )
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}")
SET(CPACK_OUTPUT_FILE_PREFIX package)
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")
@ -12,14 +76,18 @@ if (${SRB2_USE_CCACHE})
endif()
endif()
file(STRINGS src/version.h SRB2_VERSION)
string(REGEX MATCH "[0-9]+\\.[0-9.]+" SRB2_VERSION ${SRB2_VERSION})
# Dependencies
add_subdirectory(thirdparty)
# DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string.
# Version change is fine.
project(SRB2
VERSION ${SRB2_VERSION}
LANGUAGES C)
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)
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.")
@ -29,11 +97,6 @@ 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
@ -41,40 +104,6 @@ function(target_sourcefile 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)
@ -89,26 +118,6 @@ 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")
@ -129,29 +138,3 @@ git_current_branch(SRB2_GIT_BRANCH "${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)
##### PACKAGE CONFIGURATION #####
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(${CMAKE_SYSTEM} MATCHES "Windows")
set(SRB2_CPACK_GENERATOR "ZIP")
elseif(${CMAKE_SYSTEM} MATCHES "Linux")
set(SRB2_CPACK_GENERATOR "TGZ")
elseif(${CMAKE_SYSTEM} MATCHES "Darwin")
set(SRB2_CPACK_GENERATOR "TGZ")
endif()
endif()
set(CPACK_GENERATOR ${SRB2_CPACK_GENERATOR})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2" CACHE STRING "Program name for display purposes")
set(CPACK_PACKAGE_VENDOR "Sonic Team Jr." CACHE STRING "Vendor name for display purposes")
#set(CPACK_PACKAGE_DESCRIPTION_FILE )
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}")
SET(CPACK_OUTPUT_FILE_PREFIX package)
include(CPack)

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(GME_LIBRARY
set(GME_PROCESS_INCLUDES GME_INCLUDE_DIR)
set(GME_PROCESS_LIBS GME_LIBRARY)
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_LIBS OPENMPT_LIBRARY)
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_LIBS SDL2_LIBRARY)
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_LIBS SDL2_MIXER_LIBRARY)
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)
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
target_sourcefile(c)
target_sources(SRB2SDL2 PRIVATE comptime.c md5.c config.h.in)
@ -11,193 +14,69 @@ set(SRB2_ASM_SOURCES vid_copy.s)
set(SRB2_NASM_SOURCES tmap_mmx.nas tmap.nas)
### 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_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
"Enable NASM tmap implementation for software mode speedup.")
set(SRB2_CONFIG_YASM OFF CACHE BOOL
"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
"Compile a development build of SRB2.")
### use internal libraries?
if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only
set(SRB2_CONFIG_USE_INTERNAL_LIBRARIES OFF CACHE BOOL
"Use SRB2's internal copies of required dependencies (SDL2, PNG, zlib, GME, OpenMPT).")
endif()
add_subdirectory(blua)
if(${SRB2_CONFIG_HAVE_GME})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(GME_FOUND ON)
set(GME_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/gme/include)
# 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)
set(GME_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/gme/win64 -lgme")
else() # 32-bit
set(GME_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/gme/win32 -lgme")
endif()
else()
find_package(GME)
endif()
if(${GME_FOUND})
set(SRB2_HAVE_GME ON)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_GME)
else()
message(WARNING "You have specified that GME is available but it was not found.")
target_compile_definitions(SRB2SDL2 PRIVATE -DLINUX64)
endif()
endif()
if(${SRB2_CONFIG_HAVE_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)
else()
message(WARNING "You have specified that OpenMPT is available but it was not found.")
endif()
if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
target_compile_definitions(SRB2SDL2 PRIVATE -DMACOSX)
endif()
if(${SRB2_CONFIG_HAVE_MIXERX})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(MIXERX_FOUND ON)
set(MIXERX_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/include/SDL2)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(MIXERX_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDLMixerX/x86_64-w64-mingw32/lib -lSDL2_mixer_ext")
else() # 32-bit
set(MIXERX_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDLMixerX/i686-w64-mingw32/lib -lSDL2_mixer_ext")
endif()
else()
# 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()
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()
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. SRB2 may not compile correctly.")
endif()
endif()
target_link_libraries(SRB2SDL2 PRIVATE openmpt)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_OPENMPT)
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. SRB2 may not compile correctly.")
endif()
endif()
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)
if(${SRB2_CONFIG_HAVE_CURL})
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. SRB2 may not compile correctly.")
endif()
endif()
set(SRB2_HAVE_THREADS ON)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_THREADS)
if(${SRB2_CONFIG_HAVE_THREADS})
set(SRB2_HAVE_THREADS ON)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_THREADS)
endif()
if(${SRB2_CONFIG_HWRENDER})
if("${SRB2_CONFIG_HWRENDER}")
target_compile_definitions(SRB2SDL2 PRIVATE -DHWRENDER)
add_subdirectory(hardware)
endif()
if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL})
if("${SRB2_CONFIG_STATIC_OPENGL}")
find_package(OpenGL)
if(${OPENGL_FOUND})
target_compile_definitions(SRB2SDL2 PRIVATE -DHWRENDER)
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} MATCHES "Linux")
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
set(SRB2_ASM_FLAGS "-DLINUX ${SRB2_ASM_FLAGS}")
endif()
@ -213,7 +92,7 @@ if(${SRB2_CONFIG_USEASM})
set(SRB2_USEASM ON)
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}
${SRB2_NASM_SOURCES})
@ -226,7 +105,7 @@ endif()
# If using CCACHE, then force it.
# 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)
if(RULE_LAUNCH_COMPILE)
MESSAGE(STATUS "Force enabling CCache usage under macOS")
@ -248,34 +127,33 @@ 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")
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()
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()
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-trigraphs)
if(${SRB2_CONFIG_DEV_BUILD})
target_compile_definitions(SRB2SDL2 PRIVATE -DDEVELOP)
endif()
target_compile_definitions(SRB2SDL2 PRIVATE -DCMAKECONFIG)
#add_library(SRB2Core STATIC
# ${SRB2_CORE_SOURCES}
# ${SRB2_CORE_HEADERS}
# ${SRB2_CORE_RENDER_SOURCES}
# ${SRB2_CORE_GAME_SOURCES}
# ${SRB2_LUA_SOURCES}
# ${SRB2_LUA_HEADERS}
# ${SRB2_BLUA_SOURCES}
# ${SRB2_BLUA_HEADERS}
#)
add_subdirectory(sdl)
if(NOT ${SRB2_SDL2_AVAILABLE})
message(FATAL_ERROR "There are no targets available to build an SRB2 executable. :(")
# 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()

View file

@ -1,72 +1,25 @@
# 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)
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_sources(SRB2SDL2 PRIVATE mixer_sound.c)
target_sourcefile(c)
target_sources(SRB2SDL2 PRIVATE ogl_sdl.c)
if(${SRB2_CONFIG_HAVE_THREADS})
target_sources(SRB2SDL2 PRIVATE i_threads.c)
endif()
target_sources(SRB2SDL2 PRIVATE i_threads.c)
# 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 COMPILE_FLAGS "-x assembler-with-cpp")
endif()
endif()
if(${CMAKE_SYSTEM} MATCHES Windows)
if("${CMAKE_SYSTEM_NAME}" MATCHES Windows)
target_sources(SRB2SDL2 PRIVATE
../win32/win_dbg.c
../win32/Srb2win.rc)
endif()
endif()
if(${CMAKE_SYSTEM} MATCHES Darwin)
if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin)
set(MACOSX_BUNDLE_ICON_FILE Srb2mac.icns)
set_source_files_properties(macosx/Srb2mac.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
target_sources(SRB2SDL2 PRIVATE
@ -76,21 +29,22 @@ if(${SDL2_FOUND})
macosx/mac_resources.h
macosx/Srb2mac.icns
)
endif()
endif()
if(${CMAKE_SYSTEM} MATCHES Windows)
if("${CMAKE_SYSTEM_NAME}" MATCHES Windows)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2win)
elseif(${CMAKE_SYSTEM} MATCHES Linux)
elseif("${CMAKE_SYSTEM_NAME}" MATCHES Linux)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsdlsrb2)
else()
else()
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2)
endif()
endif()
if(${CMAKE_SYSTEM} MATCHES Darwin)
if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin)
find_library(CORE_FOUNDATION_LIBRARY "CoreFoundation")
target_link_libraries(SRB2SDL2 PRIVATE
${CORE_FOUNDATION_LIBRARY}
)
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}")
# Configure the app bundle icon and plist properties
@ -102,30 +56,19 @@ if(${SDL2_FOUND})
RESOURCE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns"
)
endif()
endif()
target_link_libraries(SRB2SDL2 PRIVATE
${SDL2_LIBRARIES}
${SDL2_MIXER_LIBRARIES}
${GME_LIBRARIES}
${OPENMPT_LIBRARIES}
${MIXERX_LIBRARIES}
${PNG_LIBRARIES}
${ZLIB_LIBRARIES}
${OPENGL_LIBRARIES}
${CURL_LIBRARIES}
)
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} MATCHES Linux)
target_link_libraries(SRB2SDL2 PRIVATE
m
rt
)
endif()
if("${CMAKE_SYSTEM_NAME}" MATCHES Linux)
target_link_libraries(SRB2SDL2 PRIVATE m rt)
endif()
#target_link_libraries(SRB2SDL2 PRIVATE SRB2Core)
if(${SRB2_USEASM})
if(${SRB2_USEASM})
if(${SRB2_CONFIG_YASM})
set(ASM_ASSEMBLER_TEMP ${CMAKE_ASM_YASM_COMPILER})
set(ASM_ASSEMBLER_OBJFORMAT ${CMAKE_ASM_YASM_OBJECT_FORMAT})
@ -135,60 +78,27 @@ if(${SDL2_FOUND})
set(ASM_ASSEMBLER_OBJFORMAT ${CMAKE_ASM_NASM_OBJECT_FORMAT})
set_source_files_properties(${SRB2_NASM_SOURCES} LANGUAGE ASM_NASM)
endif()
endif()
endif()
if(${CMAKE_SYSTEM} MATCHES Windows)
if("${CMAKE_SYSTEM_NAME}" MATCHES Windows)
target_link_libraries(SRB2SDL2 PRIVATE
ws2_32
)
target_compile_options(SRB2SDL2 PRIVATE
-U_WINDOWS
)
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}
)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER)
target_compile_definitions(SRB2SDL2 PRIVATE -DDIRECTFULLSCREEN -DHAVE_SDL)
if((${SRB2_HAVE_MIXER}) OR (${SRB2_HAVE_MIXERX}))
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER)
endif()
target_compile_definitions(SRB2SDL2 PRIVATE
-DDIRECTFULLSCREEN -DHAVE_SDL
)
## 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} 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()
#### Installation ####
if(${CMAKE_SYSTEM} MATCHES Darwin)
#### Installation ####
if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin)
install(TARGETS SRB2SDL2
BUNDLE DESTINATION .
)
set_property(TARGET SRB2SDL2 PROPERTY INSTALL_RPATH_USE_LINK_PATH ON)
else()
else()
install(TARGETS SRB2SDL2 SRB2SDL2
RUNTIME DESTINATION .
)
@ -201,98 +111,19 @@ 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()
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
# HACK: THIS IS IMPORTANT! See the escaped \${CMAKE_INSTALL_PREFIX}? This
# makes it so that var is evaluated LATER during cpack, not right now!
# This fixes the quirk where the bundled libraries don't land in the final package
# https://cmake.org/pipermail/cmake/2011-March/043532.html
#
# HOWEVER: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY} is NOT escaped, because that var
# 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.
# Therefore, it makes sense to escape that var, but not the other.
if(${CMAKE_SYSTEM} MATCHES Darwin)
# Mac bundle fixup
# HACK: THIS IS IMPORTANT! See the escaped \${CMAKE_INSTALL_PREFIX}? This
# makes it so that var is evaluated LATER during cpack, not right now!
# This fixes the quirk where the bundled libraries don't land in the final package
# https://cmake.org/pipermail/cmake/2011-March/043532.html
#
# HOWEVER: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY} is NOT escaped, because that var
# 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.
# Therefore, it makes sense to escape that var, but not the other.
if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin)
install(CODE "
include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${CPACK_PACKAGE_DESCRIPTION_SUMMARY}.app\"
@ -300,10 +131,6 @@ if(${SDL2_FOUND})
/Library/Frameworks
)"
)
endif()
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()
set(SRB2_SDL2_AVAILABLE YES PARENT_SCOPE)

View file

@ -74,7 +74,7 @@
#endif
#ifdef HAVE_GME
#include "gme/gme.h"
#include <gme/gme.h>
#define GME_TREBLE 5.0f
#define GME_BASS 1.0f
#endif // HAVE_GME

499
thirdparty/CMakeLists.txt vendored Normal file
View file

@ -0,0 +1,499 @@
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()

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