cmake: better support of SDL2

Description: Building with SDL2_API=TRUE is incomplete
 SDL_FOUND does not imply SDL2_FOUND
 Use check_libs for detection
 Only include ${SDL_INCLUDE_DIR} when needed
 Use SDL2_LIBRARIES
Author: Miguel A. Colón Vélez

Gregory: add back SDL_BUILDING_LIBRARY
This commit is contained in:
Gregory Hainaut 2014-12-07 12:19:14 +01:00
parent 16284d0a59
commit c945aead54
5 changed files with 18 additions and 13 deletions

View File

@ -32,8 +32,6 @@ option(BUILD_REPLAY_LOADERS "Build GS replayer to ease testing (developer option
option(PACKAGE_MODE "Use this option to ease packaging of PCSX2 (developer/distribution option)")
option(XDG_STD "Use XDG standard path instead of the standard PCSX2 path")
option(EXTRA_PLUGINS "Build various 'extra' plugins")
# FIXME do a proper detection
set(SDL2_LIBRARY "-lSDL2")
option(SDL2_API "Use SDL2 on spu2x and onepad")
option(WX28_API "Force wxWidget 2.8 lib")

View File

@ -14,9 +14,6 @@ find_package(Gettext) # translation tool
find_package(Git)
find_package(JPEG)
find_package(OpenGL)
# Tell cmake that we use SDL as a library and not as an application
set(SDL_BUILDING_LIBRARY TRUE)
find_package(SDL)
# The requirement of wxWidgets is checked in SelectPcsx2Plugins module
# Does not require the module (allow to compile non-wx plugins)
# Force the unicode build (the variable is only supported on cmake 2.8.3 and above)
@ -45,6 +42,16 @@ 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
set(SDL_BUILDING_LIBRARY TRUE)
if(SDL2_API)
check_lib(SDL2 SDL2 SDL.h)
else()
# Tell cmake that we use SDL as a library and not as an application
set(SDL_BUILDING_LIBRARY TRUE)
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...
@ -93,7 +100,7 @@ if(OPENGL_FOUND)
include_directories(${OPENGL_INCLUDE_DIR})
endif()
if(SDL_FOUND)
if(SDL_FOUND AND NOT SDL2_API)
include_directories(${SDL_INCLUDE_DIR})
endif()

View File

@ -6,8 +6,8 @@ set(msg_dep_pcsx2 "check these libraries -> wxWidgets (>=2.8.10), gtk2 (>=
set(msg_dep_cdvdiso "check these libraries -> bzip2 (>=1.0.5), gtk2 (>=2.16)")
set(msg_dep_zerogs "check these libraries -> glew (>=1.6), opengl, X11, nvidia-cg-toolkit (>=2.1)")
set(msg_dep_gsdx "check these libraries -> opengl, egl, X11")
set(msg_dep_onepad "check these libraries -> sdl (==1.2)")
set(msg_dep_spu2x "check these libraries -> soundtouch (>=1.5), alsa, portaudio (>=1.9), sdl (==1.2) pcsx2 common libs")
set(msg_dep_onepad "check these libraries -> sdl (>=1.2)")
set(msg_dep_spu2x "check these libraries -> soundtouch (>=1.5), alsa, portaudio (>=1.9), sdl (>=1.2) pcsx2 common libs")
set(msg_dep_zerospu2 "check these libraries -> soundtouch (>=1.5), alsa")
if(GLSL_API)
set(msg_dep_zzogl "check these libraries -> glew (>=1.6), jpeg (>=6.2), opengl, X11, pcsx2 common libs")
@ -208,7 +208,7 @@ endif()
#---------------------------------------
# requires: -SDL
#---------------------------------------
if(SDL_FOUND)
if(SDL_FOUND OR SDL2_FOUND)
set(onepad TRUE)
elseif(NOT EXISTS "${CMAKE_SOURCE_DIR}/plugins/onepad")
set(onepad FALSE)
@ -236,7 +236,7 @@ endif()
# -SDL
# -common_libs
#---------------------------------------
if(ALSA_FOUND AND PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND AND SDL_FOUND AND common_libs)
if(ALSA_FOUND AND PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND AND (SDL_FOUND OR SDL2_FOUND) AND common_libs)
set(spu2-x TRUE)
elseif(NOT EXISTS "${CMAKE_SOURCE_DIR}/plugins/spu2-x")
set(spu2-x FALSE)

View File

@ -82,7 +82,7 @@ set(onepadWindowsHeaders
if (SDL2_API)
set(onepadFinalLibs
${SDL2_LIBRARY}
${SDL2_LIBRARIES}
)
else()
set(onepadFinalLibs

View File

@ -122,7 +122,7 @@ include_directories(Linux)
# endif(GCC_VERSION VERSION_GREATER 4.7)
# endif()
if(SDL_FOUND)
if(SDL_FOUND OR SDL2_FOUND)
list(APPEND spu2xSources SndOut_SDL.cpp)
if (SDL2_API)
set(spu2xFinalFlags
@ -155,7 +155,7 @@ set(spu2xFinalLibs
if (SDL2_API)
set(spu2xFinalLibs
${spu2xFinalLibs}
${SDL2_LIBRARY}
${SDL2_LIBRARIES}
)
else()
set(spu2xFinalLibs