-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
151 lines (126 loc) · 3.53 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
cmake_minimum_required(VERSION 3.10)
project(gba_emu)
# C/C++ version
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11)
# Platform config
set(ENABLE_ASAN 0)
# set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_BUILD_TYPE "Release")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
## Common
# Platform
if (LV_USE_RPI)
message(STATUS "Platform: Raspberry Pi - GamePi20")
add_definitions(
-DLV_USE_RPI=1
-DLV_USE_SDL=0
-DTHREADED_RENDERER=1
)
# FLAGS
set(RPI_BUILD_FLAGS "-mfpu=vfp -Ofast -flto")
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} ${RPI_BUILD_FLAGS})
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${RPI_BUILD_FLAGS})
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} -flto)
# Link libs
set(RPI_LINK_LIBS wiringPi asound)
else()
message(STATUS "Platform: UNIX - SDL2")
add_definitions(
-DLV_SCREEN_HOR_RES=320
-DLV_SCREEN_VER_RES=480
-DLV_USE_SDL=1
-DTHREADED_RENDERER=0
)
add_definitions(-DUSE_SDL=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1)
find_package(SDL2 REQUIRED SDL2)
include_directories(
${SDL2_INCLUDE_DIRS}
${SDL2_INCLUDE_DIRS}/../
)
# Address Sanitizer
if (ENABLE_ASAN)
set(ASAN_FLAGS "-fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer")
add_definitions(${ASAN_FLAGS})
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} ${ASAN_FLAGS})
endif()
endif()
# LVGL config
add_definitions(
-DLV_USE_DEV_VERSION=1
)
# vba-next config
add_definitions(
-DDEBUG=0
-DFRONTEND_SUPPORTS_RGB565=1
-DTILED_RENDERING=1
-DSTATIC_LINKING=0
-DUSE_TWEAKS=1
-DUSE_FRAME_SKIP=1
-DHAVE_NEON=0
-Dretro_sleep=lv_port_sleep
-DNDEBUG
-D__LIBRETRO__
-DINLINE=inline
-DHAVE_STDINT_H
-DHAVE_INTTYPES_H
-DGBA_FRAME_SKIP="0"
)
# Include
set(VBA_NEXT_SOURCE_DIR ${PROJECT_SOURCE_DIR}/vba-next)
include_directories(
${PROJECT_SOURCE_DIR}
${VBA_NEXT_SOURCE_DIR}/src
${VBA_NEXT_SOURCE_DIR}/libretro-common/include
)
# Sources
## porting
file(GLOB PORT_SOURCES "port/*.c")
if (LV_USE_RPI)
file(GLOB PORT_RPI_SOURCES "port/rpi/*.c")
endif ()
## gba emu
file(GLOB GBA_EMU_SOURCES "gba_emu/*.c*")
## vba-next
file(GLOB VBA_NEXT_SOURCE
${VBA_NEXT_SOURCE_DIR}/src/*.c
${VBA_NEXT_SOURCE_DIR}/src/*.cpp
${VBA_NEXT_SOURCE_DIR}/libretro/libretro.cpp
${VBA_NEXT_SOURCE_DIR}/libretro-common/rthreads/rsemaphore.c
${VBA_NEXT_SOURCE_DIR}/libretro-common/rthreads/rthreads.c
${VBA_NEXT_SOURCE_DIR}/libretro-common/compat/*.c
${VBA_NEXT_SOURCE_DIR}/libretro-common/encodings/*.c
${VBA_NEXT_SOURCE_DIR}/libretro-common/file/*.c
${VBA_NEXT_SOURCE_DIR}/libretro-common/streams/*.c
${VBA_NEXT_SOURCE_DIR}/libretro-common/string/*.c
${VBA_NEXT_SOURCE_DIR}/libretro-common/time/*.c
)
## ALL SOURCES
set(SOURCES
${PORT_SOURCES}
${PORT_RPI_SOURCES}
${GBA_EMU_SOURCES}
${GBA_PORT_SOURCES}
${VBA_NEXT_SOURCE}
)
# Subdirectory
add_subdirectory(${PROJECT_SOURCE_DIR}/lvgl ${PROJECT_BINARY_DIR}/build_lvgl)
# Executable
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
add_executable(gba_emu main.c ${SOURCES} ${INCLUDES})
# Link
target_link_libraries(
gba_emu PRIVATE
lvgl
pthread
# lvgl::examples
# lvgl::demos
${RPI_LINK_LIBS}
${SDL2_LIBRARIES}
)
set_target_properties(
gba_emu
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/build"
)