From 9065ddf5fadf337b6b8cd5ed7a36bf796199cda2 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Mon, 29 Jun 2015 13:09:24 +1200 Subject: [PATCH] Linux: Disable SDL controller backend by default. Not deleted, because it's the only option for some other operating systems such as FreeBSD or any other slightly exotic operating system someone might try and run dolphin on. --- CMakeLists.txt | 19 +++++++++++-------- CMakeTests/FindSDL2.cmake | 15 ++++++++++++++- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e64061a6b7..5162b86dd4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,14 @@ option(ENABLE_PCH "Use PCH to speed up compilation" ON) option(ENABLE_PIE "Build a Position-Independent Executable (PIE)" ON) option(ENABLE_LTO "Enables Link Time Optimization" OFF) option(ENABLE_GENERIC "Enables generic build that should run on any little-endian host" OFF) + +# Enable SDL for default on operating systems that aren't OSX, Android, Linux or Windows. +if(NOT APPLE AND NOT ANDROID AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT MSVC) + option(ENABLE_SDL "Enables SDL as a generic controller backend" ON) +else() + option(ENABLE_SDL "Enables SDL as a generic controller backend" OFF) +endif() + if(APPLE) option(OSX_USE_DEFAULT_SEARCH_PATH "Don't prioritize system library paths" OFF) endif() @@ -632,26 +640,21 @@ if(OPENAL_FOUND) endif() endif() -if(NOT ANDROID) - if(NOT APPLE) - include(FindSDL2 OPTIONAL) - endif() +if(ENABLE_SDL) + include(FindSDL2 OPTIONAL) if(SDL2_FOUND) message("Using shared SDL2") add_definitions(-DHAVE_SDL=1) include_directories(${SDL2_INCLUDE_DIR}) else(SDL2_FOUND) # SDL2 not found, try SDL - if(NOT APPLE) - include(FindSDL OPTIONAL) - endif() + include(FindSDL OPTIONAL) if(SDL_FOUND) message("Using shared SDL") add_definitions(-DHAVE_SDL=1) include_directories(${SDL_INCLUDE_DIR}) else(SDL_FOUND) message("SDL NOT found, disabling SDL input") - add_definitions(-DHAVE_SDL=0) endif(SDL_FOUND) endif(SDL2_FOUND) endif() diff --git a/CMakeTests/FindSDL2.cmake b/CMakeTests/FindSDL2.cmake index 614426cccf..aef817ec6a 100644 --- a/CMakeTests/FindSDL2.cmake +++ b/CMakeTests/FindSDL2.cmake @@ -172,9 +172,22 @@ IF(SDL2_LIBRARY_TEMP) SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "") SET(SDL2_FOUND "YES") + + # extract the major and minor version numbers from SDL2/SDL_version.h + # we have to handle framework a little bit differently : + if("${SDL2_INCLUDE_DIR}" MATCHES ".framework") + set(SDL2_VERSION_H_INPUT "${SDL2_INCLUDE_DIR}/Headers/SDL_version.h") + else() + set(SDL2_VERSION_H_INPUT "${SDL2_INCLUDE_DIR}/SDL_version.h") + endif() + FILE(READ "${SDL2_VERSION_H_INPUT}" SDL2_VERSION_H_CONTENTS) + STRING(REGEX REPLACE ".*#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+).*#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+).*#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+).*" + "\\1.\\2.\\3" SDL2_VERSION "${SDL2_VERSION_H_CONTENTS}") +#MESSAGE("SDL2 Version is ${SDL2_VERSION}") + ENDIF(SDL2_LIBRARY_TEMP) INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 - REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR) + REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR VERSION_VAR SDL2_VERSION)