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
This commit is contained in:
Gregory Hainaut 2014-12-07 21:06:21 +01:00
parent 9e8b0b59ba
commit 0a4f9e43d9
8 changed files with 24 additions and 74 deletions

View File

@ -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(PORTAUDIO portaudio portaudio.h pa_linux_alsa.h)
check_lib(SOUNDTOUCH SoundTouch soundtouch/SoundTouch.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) if(SDL2_API)
check_lib(SDL2 SDL2 SDL.h) check_lib(SDL2 SDL2 SDL.h)
else() else()
@ -51,19 +50,8 @@ else()
find_package(SDL) find_package(SDL)
endif() 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 # Use system include
#----------------------------------------
# Empty
#----------------------------------------
# Use system include (if not 3rdparty one)
#---------------------------------------- #----------------------------------------
if(Linux) if(Linux)
if(GTK2_FOUND) if(GTK2_FOUND)
@ -109,7 +97,7 @@ if(wxWidgets_FOUND)
# 64 bits machine with 32 bits library in /usr/lib32 # 64 bits machine with 32 bits library in /usr/lib32
if(_ARCH_64 AND NOT 64BIT_BUILD_DONT_WORK) 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 ## 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) # 1/ /usr/lib32 (32 bits only)
# 2/ /usr/lib64 (64 bits only) # 2/ /usr/lib64 (64 bits only)
# 3/ /usr/lib (32 or 64 bits depends on distributions) # 3/ /usr/lib (32 or 64 bits depends on distributions)

View File

@ -21,6 +21,8 @@ endif()
# Check for additional dependencies. # Check for additional dependencies.
# If all dependencies are available, including OS, build it # 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 # Common libs
@ -55,7 +57,7 @@ else()
message(STATUS "${msg_dep_pcsx2}") message(STATUS "${msg_dep_pcsx2}")
endif() endif()
# Linux need also gtk2 # 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) set(pcsx2_core FALSE)
message(STATUS "Skip build of pcsx2 core: miss some dependencies") message(STATUS "Skip build of pcsx2 core: miss some dependencies")
message(STATUS "${msg_dep_pcsx2}") message(STATUS "${msg_dep_pcsx2}")
@ -73,7 +75,7 @@ endif()
#--------------------------------------- #---------------------------------------
# CDVDnull # CDVDnull
#--------------------------------------- #---------------------------------------
if(GTK2_FOUND) if(GTKn_FOUND)
set(CDVDnull TRUE) set(CDVDnull TRUE)
endif() endif()
#--------------------------------------- #---------------------------------------
@ -85,7 +87,7 @@ endif()
# -gtk2 (linux) # -gtk2 (linux)
#--------------------------------------- #---------------------------------------
if(EXTRA_PLUGINS) if(EXTRA_PLUGINS)
if(BZIP2_FOUND AND GTK2_FOUND) if(BZIP2_FOUND AND GTKn_FOUND)
set(CDVDiso TRUE) set(CDVDiso TRUE)
elseif(NOT EXISTS "${CMAKE_SOURCE_DIR}/plugins/CDVDiso") elseif(NOT EXISTS "${CMAKE_SOURCE_DIR}/plugins/CDVDiso")
set(CDVDiso FALSE) set(CDVDiso FALSE)
@ -106,7 +108,7 @@ endif()
#--------------------------------------- #---------------------------------------
# dev9null # dev9null
#--------------------------------------- #---------------------------------------
if(GTK2_FOUND) if(GTKn_FOUND)
set(dev9null TRUE) set(dev9null TRUE)
endif() endif()
#--------------------------------------- #---------------------------------------
@ -114,7 +116,7 @@ endif()
#--------------------------------------- #---------------------------------------
# FWnull # FWnull
#--------------------------------------- #---------------------------------------
if(GTK2_FOUND) if(GTKn_FOUND)
set(FWnull TRUE) set(FWnull TRUE)
endif() endif()
#--------------------------------------- #---------------------------------------
@ -122,7 +124,7 @@ endif()
#--------------------------------------- #---------------------------------------
# GSnull # GSnull
#--------------------------------------- #---------------------------------------
if(GTK2_FOUND AND EXTRA_PLUGINS) if(GTKn_FOUND AND EXTRA_PLUGINS)
set(GSnull TRUE) set(GSnull TRUE)
endif() endif()
#--------------------------------------- #---------------------------------------
@ -198,7 +200,7 @@ endif()
#--------------------------------------- #---------------------------------------
# PadNull # PadNull
#--------------------------------------- #---------------------------------------
if(GTK2_FOUND AND EXTRA_PLUGINS) if(GTKn_FOUND AND EXTRA_PLUGINS)
set(PadNull TRUE) set(PadNull TRUE)
endif() endif()
#--------------------------------------- #---------------------------------------
@ -208,7 +210,7 @@ endif()
#--------------------------------------- #---------------------------------------
# requires: -SDL # requires: -SDL
#--------------------------------------- #---------------------------------------
if(SDL_FOUND OR SDL2_FOUND) if(SDLn_FOUND)
set(onepad TRUE) set(onepad TRUE)
elseif(NOT EXISTS "${CMAKE_SOURCE_DIR}/plugins/onepad") elseif(NOT EXISTS "${CMAKE_SOURCE_DIR}/plugins/onepad")
set(onepad FALSE) set(onepad FALSE)
@ -222,7 +224,7 @@ endif()
#--------------------------------------- #---------------------------------------
# SPU2null # SPU2null
#--------------------------------------- #---------------------------------------
if(GTK2_FOUND AND EXTRA_PLUGINS) if(GTKn_FOUND AND EXTRA_PLUGINS)
set(SPU2null TRUE) set(SPU2null TRUE)
endif() endif()
#--------------------------------------- #---------------------------------------
@ -236,7 +238,7 @@ endif()
# -SDL # -SDL
# -common_libs # -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) set(spu2-x TRUE)
elseif(NOT EXISTS "${CMAKE_SOURCE_DIR}/plugins/spu2-x") elseif(NOT EXISTS "${CMAKE_SOURCE_DIR}/plugins/spu2-x")
set(spu2-x FALSE) set(spu2-x FALSE)
@ -273,7 +275,7 @@ endif()
#--------------------------------------- #---------------------------------------
# USBnull # USBnull
#--------------------------------------- #---------------------------------------
if(GTK2_FOUND) if(GTKn_FOUND)
set(USBnull TRUE) set(USBnull TRUE)
endif() endif()
#--------------------------------------- #---------------------------------------

View File

@ -38,13 +38,6 @@ if(CMAKE_BUILD_TYPE STREQUAL Release)
) )
endif(CMAKE_BUILD_TYPE STREQUAL Release) endif(CMAKE_BUILD_TYPE STREQUAL Release)
if (SDL2_API)
set(onepadFinalFlags
${onepadFinalFlags}
-DONEPAD_SDL2
)
endif()
# onepad sources # onepad sources
set(onepadSources set(onepadSources
controller.cpp controller.cpp

View File

@ -22,11 +22,9 @@
#ifndef __JOYSTICK_H__ #ifndef __JOYSTICK_H__
#define __JOYSTICK_H__ #define __JOYSTICK_H__
#ifdef ONEPAD_SDL2 #include <SDL.h>
#include "SDL2/SDL.h" #if SDL_MAJOR_VERSION >= 2
#include "SDL2/SDL_haptic.h" #include <SDL_haptic.h>
#else
#include "SDL/SDL.h"
#endif #endif

View File

@ -65,6 +65,7 @@ set(spu2xSources
Reverb.cpp Reverb.cpp
SndOut.cpp SndOut.cpp
SndOut_Portaudio.cpp SndOut_Portaudio.cpp
SndOut_SDL.cpp
spu2freeze.cpp spu2freeze.cpp
Spu2replay.cpp Spu2replay.cpp
spu2sys.cpp spu2sys.cpp
@ -111,32 +112,6 @@ set(spu2xLinuxHeaders
# add additional include directories # add additional include directories
include_directories(Linux) 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 set(spu2xFinalSources
${spu2xSources} ${spu2xSources}
${spu2xHeaders} ${spu2xHeaders}

View File

@ -92,10 +92,8 @@ SndOutModule* mods[]=
WaveOut, WaveOut,
#endif #endif
PortaudioOut, PortaudioOut,
#if defined(SPU2X_SDL) || defined(SPU2X_SDL2)
SDLOut,
#endif
#ifdef __linux__ #ifdef __linux__
SDLOut,
AlsaOut, AlsaOut,
#endif #endif
NULL // signals the end of our list NULL // signals the end of our list

View File

@ -672,10 +672,8 @@ extern SndOutModule* DSoundOut;
extern SndOutModule* XAudio2Out; extern SndOutModule* XAudio2Out;
#endif #endif
extern SndOutModule* PortaudioOut; extern SndOutModule* PortaudioOut;
#if defined(SPU2X_SDL) || defined(SPU2X_SDL2)
extern SndOutModule * const SDLOut;
#endif
#ifdef __linux__ #ifdef __linux__
extern SndOutModule * const SDLOut;
extern SndOutModule* AlsaOut; extern SndOutModule* AlsaOut;
#endif #endif

View File

@ -28,13 +28,11 @@
/* Using SDL2 requires other SDL dependencies in pcsx2 get upgraded as well, or the /* 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 * 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. */ * build wx without sdl support, though) and onepad at the time of writing this. */
#ifdef SPU2X_SDL2 #include <SDL.h>
#include <SDL2/SDL.h> #include <SDL_audio.h>
#include <SDL2/SDL_audio.h> #if SDL_MAJOR_VERSION >= 2
typedef StereoOut32 StereoOut_SDL; typedef StereoOut32 StereoOut_SDL;
#else #else
#include <SDL/SDL.h>
#include <SDL/SDL_audio.h>
typedef StereoOut16 StereoOut_SDL; typedef StereoOut16 StereoOut_SDL;
#endif #endif