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_SDL ON CACHE BOOL "Build SDL frontend")
8set(BUILD_PERF ON CACHE BOOL "Build performance profiling tool")
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(USE_DEBUGGER)
28 file(GLOB DEBUGGER_SRC ${CMAKE_SOURCE_DIR}/src/debugger/*.c)
29 set(DEBUGGER_LIB "edit")
30 add_definitions(-DUSE_DEBUGGER)
31else()
32 set(DEBUGGER_SRC "")
33 set(DEBUGGER_LIB "")
34endif()
35
36add_library(${BINARY_NAME} SHARED ${ARM_SRC} ${GBA_SRC} ${DEBUGGER_SRC} ${RENDERER_SRC} ${UTIL_SRC} ${OS_SRC})
37target_link_libraries(${BINARY_NAME} m ${DEBUGGER_LIB} ${OS_LIB})
38
39if(BUILD_SDL)
40 add_subdirectory(src/platform/sdl)
41endif()
42
43if(BUILD_PERF)
44 set(PERF_SRC ${CMAKE_SOURCE_DIR}/src/platform/perf-main.c)
45 if(UNIX AND NOT APPLE)
46 set(PERF_LIB "$PERF_LIB};rt")
47 endif()
48
49 add_executable(${BINARY_NAME}-perf ${PERF_SRC})
50 target_link_libraries(${BINARY_NAME}-perf ${BINARY_NAME} ${PERF_LIBRARY})
51endif()