all repos — mgba @ 8f151ec90fac7f3ff1e17d055b052f8e4bf11eba

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 --std=gnu99")
 5set(CMAKE_C_FLAGS_RELEASE "-O3 -Wall -Wextra --std=gnu99")
 6set(USE_CLI_DEBUGGER ON CACHE BOOL "Whether or not to enable the CLI-mode ARM debugger")
 7set(USE_GDB_STUB ON CACHE BOOL "Whether or not to enable the GDB stub ARM debugger")
 8set(BUILD_SDL ON CACHE BOOL "Build SDL frontend")
 9set(BUILD_PERF ON CACHE BOOL "Build performance profiling tool")
10file(GLOB ARM_SRC ${CMAKE_SOURCE_DIR}/src/arm/*.c)
11file(GLOB GBA_SRC ${CMAKE_SOURCE_DIR}/src/gba/*.c)
12file(GLOB UTIL_SRC ${CMAKE_SOURCE_DIR}/src/util/*.[cS])
13file(GLOB RENDERER_SRC ${CMAKE_SOURCE_DIR}/src/gba/renderers/video-software.c)
14set(UTIL_SRC ${UTIL_SRC};${CMAKE_SOURCE_DIR}/src/platform/commandline.c)
15source_group("ARM core" FILES ${ARM_SRC})
16source_group("GBA board" FILES ${GBA_SRC} ${RENDERER_SRC})
17source_group("Utilities" FILES ${UTIL_SRC})
18include_directories(${CMAKE_SOURCE_DIR}/src/arm)
19include_directories(${CMAKE_SOURCE_DIR}/src/gba)
20include_directories(${CMAKE_SOURCE_DIR}/src)
21
22if(WIN32)
23	add_definitions(-D_WIN32_WINNT=0x0600)
24	set(OS_LIB "${OS_LIB};Ws2_32")
25	file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/windows/*.c)
26	source_group("Windows-specific code" FILES ${OS_SRC})
27else()
28	add_definitions(-DUSE_PTHREADS)
29	set(OS_LIB "${OS_LIB};pthread")
30	file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/posix/*.c)
31	source_group("POSIX-specific code" FILES ${OS_SRC})
32endif()
33
34if(BUILD_BBB OR BUILD_RASPI)
35	enable_language(ASM)
36	if(NOT BUILD_EGL)
37		add_definitions(-DCOLOR_16_BIT -DCOLOR_5_6_5)
38	endif()
39endif()
40
41set(DEBUGGER_SRC "${CMAKE_SOURCE_DIR}/src/debugger/debugger.c;${CMAKE_SOURCE_DIR}/src/debugger/memory-debugger.c")
42
43if(USE_CLI_DEBUGGER)
44	add_definitions(-DUSE_CLI_DEBUGGER)
45	set(DEBUGGER_SRC "${DEBUGGER_SRC};${CMAKE_SOURCE_DIR}/src/debugger/cli-debugger.c")
46	set(DEBUGGER_LIB "edit")
47else()
48	set(DEBUGGER_LIB "")
49endif()
50
51if(USE_GDB_STUB)
52	add_definitions(-DUSE_GDB_STUB)
53	set(DEBUGGER_SRC "${DEBUGGER_SRC};${CMAKE_SOURCE_DIR}/src/debugger/gdb-stub.c")
54endif()
55source_group("ARM debugger" FILES ${DEBUGGER_SRC})
56
57add_library(${BINARY_NAME} SHARED ${ARM_SRC} ${GBA_SRC} ${DEBUGGER_SRC} ${RENDERER_SRC} ${UTIL_SRC} ${OS_SRC})
58target_link_libraries(${BINARY_NAME} m ${DEBUGGER_LIB} ${OS_LIB})
59
60if(BUILD_SDL)
61	add_subdirectory(${CMAKE_SOURCE_DIR}/src/platform/sdl ${CMAKE_BINARY_DIR}/sdl)
62endif()
63
64if(BUILD_PERF)
65	set(PERF_SRC ${CMAKE_SOURCE_DIR}/src/platform/perf-main.c)
66	if(UNIX AND NOT APPLE)
67		set(PERF_LIB "${PERF_LIB};rt")
68	endif()
69
70	add_executable(${BINARY_NAME}-perf ${PERF_SRC})
71	target_link_libraries(${BINARY_NAME}-perf ${BINARY_NAME} ${PERF_LIB})
72endif()