all repos — mgba @ 2b3631dc91ec424429d4dc3259c8b8f81575bf09

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