Fixed bug 2683 - Raspberry PI support using CMake

Tobias Himmer

this patch adds a check to the CMake build script to detect whether the VideoCore API is available.
If it is found, it enables SDL_VIDEO_DRIVER_RPI and will also add the needed include/library directory flags to CMAKE_C_FLAGS so the subsequent check for GLES succeeds in picking up the headers.

Seems to work fine on Raspbian.
main
Sam Lantinga 2014-08-16 23:28:40 -07:00
parent 8272ed1819
commit 984d0fc40b
3 changed files with 33 additions and 0 deletions

View File

@ -237,6 +237,7 @@ set_option(INPUT_TSLIB "Use the Touchscreen library for input" ${UNIX_SY
set_option(VIDEO_X11 "Use X11 video driver" ${UNIX_SYS})
set_option(VIDEO_WAYLAND "Use Wayland video driver" ${UNIX_SYS})
set_option(VIDEO_MIR "Use Mir video driver" ${UNIX_SYS})
set_option(VIDEO_RPI "Use Raspberry Pi video driver" ${UNIX_SYS})
dep_option(X11_SHARED "Dynamically load X11 support" ON "VIDEO_X11" OFF)
set(SDL_X11_OPTIONS Xcursor Xinerama XInput Xrandr Xscrnsaver XShape Xvm)
foreach(_SUB ${SDL_X11_OPTIONS})
@ -658,6 +659,8 @@ if(UNIX AND NOT APPLE)
endif()
if(SDL_VIDEO)
# Need to check for Raspberry PI first and add platform specific compiler flags, otherwise the test for GLES fails!
CheckRPI()
CheckX11()
CheckMir()
CheckDirectFB()

View File

@ -917,3 +917,32 @@ macro(CheckUSBHID)
set(CMAKE_REQUIRED_FLAGS)
endif(HAVE_USBHID)
endmacro(CheckUSBHID)
# Requires:
# - n/a
macro(CheckRPI)
if(VIDEO_RPI)
set(VIDEO_RPI_INCLUDE_DIRS "/opt/vc/include" "/opt/vc/include/interface/vcos/pthreads" "/opt/vc/include/interface/vmcs_host/linux/" )
set(VIDEO_RPI_LIBRARY_DIRS "/opt/vc/lib" )
set(VIDEO_RPI_LIBS bcm_host )
listtostr(VIDEO_RPI_INCLUDE_DIRS VIDEO_RPI_INCLUDE_FLAGS "-I")
listtostr(VIDEO_RPI_LIBRARY_DIRS VIDEO_RPI_LIBRARY_FLAGS "-L")
set(CMAKE_REQUIRED_FLAGS "${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
set(CMAKE_REQUIRED_LIBRARIES "${VIDEO_RPI_LIBS}")
check_c_source_compiles("
#include <bcm_host.h>
int main(int argc, char **argv) {}" HAVE_VIDEO_RPI)
set(CMAKE_REQUIRED_FLAGS)
set(CMAKE_REQUIRED_LIBRARIES)
if(SDL_VIDEO AND HAVE_VIDEO_RPI)
set(HAVE_SDL_VIDEO TRUE)
set(SDL_VIDEO_DRIVER_RPI 1)
file(GLOB VIDEO_RPI_SOURCES ${SDL2_SOURCE_DIR}/src/video/raspberry/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${VIDEO_RPI_SOURCES})
list(APPEND EXTRA_LIBS ${VIDEO_RPI_LIBS})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
endif(SDL_VIDEO AND HAVE_VIDEO_RPI)
endif(VIDEO_RPI)
endmacro(CheckRPI)

View File

@ -264,6 +264,7 @@
#cmakedefine SDL_VIDEO_DRIVER_DUMMY @SDL_VIDEO_DRIVER_DUMMY@
#cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND @SDL_VIDEO_DRIVER_WAYLAND@
#cmakedefine SDL_VIDEO_DRIVER_RPI @SDL_VIDEO_DRIVER_RPI@
#if 0
/* !!! FIXME: in configure script version, missing here: */