Merge remote-tracking branch 'origin/master' into next

This commit is contained in:
James R 2020-07-16 19:00:21 -07:00
commit fa90ff6bae
6 changed files with 146 additions and 27 deletions

View File

@ -1,5 +1,17 @@
cmake_minimum_required(VERSION 3.0)
# 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()
file(STRINGS src/version.h SRB2_VERSION)
string(REGEX MATCH "[0-9]+\\.[0-9.]+" SRB2_VERSION ${SRB2_VERSION})
@ -13,6 +25,10 @@ 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()
# Set up CMAKE path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
@ -117,16 +133,19 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINAR
##### PACKAGE CONFIGURATION #####
if(${CMAKE_SYSTEM} MATCHES "Windows")
set(CPACK_GENERATOR "ZIP")
endif()
if(${CMAKE_SYSTEM} MATCHES "Linux")
set(CPACK_GENERATOR "TGZ")
endif()
if(${CMAKE_SYSTEM} MATCHES "Darwin")
set(CPACK_GENERATOR "DragNDrop")
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 )
@ -135,4 +154,5 @@ 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)

View File

@ -12,6 +12,9 @@ ENDFUNCTION(PREPEND)
set(SRB2_ASSET_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/installer"
CACHE STRING "Path to directory that contains all asset files for the installer.")
set(SRB2_ASSET_INSTALL ON
CACHE BOOL "Insert asset files into the install directory or package.")
####################
# POST-V2.2 NOTE: Do not forget to add patch.pk3 to the end of this list!
####################
@ -43,20 +46,27 @@ endforeach()
if(${CMAKE_SYSTEM} MATCHES Darwin)
get_target_property(outname SRB2SDL2 OUTPUT_NAME)
install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/"
DESTINATION "${outname}.app/Contents/Resources"
)
if(${SRB2_ASSET_INSTALL})
install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/"
DESTINATION "${outname}.app/Contents/Resources"
)
endif()
# Always install the doc files, even in non-asset packages.
install(FILES ${SRB2_ASSET_DOCS}
DESTINATION .
OPTIONAL
)
else()
install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/"
DESTINATION .
)
# Docs are assumed to be located in SRB2_ASSET_DIRECTORY, so don't install again
#install(FILES ${SRB2_ASSET_DOCS}
# DESTINATION .
# OPTIONAL
#)
if(${SRB2_ASSET_INSTALL})
install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/"
DESTINATION .
)
# Docs are assumed to be located in SRB2_ASSET_DIRECTORY, so don't install them in their own call.
else()
# Always install the doc files, even in non-asset packages.
install(FILES ${SRB2_ASSET_DOCS}
DESTINATION .
OPTIONAL
)
endif()
endif()

3
cmake/launch-c.in Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
export CCACHE_CPP2=true
exec "${RULE_LAUNCH_COMPILE}" "${CMAKE_C_COMPILER}" "$@"

3
cmake/launch-cxx.in Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
export CCACHE_CPP2=true
exec "${RULE_LAUNCH_COMPILE}" "${CMAKE_C_COMPILER}" "$@"

View File

@ -226,6 +226,12 @@ set(SRB2_CONFIG_HAVE_GME ON CACHE BOOL
"Enable GME support.")
set(SRB2_CONFIG_HAVE_OPENMPT ON CACHE BOOL
"Enable OpenMPT 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
@ -366,6 +372,30 @@ if(${SRB2_CONFIG_HAVE_OPENMPT})
endif()
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)
set(SRB2_SDL2_SOUNDIMPL mixer_sound.c)
add_definitions(-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_ZLIB})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(ZLIB_FOUND ON)
@ -493,6 +523,27 @@ endif()
# Targets
# If using CCACHE, then force it.
# https://github.com/Cockatrice/Cockatrice/pull/3052/files
if (${CMAKE_SYSTEM} MATCHES "Darwin")
get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE)
if(RULE_LAUNCH_COMPILE)
MESSAGE(STATUS "Force enabling CCache usage under macOS")
# Set up wrapper scripts
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/launch-c.in ${CMAKE_BINARY_DIR}/launch-c)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/launch-cxx.in ${CMAKE_BINARY_DIR}/launch-cxx)
execute_process(COMMAND chmod a+rx
"${CMAKE_BINARY_DIR}/launch-c"
"${CMAKE_BINARY_DIR}/launch-cxx")
# Set Xcode project attributes to route compilation through our scripts
set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c")
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx")
set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c")
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx")
endif()
endif()
# Compatibility flag with later versions of GCC
# We should really fix our code to not need this
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")

View File

@ -1,6 +1,10 @@
# Declare SDL2 interface sources
set(SRB2_CONFIG_SDL2_USEMIXER ON CACHE BOOL "Use SDL2_mixer or regular sdl sound")
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})
@ -22,6 +26,8 @@ if(${SRB2_CONFIG_SDL2_USEMIXER})
message(WARNING "You specified that SDL2_mixer is available, but it was not found. Falling back to sdl sound.")
set(SRB2_SDL2_SOUNDIMPL sdl_sound.c)
endif()
elseif(${MIXERX_FOUND})
set(SRB2_SDL2_SOUNDIMPL mixer_sound.c)
else()
set(SRB2_SDL2_SOUNDIMPL sdl_sound.c)
endif()
@ -156,6 +162,7 @@ if(${SDL2_FOUND})
SDL2_mixer
${GME_LIBRARIES}
${OPENMPT_LIBRARIES}
${MIXERX_LIBRARIES}
${PNG_LIBRARIES}
${ZLIB_LIBRARIES}
${OPENGL_LIBRARIES}
@ -167,6 +174,7 @@ if(${SDL2_FOUND})
${SDL2_MIXER_LIBRARIES}
${GME_LIBRARIES}
${OPENMPT_LIBRARIES}
${MIXERX_LIBRARIES}
${PNG_LIBRARIES}
${ZLIB_LIBRARIES}
${OPENGL_LIBRARIES}
@ -247,27 +255,32 @@ if(${SDL2_FOUND})
${SDL2_MIXER_INCLUDE_DIRS}
${GME_INCLUDE_DIRS}
${OPENMPT_INCLUDE_DIRS}
${MIXERX_INCLUDE_DIRS}
${PNG_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
${OPENGL_INCLUDE_DIRS}
)
if(${SRB2_HAVE_MIXER})
if((${SRB2_HAVE_MIXER}) OR (${SRB2_HAVE_MIXERX}))
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER)
endif()
target_compile_definitions(SRB2SDL2 PRIVATE
-DHAVE_SDL
-DDDIRECTFULLSCREEN -DHAVE_SDL
)
## strip debug symbols into separate file when using gcc
if(CMAKE_COMPILER_IS_GNUCC)
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
## 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} --only-keep-debug $<TARGET_FILE:SRB2SDL2> $<TARGET_FILE:SRB2SDL2>.debug
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_NAME:SRB2SDL2>.debug $<TARGET_FILE:SRB2SDL2>
COMMAND ${OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE:SRB2SDL2>.debug $<TARGET_FILE:SRB2SDL2>
)
endif()
endif()
@ -281,6 +294,15 @@ if(${SDL2_FOUND})
install(TARGETS SRB2SDL2 SRB2SDL2
RUNTIME DESTINATION .
)
if ((${CMAKE_BUILD_TYPE} MATCHES Debug) OR (${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo))
set(SRB2_DEBUG_INSTALL OFF CACHE BOOL "Insert *.debug file into the install directory or package.")
if (${SRB2_DEBUG_INSTALL})
install(FILES $<TARGET_FILE:SRB2SDL2>.debug
DESTINATION .
OPTIONAL
)
endif()
endif()
endif()
if(${CMAKE_SYSTEM} MATCHES Windows)
@ -294,6 +316,7 @@ if(${SDL2_FOUND})
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}"
@ -301,6 +324,7 @@ if(${SDL2_FOUND})
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()
@ -310,6 +334,7 @@ if(${SDL2_FOUND})
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}"
@ -317,6 +342,7 @@ if(${SDL2_FOUND})
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()
@ -340,6 +366,12 @@ if(${SDL2_FOUND})
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}