all repos — mgba @ 4da65d0f2f041e2db4874087e1e0d8da5a2d96be

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=c99")
 5set(CMAKE_C_FLAGS_RELEASE "-O3 -Wall -Wextra -std=c99")
 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_QT ON CACHE BOOL "Build Qt frontend")
 9set(BUILD_SDL ON CACHE BOOL "Build SDL frontend")
10set(BUILD_PERF ON CACHE BOOL "Build performance profiling tool")
11file(GLOB ARM_SRC ${CMAKE_SOURCE_DIR}/src/arm/*.c)
12file(GLOB GBA_SRC ${CMAKE_SOURCE_DIR}/src/gba/*.c)
13file(GLOB UTIL_SRC ${CMAKE_SOURCE_DIR}/src/util/*.[cS])
14file(GLOB VFS_SRC ${CMAKE_SOURCE_DIR}/src/util/vfs/*.c)
15file(GLOB RENDERER_SRC ${CMAKE_SOURCE_DIR}/src/gba/renderers/video-software.c)
16set(UTIL_SRC ${UTIL_SRC};${CMAKE_SOURCE_DIR}/src/platform/commandline.c)
17source_group("ARM core" FILES ${ARM_SRC})
18source_group("GBA board" FILES ${GBA_SRC} ${RENDERER_SRC})
19source_group("Utilities" FILES ${UTIL_SRC} ${VFS_SRC}})
20include_directories(${CMAKE_SOURCE_DIR}/src/arm)
21include_directories(${CMAKE_SOURCE_DIR}/src/gba)
22include_directories(${CMAKE_SOURCE_DIR}/src)
23
24add_definitions(-DBINARY_NAME="${BINARY_NAME}" -DPROJECT_NAME="${PROJECT_NAME}")
25
26include(FindPkgConfig)
27pkg_search_module(LIBZIP libzip)
28if(LIBZIP_FOUND)
29	include_directories(${LIBZIP_INCLUDE_DIRS})
30	list(APPEND DEPENDENCY_LIB ${LIBZIP_LIBRARIES})
31	add_definitions(-DENABLE_LIBZIP)
32else()
33	message(WARNING "Could not find libzip for archive support")
34endif()
35
36if(WIN32)
37	add_definitions(-D_WIN32_WINNT=0x0600)
38	set(OS_LIB "${OS_LIB};Ws2_32")
39	file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/windows/*.c)
40	source_group("Windows-specific code" FILES ${OS_SRC})
41else()
42	add_definitions(-DUSE_PTHREADS)
43	set(OS_LIB "${OS_LIB};pthread")
44	file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/posix/*.c)
45	source_group("POSIX-specific code" FILES ${OS_SRC})
46endif()
47
48if(BUILD_BBB OR BUILD_RASPI)
49	enable_language(ASM)
50	if(NOT BUILD_EGL)
51		add_definitions(-DCOLOR_16_BIT -DCOLOR_5_6_5)
52	endif()
53endif()
54
55set(DEBUGGER_SRC "${CMAKE_SOURCE_DIR}/src/debugger/debugger.c;${CMAKE_SOURCE_DIR}/src/debugger/memory-debugger.c")
56
57if(USE_CLI_DEBUGGER AND NOT WIN32)
58	# Win32 doesn't have a usable command line, nor libedit, so this is useless on Windows
59	add_definitions(-DUSE_CLI_DEBUGGER)
60	list(APPEND DEBUGGER_SRC "${CMAKE_SOURCE_DIR}/src/debugger/cli-debugger.c")
61	list(APPEND DEBUGGER_SRC "${CMAKE_SOURCE_DIR}/src/debugger/parser.c")
62	set(DEBUGGER_LIB "edit")
63else()
64	set(DEBUGGER_LIB "")
65endif()
66
67if(USE_GDB_STUB)
68	add_definitions(-DUSE_GDB_STUB)
69	set(DEBUGGER_SRC "${DEBUGGER_SRC};${CMAKE_SOURCE_DIR}/src/debugger/gdb-stub.c")
70endif()
71source_group("ARM debugger" FILES ${DEBUGGER_SRC})
72
73add_library(${BINARY_NAME} SHARED ${ARM_SRC} ${GBA_SRC} ${DEBUGGER_SRC} ${RENDERER_SRC} ${UTIL_SRC} ${VFS_SRC} ${OS_SRC})
74target_link_libraries(${BINARY_NAME} m ${DEBUGGER_LIB} ${OS_LIB} ${DEPENDENCY_LIB})
75
76if(BUILD_SDL)
77	add_definitions(-DBUILD_SDL)
78	add_subdirectory(${CMAKE_SOURCE_DIR}/src/platform/sdl ${CMAKE_BINARY_DIR}/sdl)
79endif()
80
81if(BUILD_PERF)
82	set(PERF_SRC ${CMAKE_SOURCE_DIR}/src/platform/perf-main.c)
83	if(UNIX AND NOT APPLE)
84		set(PERF_LIB "${PERF_LIB};rt")
85	endif()
86
87	add_executable(${BINARY_NAME}-perf ${PERF_SRC})
88	target_link_libraries(${BINARY_NAME}-perf ${BINARY_NAME} ${PERF_LIB})
89endif()
90
91if(BUILD_QT)
92	add_subdirectory(${CMAKE_SOURCE_DIR}/src/platform/qt ${CMAKE_BINARY_DIR}/qt)
93endif()