all repos — mgba @ ec4eb253e5d940429195c9525018fb42d9c8e71a

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