all repos — mgba @ 22ef0977dc138d57300aa9ea2fbd8ec94c10caa3

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(BUILD_QT ON CACHE BOOL "Build Qt frontend")
 8set(EXTRA_LIB "")
 9file(GLOB ARM_SRC ${CMAKE_SOURCE_DIR}/src/arm/*.c)
10file(GLOB GBA_SRC ${CMAKE_SOURCE_DIR}/src/gba/*.c)
11file(GLOB UTIL_SRC ${CMAKE_SOURCE_DIR}/src/util/*.[cS])
12file(GLOB RENDERER_SRC ${CMAKE_SOURCE_DIR}/src/gba/renderers/video-software.c)
13include_directories(${CMAKE_SOURCE_DIR}/src/arm)
14include_directories(${CMAKE_SOURCE_DIR}/src/gba)
15include_directories(${CMAKE_SOURCE_DIR}/src/debugger)
16include_directories(${CMAKE_SOURCE_DIR}/src/util)
17
18if(WIN32)
19	add_definitions(-D_WIN32_WINNT=0x0600)
20	file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/windows/*.c)
21else()
22	add_definitions(-DUSE_PTHREADS)
23	set(OS_LIBRARY "${OS_LIBRARY};pthread")
24	file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/posix/*.c)
25endif()
26
27if(NOT BUILD_PERF)
28	find_package(SDL 1.2 REQUIRED)
29	file(GLOB PLATFORM_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/sdl-*.c)
30	set(PLATFORM_LIBRARY "${SDL_LIBRARY};${SDLMAIN_LIBRARY}")
31	include_directories(${CMAKE_SOURCE_DIR}/src/platform/sdl)
32endif()
33
34if(USE_DEBUGGER)
35	file(GLOB DEBUGGER_SRC ${CMAKE_SOURCE_DIR}/src/debugger/*.c)
36	set(DEBUGGER_LIB "edit")
37	add_definitions(-DUSE_DEBUGGER)
38else()
39	set(DEBUGGER_SRC "")
40	set(DEBUGGER_LIB "")
41endif()
42
43if(BUILD_RASPI AND BUILD_EGL)
44	set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/egl-main.c)
45	set(OPENGL_LIBRARY "-lEGL -lGLESv2 -lbcm_host")
46	set(OPENGL_INCLUDE_DIR "")
47	add_definitions(-DBUILD_RASPI)
48elseif(BUILD_BBB OR BUILD_RASPI)
49	enable_language(ASM)
50	add_definitions(-DCOLOR_16_BIT -DCOLOR_5_6_5)
51	set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/sw-main.c)
52else()
53	set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/gl-main.c)
54	find_package(OpenGL REQUIRED)
55	include_directories(${SDL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})
56endif()
57
58if(BUILD_PERF)
59	set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/perf-main.c)
60	if(UNIX AND NOT APPLE)
61		set(PLATFORM_LIB "${PLATFORM_LIB};rt")
62	endif()
63endif()
64
65add_library(${BINARY_NAME} SHARED ${ARM_SRC} ${GBA_SRC} ${DEBUGGER_SRC} ${RENDERER_SRC} ${UTIL_SRC} ${OS_SRC})
66target_link_libraries(${BINARY_NAME} m ${DEBUGGER_LIB} ${OS_LIB})
67
68add_executable(${BINARY_NAME}-bin WIN32 ${PLATFORM_SRC} ${MAIN_SRC})
69target_link_libraries(${BINARY_NAME}-bin ${BINARY_NAME} ${PLATFORM_LIBRARY} ${OPENGL_LIBRARY})
70set_target_properties(${BINARY_NAME}-bin PROPERTIES OUTPUT_NAME ${BINARY_NAME})
71
72if(BUILD_QT)
73	add_subdirectory(src/platform/qt)
74endif()