Skip to content

Commit

Permalink
Merge branch 'development' into osxDedeprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
Areloch committed Jan 31, 2017
2 parents 6a10485 + 15ef6bd commit 8f42089
Show file tree
Hide file tree
Showing 529 changed files with 17,480 additions and 21,812 deletions.
Empty file modified Engine/lib/sdl/Android.mk
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion Engine/lib/sdl/BUGS.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Bugs are now managed in the SDL bug tracker, here:

http://bugzilla.libsdl.org/
https://bugzilla.libsdl.org/

You may report bugs there, and search to see if a given issue has already
been reported, discussed, and maybe even fixed.
Expand Down
183 changes: 134 additions & 49 deletions Engine/lib/sdl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the SDL source code and call cmake from there")
endif()

cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 2.8.5)
project(SDL2 C)

# !!! FIXME: this should probably do "MACOSX_RPATH ON" as a target property
# !!! FIXME: for the SDL2 shared library (so you get an
# !!! FIXME: install_name ("soname") of "@rpath/libSDL-whatever.dylib"
# !!! FIXME: instead of "/usr/local/lib/libSDL-whatever.dylib"), but I'm
# !!! FIXME: punting for now and leaving the existing behavior. Until this
# !!! FIXME: properly resolved, this line silences a warning in CMake 3.0+.
# !!! FIXME: remove it and this comment entirely once the problem is
# !!! FIXME: properly resolved.
#cmake_policy(SET CMP0042 OLD)

include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckIncludeFiles)
Expand All @@ -15,6 +26,7 @@ include(CheckTypeSize)
include(CheckStructHasMember)
include(CMakeDependentOption)
include(FindPkgConfig)
include(GNUInstallDirs)
set(CMAKE_MODULE_PATH "${SDL2_SOURCE_DIR}/cmake")
include(${SDL2_SOURCE_DIR}/cmake/macros.cmake)
include(${SDL2_SOURCE_DIR}/cmake/sdlchecks.cmake)
Expand All @@ -29,9 +41,9 @@ 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 4)
set(SDL_INTERFACE_AGE 0)
set(SDL_BINARY_AGE 4)
set(SDL_MICRO_VERSION 5)
set(SDL_INTERFACE_AGE 1)
set(SDL_BINARY_AGE 5)
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")

# Calculate a libtool-like version number
Expand Down Expand Up @@ -147,8 +159,10 @@ endif()

# Default flags, if not set otherwise
if("$ENV{CFLAGS}" STREQUAL "")
if(USE_GCC OR USE_CLANG)
set(CMAKE_C_FLAGS "-g -O3")
if(CMAKE_BUILD_TYPE STREQUAL "")
if(USE_GCC OR USE_CLANG)
set(CMAKE_C_FLAGS "-g -O3")
endif()
endif()
else()
set(CMAKE_C_FLAGS "$ENV{CFLAGS}")
Expand Down Expand Up @@ -183,16 +197,16 @@ 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
# 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})

if(CYGWIN)
# We build SDL on cygwin without the UNIX emulation layer
include_directories("-I/usr/include/mingw")
set(CMAKE_REQUIRED_FLAGS "-mno-cygwin")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -mno-cygwin")
check_c_source_compiles("int main(int argc, char **argv) {}"
HAVE_GCC_NO_CYGWIN)
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
Expand All @@ -212,7 +226,7 @@ include_directories(${SDL2_BINARY_DIR}/include ${SDL2_SOURCE_DIR}/include)
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)
Expand Down Expand Up @@ -299,6 +313,8 @@ set_option(VIDEO_VIVANTE "Use Vivante EGL video driver" ${UNIX_SYS})
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)

# General source files
file(GLOB SOURCE_FILES
${SDL2_SOURCE_DIR}/src/*.c
Expand Down Expand Up @@ -334,6 +350,24 @@ set(HAVE_ASSERTIONS ${ASSERTIONS})

# Compiler option evaluation
if(USE_GCC OR USE_CLANG)
# Check for -Wall first, so later things can override pieces of it.
check_c_compiler_flag(-Wall HAVE_GCC_WALL)
if(HAVE_GCC_WALL)
list(APPEND EXTRA_CFLAGS "-Wall")
if(HAIKU)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar")
endif()
endif()

check_c_compiler_flag(-Wdeclaration-after-statement HAVE_GCC_WDECLARATION_AFTER_STATEMENT)
if(HAVE_GCC_WDECLARATION_AFTER_STATEMENT)
check_c_compiler_flag(-Werror=declaration-after-statement HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT)
if(HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT)
list(APPEND EXTRA_CFLAGS "-Werror=declaration-after-statement")
endif()
list(APPEND EXTRA_CFLAGS "-Wdeclaration-after-statement")
endif()

if(DEPENDENCY_TRACKING)
check_c_source_compiles("
#if !defined(__GNUC__) || __GNUC__ < 3
Expand Down Expand Up @@ -375,26 +409,16 @@ if(USE_GCC OR USE_CLANG)
endif()
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})

check_c_compiler_flag(-Wall HAVE_GCC_WALL)
if(HAVE_GCC_WALL)
list(APPEND EXTRA_CFLAGS "-Wall")
if(HAIKU)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar")
endif()
endif()
check_c_compiler_flag(-Wshadow HAVE_GCC_WSHADOW)
if(HAVE_GCC_WSHADOW)
list(APPEND EXTRA_CFLAGS "-Wshadow")
endif()

# --no-undefined is unsupported with clang
if(NOT USE_CLANG)
set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined")
check_c_compiler_flag("" HAVE_NO_UNDEFINED)
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
if(HAVE_NO_UNDEFINED)
list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined")
endif()
set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined")
check_c_compiler_flag("" HAVE_NO_UNDEFINED)
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
if(HAVE_NO_UNDEFINED)
list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined")
endif()
endif()

Expand Down Expand Up @@ -773,6 +797,16 @@ if(EMSCRIPTEN)
set(SOURCE_FILES ${SOURCE_FILES} ${EM_POWER_SOURCES})
set(HAVE_SDL_POWER TRUE)
endif()
if(SDL_TIMERS)
set(SDL_TIMER_UNIX 1)
file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
set(HAVE_SDL_TIMERS TRUE)

if(CLOCK_GETTIME)
set(HAVE_CLOCK_GETTIME 1)
endif()
endif()
if(SDL_VIDEO)
set(SDL_VIDEO_DRIVER_EMSCRIPTEN 1)
file(GLOB EM_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/emscripten/*.c)
Expand Down Expand Up @@ -839,7 +873,7 @@ elseif(UNIX AND NOT APPLE)
#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;
Expand All @@ -866,8 +900,24 @@ elseif(UNIX AND NOT APPLE)

check_include_file("libudev.h" HAVE_LIBUDEV_H)

# !!! FIXME: this needs pkg-config to find the include path, I think.
check_include_file("dbus/dbus.h" HAVE_DBUS_DBUS_H)
if(PKG_CONFIG_FOUND)
pkg_search_module(DBUS dbus-1 dbus)
if(DBUS_FOUND)
set(HAVE_DBUS_DBUS_H TRUE)
include_directories(${DBUS_INCLUDE_DIRS})
list(APPEND EXTRA_LIBS ${DBUS_LIBRARIES})
endif()

pkg_search_module(IBUS ibus-1.0 ibus)
if(IBUS_FOUND)
set(HAVE_IBUS_IBUS_H TRUE)
include_directories(${IBUS_INCLUDE_DIRS})
list(APPEND EXTRA_LIBS ${IBUS_LIBRARIES})
endif()
endif()

check_include_file("fcitx/frontend.h" HAVE_FCITX_FRONTEND_H)

endif()

if(INPUT_TSLIB)
Expand Down Expand Up @@ -936,7 +986,14 @@ elseif(UNIX AND NOT APPLE)
if(RPATH)
set(SDL_RLD_FLAGS "")
if(BSDI OR FREEBSD OR LINUX OR NETBSD)
set(SDL_RLD_FLAGS "-Wl,-rpath,\${libdir}")
set(CMAKE_REQUIRED_FLAGS "-Wl,--enable-new-dtags")
check_c_compiler_flag("" HAVE_ENABLE_NEW_DTAGS)
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
if(HAVE_ENABLE_NEW_DTAGS)
set(SDL_RLD_FLAGS "-Wl,-rpath,\${libdir} -Wl,--enable-new-dtags")
else()
set(SDL_RLD_FLAGS "-Wl,-rpath,\${libdir}")
endif()
elseif(SOLARIS)
set(SDL_RLD_FLAGS "-R\${libdir}")
endif()
Expand Down Expand Up @@ -1108,7 +1165,7 @@ elseif(WINDOWS)
set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
if(HAVE_DINPUT_H)
set(SDL_JOYSTICK_DINPUT 1)
list(APPEND EXTRA_LIBS dinput8 dxguid)
list(APPEND EXTRA_LIBS dinput8)
if(CMAKE_COMPILER_IS_MINGW)
list(APPEND EXTRA_LIBS dxerr8)
elseif (NOT USE_WINSDK_DIRECTX)
Expand Down Expand Up @@ -1166,16 +1223,20 @@ elseif(APPLE)

if(SDL_AUDIO)
set(SDL_AUDIO_DRIVER_COREAUDIO 1)
file(GLOB AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/coreaudio/*.c)
file(GLOB AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/coreaudio/*.m)
set(SOURCE_FILES ${SOURCE_FILES} ${AUDIO_SOURCES})
set(HAVE_SDL_AUDIO TRUE)
set(SDL_FRAMEWORK_COREAUDIO 1)
set(SDL_FRAMEWORK_AUDIOUNIT 1)
set(SDL_FRAMEWORK_AUDIOTOOLBOX 1)
endif()

if(SDL_JOYSTICK)
set(SDL_JOYSTICK_IOKIT 1)
file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/darwin/*.c)
if (IOS)
file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/iphoneos/*.m)
else()
file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/darwin/*.c)
endif()
set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
set(HAVE_SDL_JOYSTICK TRUE)
set(SDL_FRAMEWORK_IOKIT 1)
Expand All @@ -1184,7 +1245,12 @@ elseif(APPLE)

if(SDL_HAPTIC)
set(SDL_HAPTIC_IOKIT 1)
file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/darwin/*.c)
if (IOS)
file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/dummy/*.c)
set(SDL_HAPTIC_DUMMY 1)
else()
file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/darwin/*.c)
endif()
set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
set(HAVE_SDL_HAPTIC TRUE)
set(SDL_FRAMEWORK_IOKIT 1)
Expand All @@ -1196,7 +1262,11 @@ elseif(APPLE)

if(SDL_POWER)
set(SDL_POWER_MACOSX 1)
file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/macosx/*.c)
if (IOS)
file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/uikit/*.m)
else()
file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/macosx/*.c)
endif()
set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})
set(HAVE_SDL_POWER TRUE)
set(SDL_FRAMEWORK_CARBON 1)
Expand Down Expand Up @@ -1243,19 +1313,25 @@ elseif(APPLE)
find_library(COREAUDIO CoreAudio)
list(APPEND EXTRA_LIBS ${COREAUDIO})
endif()
if(SDL_FRAMEWORK_AUDIOUNIT)
find_library(AUDIOUNIT AudioUnit)
list(APPEND EXTRA_LIBS ${AUDIOUNIT})
if(SDL_FRAMEWORK_AUDIOTOOLBOX)
find_library(AUDIOTOOLBOX AudioToolbox)
list(APPEND EXTRA_LIBS ${AUDIOTOOLBOX})
endif()

# iOS hack needed - http://code.google.com/p/ios-cmake/ ?
if(SDL_VIDEO)
CheckCOCOA()
if(VIDEO_OPENGL)
set(SDL_VIDEO_OPENGL 1)
set(SDL_VIDEO_OPENGL_CGL 1)
set(SDL_VIDEO_RENDER_OGL 1)
set(HAVE_VIDEO_OPENGL TRUE)
if (IOS)
set(SDL_VIDEO_DRIVER_UIKIT 1)
file(GLOB UIKITVIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/uikit/*.m)
set(SOURCE_FILES ${SOURCE_FILES} ${UIKITVIDEO_SOURCES})
else()
CheckCOCOA()
if(VIDEO_OPENGL)
set(SDL_VIDEO_OPENGL 1)
set(SDL_VIDEO_OPENGL_CGL 1)
set(SDL_VIDEO_RENDER_OGL 1)
set(HAVE_VIDEO_OPENGL TRUE)
endif()
endif()
endif()

Expand Down Expand Up @@ -1442,6 +1518,9 @@ message(STATUS " EXTRA_LIBS: ${EXTRA_LIBS}")
message(STATUS "")
message(STATUS " Build Shared Library: ${SDL_SHARED}")
message(STATUS " Build Static Library: ${SDL_STATIC}")
if(SDL_STATIC)
message(STATUS " Build Static Library with Position Independent Code: ${SDL_STATIC_PIC}")
endif()
message(STATUS "")
if(UNIX)
message(STATUS "If something was not detected, although the libraries")
Expand All @@ -1458,7 +1537,7 @@ add_library(SDL2main STATIC ${SDLMAIN_SOURCES})
set(_INSTALL_LIBS "SDL2main")

if(SDL_SHARED)
add_library(SDL2 SHARED ${SOURCE_FILES})
add_library(SDL2 SHARED ${SOURCE_FILES} ${VERSION_SOURCES})
if(UNIX)
set_target_properties(SDL2 PROPERTIES
VERSION ${LT_VERSION}
Expand All @@ -1484,6 +1563,7 @@ if(SDL_STATIC)
set (BUILD_SHARED_LIBS FALSE)
add_library(SDL2-static STATIC ${SOURCE_FILES})
set_target_properties(SDL2-static PROPERTIES OUTPUT_NAME "SDL2")
set_target_properties(SDL2-static PROPERTIES POSITION_INDEPENDENT_CODE ${SDL_STATIC_PIC})
if(MSVC)
set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB")
set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB")
Expand All @@ -1510,12 +1590,17 @@ endforeach()
list(APPEND INCLUDE_FILES ${BIN_INCLUDE_FILES})
install(FILES ${INCLUDE_FILES} DESTINATION include/SDL2)

if(NOT WINDOWS OR CYGWIN)
if(NOT (WINDOWS OR CYGWIN))
if(SDL_SHARED)
if (APPLE)
set(SOEXT "dylib")
else()
set(SOEXT "so")
endif()
install(CODE "
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
\"libSDL2-2.0.so\" \"libSDL2.so\")")
install(FILES ${SDL2_BINARY_DIR}/libSDL2.so DESTINATION "lib${LIB_SUFFIX}")
\"libSDL2-2.0.${SOEXT}\" \"libSDL2.${SOEXT}\")")
install(FILES ${SDL2_BINARY_DIR}/libSDL2.${SOEXT} DESTINATION "lib${LIB_SUFFIX}")
endif()
if(FREEBSD)
# FreeBSD uses ${PREFIX}/libdata/pkgconfig
Expand All @@ -1526,7 +1611,7 @@ if(NOT WINDOWS OR CYGWIN)
endif()
install(PROGRAMS ${SDL2_BINARY_DIR}/sdl2-config DESTINATION bin)
# TODO: what about the .spec file? Is it only needed for RPM creation?
install(FILES "${SDL2_SOURCE_DIR}/sdl2.m4" DESTINATION "share/aclocal")
install(FILES "${SDL2_SOURCE_DIR}/sdl2.m4" DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/aclocal")
endif()

##### Uninstall target #####
Expand Down
Loading

0 comments on commit 8f42089

Please sign in to comment.