all repos — mgba @ 12f99a33bc705b394df6fb0df65e98d0a8674f53

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} CACHE INTERNAL "")
 9		set(SDL_LIBRARY ${SDL2_LIBRARIES} CACHE INTERNAL "")
10		set(SDLMAIN_LIBRARY "" CACHE INTERNAL "")
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)
17	set(SDL_VERSION "1.2" PARENT_SCOPE)
18endif()
19
20if (NOT SDL2_FOUND AND NOT SDL_FOUND)
21	set(BUILD_SDL OFF PARENT_SCOPE)
22	return()
23endif()
24
25file(GLOB PLATFORM_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/sdl-*.c)
26set(PLATFORM_LIBRARY ${SDL_LIBRARY} ${SDLMAIN_LIBRARY})
27include_directories(${CMAKE_SOURCE_DIR}/src/platform/sdl ${SDL_INCLUDE_DIR})
28
29set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/main.c)
30
31if(BUILD_RASPI)
32	add_definitions(-DBUILD_RASPI)
33	set(EGL_MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/egl-sdl.c)
34	set(EGL_LIBRARY "-lEGL -lGLESv2 -lbcm_host")
35	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fgnu89-inline")
36	add_executable(${BINARY_NAME}-rpi ${PLATFORM_SRC} ${MAIN_SRC} ${EGL_MAIN_SRC})
37	target_link_libraries(${BINARY_NAME}-rpi ${BINARY_NAME} ${PLATFORM_LIBRARY} ${EGL_LIBRARY})
38	install(TARGETS ${BINARY_NAME}-rpi DESTINATION bin)
39endif()
40
41if(BUILD_BBB OR BUILD_RASPI OR NOT BUILD_GL)
42	list(APPEND MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/sw-sdl.c)
43else()
44	list(APPEND MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/gl-sdl.c)
45	add_definitions(-DBUILD_GL)
46	find_package(OpenGL REQUIRED)
47	include_directories(${OPENGL_INCLUDE_DIR})
48endif()
49
50add_executable(${BINARY_NAME}-sdl WIN32 ${PLATFORM_SRC} ${MAIN_SRC})
51target_link_libraries(${BINARY_NAME}-sdl ${BINARY_NAME} ${PLATFORM_LIBRARY} ${OPENGL_LIBRARY})
52set_target_properties(${BINARY_NAME}-sdl PROPERTIES OUTPUT_NAME ${BINARY_NAME})
53install(TARGETS ${BINARY_NAME}-sdl DESTINATION bin)