mirror of
https://github.com/love2d/megasource.git
synced 2026-08-19 20:20:11 +02:00
Update SDL to the latest source code (2.0.9 + e1e13e154128)
This commit is contained in:
+72
-41
@@ -42,10 +42,13 @@ include(${SDL2_SOURCE_DIR}/cmake/sdlchecks.cmake)
|
||||
# set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0.
|
||||
set(SDL_MAJOR_VERSION 2)
|
||||
set(SDL_MINOR_VERSION 0)
|
||||
set(SDL_MICRO_VERSION 8)
|
||||
set(SDL_MICRO_VERSION 9)
|
||||
set(SDL_INTERFACE_AGE 0)
|
||||
set(SDL_BINARY_AGE 8)
|
||||
set(SDL_BINARY_AGE 9)
|
||||
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
|
||||
# the following should match the versions in Xcode project file:
|
||||
set(DYLIB_CURRENT_VERSION 10.0.0)
|
||||
set(DYLIB_COMPATIBILITY_VERSION 1.0.0)
|
||||
|
||||
# Set defaults preventing destination file conflicts
|
||||
set(SDL_CMAKE_DEBUG_POSTFIX "d"
|
||||
@@ -61,7 +64,7 @@ set(LT_REVISION "${SDL_INTERFACE_AGE}")
|
||||
set(LT_RELEASE "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}")
|
||||
set(LT_VERSION "${LT_MAJOR}.${LT_AGE}.${LT_REVISION}")
|
||||
|
||||
message(STATUS "${LT_VERSION} :: ${LT_AGE} :: ${LT_REVISION} :: ${LT_CURRENT} :: ${LT_RELEASE}")
|
||||
#message(STATUS "${LT_VERSION} :: ${LT_AGE} :: ${LT_REVISION} :: ${LT_CURRENT} :: ${LT_RELEASE}")
|
||||
|
||||
# General settings & flags
|
||||
set(LIBRARY_OUTPUT_DIRECTORY "build")
|
||||
@@ -210,8 +213,14 @@ endif()
|
||||
set(SDL_LIBS "-lSDL2")
|
||||
set(SDL_CFLAGS "")
|
||||
|
||||
# Emscripten toolchain has a nonempty default value for this, and the checks
|
||||
# in this file need to change that, so remember the original value, and
|
||||
# When building shared lib for Windows with MinGW,
|
||||
# avoid the DLL having a "lib" prefix
|
||||
if(WINDOWS)
|
||||
set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
||||
endif()
|
||||
|
||||
# Emscripten toolchain has a nonempty default value for this, and the checks
|
||||
# in this file need to change that, so remember the original value, and
|
||||
# restore back to that afterwards. For check_function_exists() to work in
|
||||
# Emscripten, this value must be at its default value.
|
||||
set(ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
||||
@@ -244,7 +253,7 @@ endif()
|
||||
set(OPT_DEF_ASM TRUE)
|
||||
if(EMSCRIPTEN)
|
||||
# Set up default values for the currently supported set of subsystems:
|
||||
# Emscripten/Javascript does not have assembly support, a dynamic library
|
||||
# Emscripten/Javascript does not have assembly support, a dynamic library
|
||||
# loading architecture, low-level CPU inspection or multithreading.
|
||||
set(OPT_DEF_ASM FALSE)
|
||||
set(SDL_SHARED_ENABLED_BY_DEFAULT OFF)
|
||||
@@ -261,7 +270,7 @@ endif()
|
||||
|
||||
set(SDL_SUBSYSTEMS
|
||||
Atomic Audio Video Render Events Joystick Haptic Power Threads Timers
|
||||
File Loadso CPUinfo Filesystem Dlopen)
|
||||
File Loadso CPUinfo Filesystem Dlopen Sensor)
|
||||
foreach(_SUB ${SDL_SUBSYSTEMS})
|
||||
string(TOUPPER ${_SUB} _OPT)
|
||||
if (NOT DEFINED SDL_${_OPT}_ENABLED_BY_DEFAULT)
|
||||
@@ -317,8 +326,6 @@ set_option(VIDEO_X11 "Use X11 video driver" ${UNIX_SYS})
|
||||
set_option(VIDEO_WAYLAND "Use Wayland video driver" ${UNIX_SYS})
|
||||
dep_option(WAYLAND_SHARED "Dynamically load Wayland support" ON "VIDEO_WAYLAND" OFF)
|
||||
dep_option(VIDEO_WAYLAND_QT_TOUCH "QtWayland server support for Wayland video driver" ON "VIDEO_WAYLAND" OFF)
|
||||
set_option(VIDEO_MIR "Use Mir video driver" ${UNIX_SYS})
|
||||
dep_option(MIR_SHARED "Dynamically load Mir support" ON "VIDEO_MIR" OFF)
|
||||
set_option(VIDEO_RPI "Use Raspberry Pi video driver" ${UNIX_SYS})
|
||||
dep_option(X11_SHARED "Dynamically load X11 support" ON "VIDEO_X11" OFF)
|
||||
set(SDL_X11_OPTIONS Xcursor Xinerama XInput Xrandr Xscrnsaver XShape Xvm)
|
||||
@@ -328,6 +335,7 @@ foreach(_SUB ${SDL_X11_OPTIONS})
|
||||
endforeach()
|
||||
set_option(VIDEO_COCOA "Use Cocoa video driver" ${APPLE})
|
||||
set_option(DIRECTX "Use DirectX for Windows audio/video" ${WINDOWS})
|
||||
set_option(WASAPI "Use the Windows WASAPI audio driver" ${WINDOWS})
|
||||
set_option(RENDER_D3D "Enable the Direct3D render driver" ${WINDOWS})
|
||||
set_option(VIDEO_VIVANTE "Use Vivante EGL video driver" ${UNIX_SYS})
|
||||
dep_option(VIDEO_VULKAN "Enable Vulkan support" ON "ANDROID OR APPLE OR LINUX OR WINDOWS" OFF)
|
||||
@@ -336,8 +344,8 @@ dep_option(KMSDRM_SHARED "Dynamically load KMS DRM support" ON "VIDEO_KMSD
|
||||
|
||||
# TODO: We should (should we?) respect cmake's ${BUILD_SHARED_LIBS} flag here
|
||||
# The options below are for compatibility to configure's default behaviour.
|
||||
set(SDL_SHARED ON CACHE BOOL "Build a shared version of the library")
|
||||
set(SDL_STATIC OFF CACHE BOOL "Build a static version of the library")
|
||||
set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared version of the library")
|
||||
set(SDL_STATIC ON CACHE BOOL "Build a static version of the library")
|
||||
|
||||
dep_option(SDL_STATIC_PIC "Static version of the library should be built with Position Independent Code" OFF "SDL_STATIC" OFF)
|
||||
set_option(SDL_TEST "Build the test directory" OFF)
|
||||
@@ -444,6 +452,8 @@ if(USE_GCC OR USE_CLANG)
|
||||
|
||||
if(APPLE)
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-undefined,error")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-compatibility_version,${DYLIB_COMPATIBILITY_VERSION}")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-current_version,${DYLIB_CURRENT_VERSION}")
|
||||
else()
|
||||
set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined")
|
||||
check_c_compiler_flag("" HAVE_NO_UNDEFINED)
|
||||
@@ -643,7 +653,7 @@ if(LIBC)
|
||||
_ultoa strtol strtoul strtoll strtod atoi atof strcmp strncmp
|
||||
_stricmp _strnicmp sscanf
|
||||
acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf
|
||||
copysign copysignf cos cosf fabs fabsf floor floorf fmod fmodf
|
||||
copysign copysignf cos cosf exp expf fabs fabsf floor floorf fmod fmodf
|
||||
log logf log10 log10f pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf)
|
||||
string(TOUPPER ${_FN} _UPPER)
|
||||
set(HAVE_${_UPPER} 1)
|
||||
@@ -743,6 +753,10 @@ if(SDL_HAPTIC)
|
||||
file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/*.c)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
|
||||
endif()
|
||||
if(SDL_SENSOR)
|
||||
file(GLOB SENSOR_SOURCES ${SDL2_SOURCE_DIR}/src/sensor/*.c)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${SENSOR_SOURCES})
|
||||
endif()
|
||||
if(SDL_POWER)
|
||||
file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/*.c)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})
|
||||
@@ -844,6 +858,12 @@ if(ANDROID)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
|
||||
set(HAVE_SDL_TIMERS TRUE)
|
||||
endif()
|
||||
if(SDL_SENSOR)
|
||||
set(SDL_SENSOR_ANDROID 1)
|
||||
set(HAVE_SDL_SENSORS TRUE)
|
||||
file(GLOB ANDROID_SENSOR_SOURCES ${SDL2_SOURCE_DIR}/src/sensor/android/*.c)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_SENSOR_SOURCES})
|
||||
endif()
|
||||
if(SDL_VIDEO)
|
||||
set(SDL_VIDEO_DRIVER_ANDROID 1)
|
||||
file(GLOB ANDROID_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/android/*.c)
|
||||
@@ -975,7 +995,6 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID)
|
||||
# Need to check for Raspberry PI first and add platform specific compiler flags, otherwise the test for GLES fails!
|
||||
CheckRPI()
|
||||
CheckX11()
|
||||
CheckMir()
|
||||
CheckDirectFB()
|
||||
CheckOpenGLX11()
|
||||
CheckOpenGLESX11()
|
||||
@@ -1001,7 +1020,7 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID)
|
||||
#include <linux/kd.h>
|
||||
#include <linux/keyboard.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct kbentry kbe;
|
||||
kbe.kb_table = KG_CTRL;
|
||||
@@ -1042,6 +1061,12 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID)
|
||||
include_directories(${IBUS_INCLUDE_DIRS})
|
||||
list(APPEND EXTRA_LIBS ${IBUS_LIBRARIES})
|
||||
endif()
|
||||
if(HAVE_LIBUNWIND_H)
|
||||
# We've already found the header, so REQUIRE the lib to be present
|
||||
pkg_search_module(UNWIND REQUIRED libunwind)
|
||||
pkg_search_module(UNWIND_GENERIC REQUIRED libunwind-generic)
|
||||
list(APPEND EXTRA_LIBS ${UNWIND_LIBRARIES} ${UNWIND_GENERIC_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
check_include_file("fcitx/frontend.h" HAVE_FCITX_FRONTEND_H)
|
||||
@@ -1146,8 +1171,6 @@ elseif(WINDOWS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(SDL_LINK_DIR ${PARENT_SCOPE})
|
||||
|
||||
# Check for DirectX
|
||||
if(DIRECTX)
|
||||
if(DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700)
|
||||
@@ -1185,21 +1208,22 @@ elseif(WINDOWS)
|
||||
check_include_file(ddraw.h HAVE_DDRAW_H)
|
||||
check_include_file(dsound.h HAVE_DSOUND_H)
|
||||
check_include_file(dinput.h HAVE_DINPUT_H)
|
||||
check_include_file(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
|
||||
check_include_file(audioclient.h HAVE_AUDIOCLIENT_H)
|
||||
check_include_file(dxgi.h HAVE_DXGI_H)
|
||||
if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H)
|
||||
set(HAVE_DIRECTX TRUE)
|
||||
if(NOT CMAKE_COMPILER_IS_MINGW AND NOT USE_WINSDK_DIRECTX)
|
||||
# TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
|
||||
set(SDL_LINK_DIR $ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH} ${SDL_LINK_DIR})
|
||||
link_directories($ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH})
|
||||
include_directories($ENV{DXSDK_DIR}\\Include)
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
||||
endif()
|
||||
|
||||
link_directories(${SDL_LINK_DIR})
|
||||
# headers needed elsewhere ...
|
||||
check_include_file(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
|
||||
check_include_file(audioclient.h HAVE_AUDIOCLIENT_H)
|
||||
check_include_file(endpointvolume.h HAVE_ENDPOINTVOLUME_H)
|
||||
|
||||
if(SDL_AUDIO)
|
||||
set(SDL_AUDIO_DRIVER_WINMM 1)
|
||||
@@ -1213,7 +1237,7 @@ elseif(WINDOWS)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${DSOUND_AUDIO_SOURCES})
|
||||
endif()
|
||||
|
||||
if(HAVE_AUDIOCLIENT_H AND HAVE_MMDEVICEAPI_H)
|
||||
if(WASAPI AND HAVE_AUDIOCLIENT_H AND HAVE_MMDEVICEAPI_H)
|
||||
set(SDL_AUDIO_DRIVER_WASAPI 1)
|
||||
file(GLOB WASAPI_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/wasapi/*.c)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${WASAPI_AUDIO_SOURCES})
|
||||
@@ -1531,6 +1555,7 @@ endif()
|
||||
|
||||
if(VIDEO_VULKAN)
|
||||
set(SDL_VIDEO_VULKAN 1)
|
||||
set(HAVE_VIDEO_VULKAN TRUE)
|
||||
endif()
|
||||
|
||||
# Dummies
|
||||
@@ -1542,7 +1567,7 @@ endif()
|
||||
# This leads to missing internal references on building, since the
|
||||
# src/X/*.c does not get included.
|
||||
if(NOT HAVE_SDL_JOYSTICK)
|
||||
set(SDL_JOYSTICK_DISABLED 1)
|
||||
set(SDL_JOYSTICK_DUMMY 1)
|
||||
if(SDL_JOYSTICK AND NOT APPLE) # results in unresolved symbols on OSX
|
||||
|
||||
file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/dummy/*.c)
|
||||
@@ -1550,10 +1575,15 @@ if(NOT HAVE_SDL_JOYSTICK)
|
||||
endif()
|
||||
endif()
|
||||
if(NOT HAVE_SDL_HAPTIC)
|
||||
set(SDL_HAPTIC_DISABLED 1)
|
||||
set(SDL_HAPTIC_DUMMY 1)
|
||||
file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/dummy/*.c)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
|
||||
endif()
|
||||
if(NOT HAVE_SDL_SENSORS)
|
||||
set(SDL_SENSOR_DUMMY 1)
|
||||
file(GLOB SENSORS_SOURCES ${SDL2_SOURCE_DIR}/src/sensor/dummy/*.c)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${SENSORS_SOURCES})
|
||||
endif()
|
||||
if(NOT HAVE_SDL_LOADSO)
|
||||
set(SDL_LOADSO_DISABLED 1)
|
||||
file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dummy/*.c)
|
||||
@@ -1699,7 +1729,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
|
||||
|
||||
# Always build SDLmain
|
||||
add_library(SDL2main STATIC ${SDLMAIN_SOURCES})
|
||||
target_include_directories(SDL2main PUBLIC include)
|
||||
target_include_directories(SDL2main PUBLIC "$<BUILD_INTERFACE:${SDL2_SOURCE_DIR}/include>" $<INSTALL_INTERFACE:include/SDL2>)
|
||||
set(_INSTALL_LIBS "SDL2main")
|
||||
if (NOT ANDROID)
|
||||
set_target_properties(SDL2main PROPERTIES DEBUG_POSTFIX ${SDL_CMAKE_DEBUG_POSTFIX})
|
||||
@@ -1707,9 +1737,10 @@ endif()
|
||||
|
||||
if(SDL_SHARED)
|
||||
add_library(SDL2 SHARED ${SOURCE_FILES} ${VERSION_SOURCES})
|
||||
install(TARGETS SDL2 RUNTIME DESTINATION . LIBRARY DESTINATION .)
|
||||
if(APPLE)
|
||||
set_target_properties(SDL2 PROPERTIES MACOSX_RPATH 1)
|
||||
set_target_properties(SDL2 PROPERTIES
|
||||
MACOSX_RPATH 1
|
||||
OUTPUT_NAME "SDL2-${LT_RELEASE}")
|
||||
elseif(UNIX AND NOT ANDROID)
|
||||
set_target_properties(SDL2 PROPERTIES
|
||||
VERSION ${LT_VERSION}
|
||||
@@ -1729,7 +1760,7 @@ if(SDL_SHARED)
|
||||
endif()
|
||||
set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS})
|
||||
target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
|
||||
target_include_directories(SDL2 PUBLIC include)
|
||||
target_include_directories(SDL2 PUBLIC "$<BUILD_INTERFACE:${SDL2_SOURCE_DIR}/include>" $<INSTALL_INTERFACE:include/SDL2>)
|
||||
if (NOT ANDROID)
|
||||
set_target_properties(SDL2 PROPERTIES DEBUG_POSTFIX ${SDL_CMAKE_DEBUG_POSTFIX})
|
||||
endif()
|
||||
@@ -1755,7 +1786,7 @@ if(SDL_STATIC)
|
||||
# libraries - do we need to consider this?
|
||||
set(_INSTALL_LIBS "SDL2-static" ${_INSTALL_LIBS})
|
||||
target_link_libraries(SDL2-static ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
|
||||
target_include_directories(SDL2-static PUBLIC include)
|
||||
target_include_directories(SDL2-static PUBLIC "$<BUILD_INTERFACE:${SDL2_SOURCE_DIR}/include>" $<INSTALL_INTERFACE:include/SDL2>)
|
||||
if (NOT ANDROID)
|
||||
set_target_properties(SDL2-static PROPERTIES DEBUG_POSTFIX ${SDL_CMAKE_DEBUG_POSTFIX})
|
||||
endif()
|
||||
@@ -1766,16 +1797,11 @@ endif()
|
||||
if(SDL_TEST)
|
||||
file(GLOB TEST_SOURCES ${SDL2_SOURCE_DIR}/src/test/*.c)
|
||||
add_library(SDL2_test STATIC ${TEST_SOURCES})
|
||||
|
||||
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
##### Installation targets #####
|
||||
|
||||
if(MEGA)
|
||||
return()
|
||||
endif()
|
||||
|
||||
install(TARGETS ${_INSTALL_LIBS} EXPORT SDL2Targets
|
||||
LIBRARY DESTINATION "lib${LIB_SUFFIX}"
|
||||
ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
|
||||
@@ -1818,18 +1844,23 @@ endforeach()
|
||||
list(APPEND INCLUDE_FILES ${BIN_INCLUDE_FILES})
|
||||
install(FILES ${INCLUDE_FILES} DESTINATION include/SDL2)
|
||||
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPER_BUILD_TYPE)
|
||||
if (UPPER_BUILD_TYPE MATCHES DEBUG)
|
||||
set(SOPOSTFIX "${SDL_CMAKE_DEBUG_POSTFIX}")
|
||||
else()
|
||||
set(SOPOSTFIX "")
|
||||
endif()
|
||||
|
||||
if(NOT (WINDOWS OR CYGWIN))
|
||||
if(SDL_SHARED)
|
||||
if (APPLE)
|
||||
set(SOEXT "dylib")
|
||||
else()
|
||||
set(SOEXT "so")
|
||||
endif()
|
||||
set(SOEXT ${CMAKE_SHARED_LIBRARY_SUFFIX}) # ".so", ".dylib", etc.
|
||||
get_target_property(SONAME SDL2 OUTPUT_NAME)
|
||||
if(NOT ANDROID)
|
||||
install(CODE "
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
\"libSDL2-2.0.${SOEXT}\" \"libSDL2.${SOEXT}\")")
|
||||
install(FILES ${SDL2_BINARY_DIR}/libSDL2.${SOEXT} DESTINATION "lib${LIB_SUFFIX}")
|
||||
\"lib${SONAME}${SOPOSTFIX}${SOEXT}\" \"libSDL2${SOPOSTFIX}${SOEXT}\")"
|
||||
WORKING_DIR "${SDL2_BINARY_DIR}")
|
||||
install(FILES ${SDL2_BINARY_DIR}/libSDL2${SOPOSTFIX}${SOEXT} DESTINATION "lib${LIB_SUFFIX}")
|
||||
endif()
|
||||
endif()
|
||||
if(FREEBSD)
|
||||
|
||||
Reference in New Issue
Block a user