all repos — mgba @ 3837213f941a150bc7a3c26c9e38b75f4ef12952

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")
 7set(EXTRA_LIB "")
 8file(GLOB ARM_SRC ${CMAKE_SOURCE_DIR}/src/arm/*.c)
 9file(GLOB GBA_SRC ${CMAKE_SOURCE_DIR}/src/gba/*.c)
10file(GLOB UTIL_SRC ${CMAKE_SOURCE_DIR}/src/util/*.[cS])
11file(GLOB RENDERER_SRC ${CMAKE_SOURCE_DIR}/src/gba/renderers/video-software.c)
12include_directories(${CMAKE_SOURCE_DIR}/src/arm)
13include_directories(${CMAKE_SOURCE_DIR}/src/gba)
14include_directories(${CMAKE_SOURCE_DIR}/src/debugger)
15include_directories(${CMAKE_SOURCE_DIR}/src/util)
16
17find_package(SDL 1.2 REQUIRED)
18file(GLOB PLATFORM_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/sdl-*.c)
19if(WIN32)
20	add_definitions(-D_WIN32_WINNT=0x0600)
21	file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/windows/*.c)
22else()
23	add_definitions(-DUSE_PTHREADS)
24	file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/posix/*.c)
25endif()
26include_directories(${CMAKE_SOURCE_DIR}/src/platform/sdl)
27
28if(USE_DEBUGGER)
29	file(GLOB DEBUGGER_SRC ${CMAKE_SOURCE_DIR}/src/debugger/*.c)
30	set(DEBUGGER_LIB "edit")
31	add_definitions(-DUSE_DEBUGGER)
32else()
33	set(DEBUGGER_SRC "")
34	set(DEBUGGER_LIB "")
35endif()
36
37if(BUILD_RASPI AND BUILD_EGL)
38	set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/egl-main.c)
39	set(OPENGL_LIBRARY "-lEGL -lGLESv2 -lbcm_host")
40	set(OPENGL_INCLUDE_DIR "")
41	add_definitions(-DBUILD_RASPI)
42elseif(BUILD_BBB OR BUILD_RASPI)
43	enable_language(ASM)
44	add_definitions(-DCOLOR_16_BIT -DCOLOR_5_6_5)
45	set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/sw-main.c)
46else()
47	set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/gl-main.c)
48	find_package(OpenGL REQUIRED)
49	include_directories(${SDL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})
50endif()
51
52if(BUILD_PERF)
53	set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/perf-main.c)
54	set(EXTRA_LIB ${EXTRA_LIB} rt)
55endif()
56
57add_executable(${BINARY_NAME} WIN32 ${ARM_SRC} ${GBA_SRC} ${DEBUGGER_SRC} ${RENDERER_SRC} ${UTIL_SRC} ${PLATFORM_SRC} ${OS_SRC} ${MAIN_SRC})
58target_link_libraries(${BINARY_NAME} m ${DEBUGGER_LIB} ${SDL_LIBRARY} ${SDLMAIN_LIBRARY} ${OPENGL_LIBRARY} ${EXTRA_LIB})