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(EXTRA_LIB "")
8file(GLOB ARM_SRC ${CMAKE_SOURCE_DIR}/src/arm/*.c)
9file(GLOB GBA_SRC ${CMAKE_SOURCE_DIR}/src/gba/*.c)
10file(GLOB UTIL_SRC ${CMAKE_SOURCE_DIR}/src/util/*.[cS])
11file(GLOB RENDERER_SRC ${CMAKE_SOURCE_DIR}/src/gba/renderers/video-software.c)
12include_directories(${CMAKE_SOURCE_DIR}/src/arm)
13include_directories(${CMAKE_SOURCE_DIR}/src/gba)
14include_directories(${CMAKE_SOURCE_DIR}/src/debugger)
15include_directories(${CMAKE_SOURCE_DIR}/src/util)
16
17if(WIN32)
18 add_definitions(-D_WIN32_WINNT=0x0600)
19 file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/windows/*.c)
20else()
21 add_definitions(-DUSE_PTHREADS)
22 set(PLATFORM_LIBRARY "${PLATFORM_LIBRARY};pthread")
23 file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/posix/*.c)
24endif()
25
26if(NOT BUILD_PERF)
27 find_package(SDL 1.2 REQUIRED)
28 file(GLOB PLATFORM_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/sdl-*.c)
29 set(PLATFORM_LIBRARY "${SDL_LIBRARY};${SDLMAIN_LIBRARY}")
30 include_directories(${CMAKE_SOURCE_DIR}/src/platform/sdl)
31endif()
32
33if(USE_DEBUGGER)
34 file(GLOB DEBUGGER_SRC ${CMAKE_SOURCE_DIR}/src/debugger/*.c)
35 set(DEBUGGER_LIB "edit")
36 add_definitions(-DUSE_DEBUGGER)
37else()
38 set(DEBUGGER_SRC "")
39 set(DEBUGGER_LIB "")
40endif()
41
42if(BUILD_RASPI AND BUILD_EGL)
43 set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/egl-main.c)
44 set(OPENGL_LIBRARY "-lEGL -lGLESv2 -lbcm_host")
45 set(OPENGL_INCLUDE_DIR "")
46 add_definitions(-DBUILD_RASPI)
47elseif(BUILD_BBB OR BUILD_RASPI)
48 enable_language(ASM)
49 add_definitions(-DCOLOR_16_BIT -DCOLOR_5_6_5)
50 set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/sw-main.c)
51else()
52 set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/sdl/gl-main.c)
53 find_package(OpenGL REQUIRED)
54 include_directories(${SDL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})
55endif()
56
57if(BUILD_PERF)
58 set(MAIN_SRC ${CMAKE_SOURCE_DIR}/src/platform/perf-main.c)
59 if(UNIX AND NOT APPLE)
60 set(EXTRA_LIB ${EXTRA_LIB} rt)
61 endif()
62endif()
63
64add_library(${BINARY_NAME} SHARED ${ARM_SRC} ${GBA_SRC} ${DEBUGGER_SRC} ${RENDERER_SRC} ${UTIL_SRC} ${PLATFORM_SRC} ${OS_SRC})
65target_link_libraries(${BINARY_NAME} m ${DEBUGGER_LIB} ${PLATFORM_LIBRARY} ${OPENGL_LIBRARY} ${EXTRA_LIB})
66
67add_executable(${BINARY_NAME}-bin WIN32 ${MAIN_SRC})
68target_link_libraries(${BINARY_NAME}-bin ${BINARY_NAME})
69set_target_properties(${BINARY_NAME}-bin PROPERTIES OUTPUT_NAME ${BINARY_NAME})