all repos — mgba @ f1b4e7039f0c61699788f1ef95fcd305a61d649d

mGBA Game Boy Advance Emulator

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	endif()
12endif()
13
14if(SDL_VERSION EQUAL "1.2" OR NOT SDL2_FOUND)
15	find_package(SDL 1.2 REQUIRED)
16endif()
17
18file(GLOB PLATFORM_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/sdl-*.c)
19set(PLATFORM_LIBRARY "${SDL_LIBRARY};${SDLMAIN_LIBRARY}")
20include_directories(${CMAKE_SOURCE_DIR}/src/platform/sdl ${SDL_INCLUDE_DIR})
21
22if(BUILD_RASPI)
23	add_definitions(-DBUILD_RASPI)
24	set(EGL_MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/egl-main.c)
25	set(EGL_LIBRARY "-lEGL -lGLESv2 -lbcm_host")
26	add_executable(${BINARY_NAME}-rpi ${PLATFORM_SRC} ${EGL_MAIN_SRC})
27	target_link_libraries(${BINARY_NAME}-rpi ${BINARY_NAME} ${PLATFORM_LIBRARY} ${EGL_LIBRARY})
28endif()
29
30if(BUILD_BBB OR BUILD_RASPI OR NOT BUILD_GL)
31	set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/sw-main.c)
32else()
33	set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/gl-main.c)
34	find_package(OpenGL REQUIRED)
35	include_directories(${OPENGL_INCLUDE_DIR})
36endif()
37
38add_executable(${BINARY_NAME}-sdl WIN32 ${PLATFORM_SRC} ${MAIN_SRC})
39target_link_libraries(${BINARY_NAME}-sdl ${BINARY_NAME} ${PLATFORM_LIBRARY} ${OPENGL_LIBRARY})
40set_target_properties(${BINARY_NAME}-sdl PROPERTIES OUTPUT_NAME ${BINARY_NAME})