From 0a4f9e43d967d1d99eb6083e6aa5c10f1c73b754 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sun, 7 Dec 2014 21:06:21 +0100 Subject: [PATCH] cmake: clean sdl management * sdl is mandatory for spu2x * cmake will include either /usr/include/SDL or /usr/include/SDL2 so no need to add extra ifdef --- cmake/SearchForStuff.cmake | 16 ++-------------- cmake/SelectPcsx2Plugins.cmake | 24 +++++++++++++----------- plugins/onepad/CMakeLists.txt | 7 ------- plugins/onepad/joystick.h | 8 +++----- plugins/spu2-x/src/CMakeLists.txt | 27 +-------------------------- plugins/spu2-x/src/SndOut.cpp | 4 +--- plugins/spu2-x/src/SndOut.h | 4 +--- plugins/spu2-x/src/SndOut_SDL.cpp | 8 +++----- 8 files changed, 24 insertions(+), 74 deletions(-) diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index 734cf4cd7a..9e224db9e5 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -42,7 +42,6 @@ check_lib(GLESV2 GLESv2 GLES3/gl3ext.h) # NOTE: looking for GLESv3, not GLESv2 check_lib(PORTAUDIO portaudio portaudio.h pa_linux_alsa.h) check_lib(SOUNDTOUCH SoundTouch soundtouch/SoundTouch.h) -# Tell cmake that we use SDL as a library and not as an application if(SDL2_API) check_lib(SDL2 SDL2 SDL.h) else() @@ -51,19 +50,8 @@ else() find_package(SDL) endif() -# Note for include_directory: The order is important to avoid a mess between include file from your system and the one of pcsx2 -# If you include first 3rdparty, all 3rdpary include will have a higer priority... -# If you include first /usr/include, all system include will have a higer priority over the pcsx2 one... -# Current implementation: -# 1/ include 3rdparty sub-directory that we will used (either request or fallback) -# 2/ include system one #---------------------------------------- -# Fallback on 3rdparty libraries -#---------------------------------------- -# Empty - -#---------------------------------------- -# Use system include (if not 3rdparty one) +# Use system include #---------------------------------------- if(Linux) if(GTK2_FOUND) @@ -109,7 +97,7 @@ if(wxWidgets_FOUND) # 64 bits machine with 32 bits library in /usr/lib32 if(_ARCH_64 AND NOT 64BIT_BUILD_DONT_WORK) ## There is no guarantee that wx-config is a link to a 32 bits library. So you need to force the destinity - # Library can go into 3 path major paths (+ multiarch but you will see that later when implementation is done) + # Library can go into 3 path major paths (+ multiarch) # 1/ /usr/lib32 (32 bits only) # 2/ /usr/lib64 (64 bits only) # 3/ /usr/lib (32 or 64 bits depends on distributions) diff --git a/cmake/SelectPcsx2Plugins.cmake b/cmake/SelectPcsx2Plugins.cmake index 7c53f380cf..11e70f4820 100644 --- a/cmake/SelectPcsx2Plugins.cmake +++ b/cmake/SelectPcsx2Plugins.cmake @@ -21,6 +21,8 @@ endif() # Check for additional dependencies. # If all dependencies are available, including OS, build it #------------------------------------------------------------------------------- +set(GTKn_FOUND GTK2_FOUND OR GTK3_FOUND) +set(SDLn_FOUND SDL_FOUND OR SDL2_FOUND) #--------------------------------------- # Common libs @@ -55,7 +57,7 @@ else() message(STATUS "${msg_dep_pcsx2}") endif() # Linux need also gtk2 -if(Linux AND pcsx2_core AND NOT GTK2_FOUND) +if(Linux AND pcsx2_core AND NOT GTKn_FOUND) set(pcsx2_core FALSE) message(STATUS "Skip build of pcsx2 core: miss some dependencies") message(STATUS "${msg_dep_pcsx2}") @@ -73,7 +75,7 @@ endif() #--------------------------------------- # CDVDnull #--------------------------------------- -if(GTK2_FOUND) +if(GTKn_FOUND) set(CDVDnull TRUE) endif() #--------------------------------------- @@ -85,7 +87,7 @@ endif() # -gtk2 (linux) #--------------------------------------- if(EXTRA_PLUGINS) - if(BZIP2_FOUND AND GTK2_FOUND) + if(BZIP2_FOUND AND GTKn_FOUND) set(CDVDiso TRUE) elseif(NOT EXISTS "${CMAKE_SOURCE_DIR}/plugins/CDVDiso") set(CDVDiso FALSE) @@ -106,7 +108,7 @@ endif() #--------------------------------------- # dev9null #--------------------------------------- -if(GTK2_FOUND) +if(GTKn_FOUND) set(dev9null TRUE) endif() #--------------------------------------- @@ -114,7 +116,7 @@ endif() #--------------------------------------- # FWnull #--------------------------------------- -if(GTK2_FOUND) +if(GTKn_FOUND) set(FWnull TRUE) endif() #--------------------------------------- @@ -122,7 +124,7 @@ endif() #--------------------------------------- # GSnull #--------------------------------------- -if(GTK2_FOUND AND EXTRA_PLUGINS) +if(GTKn_FOUND AND EXTRA_PLUGINS) set(GSnull TRUE) endif() #--------------------------------------- @@ -198,7 +200,7 @@ endif() #--------------------------------------- # PadNull #--------------------------------------- -if(GTK2_FOUND AND EXTRA_PLUGINS) +if(GTKn_FOUND AND EXTRA_PLUGINS) set(PadNull TRUE) endif() #--------------------------------------- @@ -208,7 +210,7 @@ endif() #--------------------------------------- # requires: -SDL #--------------------------------------- -if(SDL_FOUND OR SDL2_FOUND) +if(SDLn_FOUND) set(onepad TRUE) elseif(NOT EXISTS "${CMAKE_SOURCE_DIR}/plugins/onepad") set(onepad FALSE) @@ -222,7 +224,7 @@ endif() #--------------------------------------- # SPU2null #--------------------------------------- -if(GTK2_FOUND AND EXTRA_PLUGINS) +if(GTKn_FOUND AND EXTRA_PLUGINS) set(SPU2null TRUE) endif() #--------------------------------------- @@ -236,7 +238,7 @@ endif() # -SDL # -common_libs #--------------------------------------- -if(ALSA_FOUND AND PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND AND (SDL_FOUND OR SDL2_FOUND) AND common_libs) +if(ALSA_FOUND AND PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND AND SDLn_FOUND AND common_libs) set(spu2-x TRUE) elseif(NOT EXISTS "${CMAKE_SOURCE_DIR}/plugins/spu2-x") set(spu2-x FALSE) @@ -273,7 +275,7 @@ endif() #--------------------------------------- # USBnull #--------------------------------------- -if(GTK2_FOUND) +if(GTKn_FOUND) set(USBnull TRUE) endif() #--------------------------------------- diff --git a/plugins/onepad/CMakeLists.txt b/plugins/onepad/CMakeLists.txt index 1900c5c27d..ee387218d0 100644 --- a/plugins/onepad/CMakeLists.txt +++ b/plugins/onepad/CMakeLists.txt @@ -38,13 +38,6 @@ if(CMAKE_BUILD_TYPE STREQUAL Release) ) endif(CMAKE_BUILD_TYPE STREQUAL Release) -if (SDL2_API) - set(onepadFinalFlags - ${onepadFinalFlags} - -DONEPAD_SDL2 - ) -endif() - # onepad sources set(onepadSources controller.cpp diff --git a/plugins/onepad/joystick.h b/plugins/onepad/joystick.h index 84514587fc..a7da84b6c1 100644 --- a/plugins/onepad/joystick.h +++ b/plugins/onepad/joystick.h @@ -22,11 +22,9 @@ #ifndef __JOYSTICK_H__ #define __JOYSTICK_H__ -#ifdef ONEPAD_SDL2 -#include "SDL2/SDL.h" -#include "SDL2/SDL_haptic.h" -#else -#include "SDL/SDL.h" +#include +#if SDL_MAJOR_VERSION >= 2 +#include #endif diff --git a/plugins/spu2-x/src/CMakeLists.txt b/plugins/spu2-x/src/CMakeLists.txt index 9e3e265f92..1ead4c0a50 100644 --- a/plugins/spu2-x/src/CMakeLists.txt +++ b/plugins/spu2-x/src/CMakeLists.txt @@ -65,6 +65,7 @@ set(spu2xSources Reverb.cpp SndOut.cpp SndOut_Portaudio.cpp + SndOut_SDL.cpp spu2freeze.cpp Spu2replay.cpp spu2sys.cpp @@ -111,32 +112,6 @@ set(spu2xLinuxHeaders # add additional include directories include_directories(Linux) -### Don't use yet c11 feature. I will bump gcc requirement to 4.7 when 4.9 is out. -### Note: actually it might work on 4.6 too -# # If compiling on GCC Version 4.7 or higher we build SDLMod in C++11 mode -# if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") -# execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) -# if(GCC_VERSION VERSION_GREATER 4.7) -# set_source_files_properties(SndOut_SDL.cpp PROPERTIES COMPILE_FLAGS -std=c++11) -# message(STATUS "GCC has C++11 support for SDLAudioMod") -# endif(GCC_VERSION VERSION_GREATER 4.7) -# endif() - -if(SDL_FOUND OR SDL2_FOUND) - list(APPEND spu2xSources SndOut_SDL.cpp) - if (SDL2_API) - set(spu2xFinalFlags - ${spu2xFinalFlags} - -DSPU2X_SDL2 - ) - else() - set(spu2xFinalFlags - ${spu2xFinalFlags} - -DSPU2X_SDL - ) - endif() -endif() - set(spu2xFinalSources ${spu2xSources} ${spu2xHeaders} diff --git a/plugins/spu2-x/src/SndOut.cpp b/plugins/spu2-x/src/SndOut.cpp index b308e1eda9..d76a2d48d7 100644 --- a/plugins/spu2-x/src/SndOut.cpp +++ b/plugins/spu2-x/src/SndOut.cpp @@ -92,10 +92,8 @@ SndOutModule* mods[]= WaveOut, #endif PortaudioOut, -#if defined(SPU2X_SDL) || defined(SPU2X_SDL2) - SDLOut, -#endif #ifdef __linux__ + SDLOut, AlsaOut, #endif NULL // signals the end of our list diff --git a/plugins/spu2-x/src/SndOut.h b/plugins/spu2-x/src/SndOut.h index a3a0899fcc..9dbfe33367 100644 --- a/plugins/spu2-x/src/SndOut.h +++ b/plugins/spu2-x/src/SndOut.h @@ -672,10 +672,8 @@ extern SndOutModule* DSoundOut; extern SndOutModule* XAudio2Out; #endif extern SndOutModule* PortaudioOut; -#if defined(SPU2X_SDL) || defined(SPU2X_SDL2) -extern SndOutModule * const SDLOut; -#endif #ifdef __linux__ +extern SndOutModule * const SDLOut; extern SndOutModule* AlsaOut; #endif diff --git a/plugins/spu2-x/src/SndOut_SDL.cpp b/plugins/spu2-x/src/SndOut_SDL.cpp index ba9ea7d21b..172aa2cb1a 100644 --- a/plugins/spu2-x/src/SndOut_SDL.cpp +++ b/plugins/spu2-x/src/SndOut_SDL.cpp @@ -28,13 +28,11 @@ /* Using SDL2 requires other SDL dependencies in pcsx2 get upgraded as well, or the * symbol tables would conflict. Other dependencies in Linux are wxwidgets (you can * build wx without sdl support, though) and onepad at the time of writing this. */ -#ifdef SPU2X_SDL2 -#include -#include +#include +#include +#if SDL_MAJOR_VERSION >= 2 typedef StereoOut32 StereoOut_SDL; #else -#include -#include typedef StereoOut16 StereoOut_SDL; #endif