src/platform/sdl/CMakeLists.txt (view raw)
1set(SDL_VERSION "2" CACHE STRING "Version of SDL to use (1.2 or 2)")
2set(BUILD_GL ON CACHE STRING "Build with OpenGL")
3
4if (SDL_VERSION EQUAL "2")
5 include(FindPkgConfig)
6 pkg_search_module(SDL2 sdl2)
7 if (SDL2_FOUND)
8 set(SDL_INCLUDE_DIR ${SDL2_INCLUDE_DIRS})
9 set(SDL_LIBRARY ${SDL2_LIBRARIES})
10 set(SDLMAIN_LIBRARY "")
11 link_directories(${SDL2_LIBDIR})
12 endif()
13endif()
14
15if(SDL_VERSION EQUAL "1.2" OR NOT SDL2_FOUND)
16 find_package(SDL 1.2)
17endif()
18
19if (NOT SDL2_FOUND AND NOT SDL_FOUND)
20 set(BUILD_SDL OFF)
21 return()
22endif()
23
24file(GLOB PLATFORM_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/sdl-*.c)
25set(PLATFORM_LIBRARY ${SDL_LIBRARY} ${SDLMAIN_LIBRARY})
26include_directories(${CMAKE_SOURCE_DIR}/src/platform/sdl ${SDL_INCLUDE_DIR})
27
28if(BUILD_RASPI)
29 add_definitions(-DBUILD_RASPI)
30 set(EGL_MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/egl-main.c)
31 set(EGL_LIBRARY "-lEGL -lGLESv2 -lbcm_host")
32 add_executable(${BINARY_NAME}-rpi ${PLATFORM_SRC} ${EGL_MAIN_SRC})
33 target_link_libraries(${BINARY_NAME}-rpi ${BINARY_NAME} ${PLATFORM_LIBRARY} ${EGL_LIBRARY})
34 install(TARGETS ${BINARY_NAME}-rpi DESTINATION bin)
35endif()
36
37if(BUILD_BBB OR BUILD_RASPI OR NOT BUILD_GL)
38 set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/sw-main.c)
39else()
40 set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/gl-main.c)
41 find_package(OpenGL REQUIRED)
42 include_directories(${OPENGL_INCLUDE_DIR})
43endif()
44
45add_executable(${BINARY_NAME}-sdl WIN32 ${PLATFORM_SRC} ${MAIN_SRC})
46target_link_libraries(${BINARY_NAME}-sdl ${BINARY_NAME} ${PLATFORM_LIBRARY} ${OPENGL_LIBRARY})
47set_target_properties(${BINARY_NAME}-sdl PROPERTIES OUTPUT_NAME ${BINARY_NAME})
48install(TARGETS ${BINARY_NAME}-sdl DESTINATION bin)