all repos — mgba @ f5a3fd7c7f1ad32cd326775a910a8e4a39a0f301

mGBA Game Boy Advance Emulator

CMakeLists.txt (view raw)

 1cmake_minimum_required(VERSION 2.6)
 2project(GBAc)
 3set(BINARY_NAME gbac CACHE INTERNAL "Name of output binaries")
 4set(CMAKE_C_FLAGS_DEBUG "-g -Wall -Wextra -Wno-error=type-limits --std=gnu99")
 5set(CMAKE_C_FLAGS_RELEASE "-O3 -Wall -Wextra --std=gnu99")
 6set(USE_DEBUGGER ON CACHE BOOL "Whether or not to enable the ARM debugger")
 7file(GLOB ARM_SRC ${CMAKE_SOURCE_DIR}/src/arm/*.c)
 8file(GLOB GBA_SRC ${CMAKE_SOURCE_DIR}/src/gba/*.c)
 9file(GLOB UTIL_SRC ${CMAKE_SOURCE_DIR}/src/util/*.c)
10file(GLOB RENDERER_SRC ${CMAKE_SOURCE_DIR}/src/gba/renderers/video-software.c)
11include_directories(${CMAKE_SOURCE_DIR}/src/arm)
12include_directories(${CMAKE_SOURCE_DIR}/src/gba)
13include_directories(${CMAKE_SOURCE_DIR}/src/debugger)
14include_directories(${CMAKE_SOURCE_DIR}/src/util)
15
16find_package(SDL 1.2 REQUIRED)
17file(GLOB PLATFORM_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/sdl-*.c)
18include_directories(${CMAKE_SOURCE_DIR}/src/platform/sdl)
19
20if(USE_DEBUGGER)
21	file(GLOB DEBUGGER_SRC ${CMAKE_SOURCE_DIR}/src/debugger/*.c)
22	set(DEBUGGER_LIB "edit")
23	add_definitions(-DUSE_DEBUGGER)
24else()
25	set(DEBUGGER_SRC "")
26	set(DEBUGGER_LIB "")
27endif()
28
29if(BUILD_RASPI AND BUILD_EGL)
30	set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/egl-main.c)
31	set(OPENGL_LIBRARY "-lEGL -lGLESv2 -lbcm_host")
32	set(OPENGL_INCLUDE_DIR "")
33	add_definitions(-DBUILD_RASPI)
34elseif(BUILD_BBB OR BUILD_RASPI)
35	add_definitions(-DCOLOR_16_BIT -DCOLOR_5_6_5)
36	set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/sw-main.c)
37else()
38	set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/gl-main.c)
39	find_package(OpenGL REQUIRED)
40	include_directories(${SDL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})
41endif()
42
43add_executable(${BINARY_NAME} ${ARM_SRC} ${GBA_SRC} ${DEBUGGER_SRC} ${RENDERER_SRC} ${UTIL_SRC} ${PLATFORM_SRC} ${MAIN_SRC})
44target_link_libraries(${BINARY_NAME} m pthread ${DEBUGGER_LIB} ${SDL_LIBRARY} ${OPENGL_LIBRARY})