all repos — mgba @ 9b150bbaa327ade253ffcc73aec015724f4a9b7d

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_DEBUGGER ON CACHE BOOL "Whether or not to enable the ARM debugger")
 7set(BUILD_QT ON CACHE BOOL "Build Qt frontend")
 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)
14source_group("ARM core" FILES ${ARM_SRC})
15source_group("GBA board" FILES ${GBA_SRC} ${RENDERER_SRC})
16source_group("Utilities" FILES ${UTIL_SRC})
17include_directories(${CMAKE_SOURCE_DIR}/src/arm)
18include_directories(${CMAKE_SOURCE_DIR}/src/gba)
19include_directories(${CMAKE_SOURCE_DIR}/src/debugger)
20include_directories(${CMAKE_SOURCE_DIR}/src/util)
21
22if(WIN32)
23	add_definitions(-D_WIN32_WINNT=0x0600)
24	file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/windows/*.c)
25	source_group("Windows-specific code" FILES ${OS_SRC})
26else()
27	add_definitions(-DUSE_PTHREADS)
28	set(OS_LIBRARY "${OS_LIBRARY};pthread")
29	file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/posix/*.c)
30	source_group("POSIX-specific code" FILES ${OS_SRC})
31endif()
32
33if(USE_DEBUGGER)
34	file(GLOB DEBUGGER_SRC ${CMAKE_SOURCE_DIR}/src/debugger/*.c)
35	source_group("ARM debugger" FILES ${DEBUGGER_SRC})
36	set(DEBUGGER_LIB "edit")
37	add_definitions(-DUSE_DEBUGGER)
38else()
39	set(DEBUGGER_SRC "")
40	set(DEBUGGER_LIB "")
41endif()
42
43add_library(${BINARY_NAME} SHARED ${ARM_SRC} ${GBA_SRC} ${DEBUGGER_SRC} ${RENDERER_SRC} ${UTIL_SRC} ${OS_SRC})
44target_link_libraries(${BINARY_NAME} m ${DEBUGGER_LIB} ${OS_LIB})
45
46if(BUILD_SDL)
47	add_subdirectory(${CMAKE_SOURCE_DIR}/src/platform/sdl ${CMAKE_BINARY_DIR}/sdl)
48endif()
49
50if(BUILD_PERF)
51	set(PERF_SRC ${CMAKE_SOURCE_DIR}/src/platform/perf-main.c)
52	if(UNIX AND NOT APPLE)
53		set(PERF_LIB "$PERF_LIB};rt")
54	endif()
55
56	add_executable(${BINARY_NAME}-perf ${PERF_SRC})
57	target_link_libraries(${BINARY_NAME}-perf ${BINARY_NAME} ${PERF_LIBRARY})
58endif()
59
60if(BUILD_QT)
61	add_subdirectory(${CMAKE_SOURCE_DIR}/src/platform/qt ${CMAKE_BINARY_DIR}/qt)
62endif()