-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
172 lines (135 loc) · 4.45 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
cmake_minimum_required(VERSION 3.13)
include(pico_sdk_import.cmake)
project(watara C CXX ASM)
SET(BUILD_NAME "${PROJECT_NAME}")
option(I2S "Enable I2S sound" OFF)
option(I2S_CS4334 "Enable I2S CS4334 sound" OFF)
option(VGA "Enable VGA" OFF)
option(TFT "Enable TFT display" OFF)
option(ILI9341 "Enable TFT ILI9341 display" OFF)
option(HDMI "Enable HDMI display" OFF)
option(TV "Enable TV composite output" OFF)
option(SOFTTV "Enable TV soft composite output" OFF)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
#add_compile_options(-flto)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -funroll-loops -ffast-math -feliminate-unused-debug-types -ffunction-sections -fdata-sections -Ofast")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funroll-loops -ffast-math -feliminate-unused-debug-types -ffunction-sections -fdata-sections -Ofast")
set(OUTPUT_DIR "${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${OUTPUT_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${OUTPUT_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${OUTPUT_DIR}")
pico_sdk_init()
add_subdirectory(drivers/audio)
add_subdirectory(drivers/ps2kbd)
add_subdirectory(drivers/nespad)
add_subdirectory(drivers/fatfs)
add_subdirectory(drivers/sdcard)
add_subdirectory(drivers/vga-nextgen)
add_subdirectory(drivers/st7789)
add_subdirectory(drivers/hdmi)
add_subdirectory(drivers/tv)
add_subdirectory(drivers/tv-software)
add_subdirectory(drivers/graphics)
# INCLUDE FILES THAT SHOULD BE COMPILED:
file(GLOB_RECURSE SRC "src/*.cpp" "src/*.c")
message(STATUS "Add source files:")
foreach (SRC_FILE IN LISTS SRC)
message(STATUS "${SRC_FILE}")
endforeach ()
message(STATUS "")
add_executable(${PROJECT_NAME} ${SRC})
pico_define_boot_stage2(slower_boot2 ${PICO_DEFAULT_BOOT_STAGE2_FILE})
target_compile_definitions(slower_boot2 PRIVATE PICO_FLASH_SPI_CLKDIV=4)
pico_set_boot_stage2(${PROJECT_NAME} slower_boot2)
set(FAMILY rp2040)
set(BOARD pico_sdk)
pico_set_program_name(watara "Watara Supervision emulator by xrip for MURMULATOR devboard")
pico_set_program_version(watara "develop")
target_include_directories(${PROJECT_NAME} PRIVATE src)
IF(TFT)
target_link_libraries(${PROJECT_NAME} PRIVATE st7789)
target_compile_definitions(${PROJECT_NAME} PRIVATE TFT)
SET(BUILD_NAME "${BUILD_NAME}-TFT")
IF(ILI9341)
SET(BUILD_NAME "${BUILD_NAME}-ILI9341")
target_compile_definitions(${PROJECT_NAME} PRIVATE ILI9341)
ELSE()
SET(BUILD_NAME "${BUILD_NAME}-ST7789")
ENDIF()
ELSEIF(HDMI)
target_link_libraries(${PROJECT_NAME} PRIVATE hdmi)
target_compile_definitions(${PROJECT_NAME} PRIVATE HDMI)
SET(BUILD_NAME "${BUILD_NAME}-HDMI")
ELSEIF(TV)
target_compile_definitions(${PROJECT_NAME} PRIVATE TV)
target_link_libraries(${PROJECT_NAME} PRIVATE tv)
SET(BUILD_NAME "${BUILD_NAME}-TV")
ELSEIF(SOFTTV)
target_compile_definitions(${PROJECT_NAME} PRIVATE SOFTTV)
target_link_libraries(${PROJECT_NAME} PRIVATE tv-software)
SET(BUILD_NAME "${BUILD_NAME}-TV-SOFT")
ELSE()
target_compile_definitions(${PROJECT_NAME} PRIVATE VGA)
target_link_libraries(${PROJECT_NAME} PRIVATE vga-nextgen)
SET(BUILD_NAME "${BUILD_NAME}-VGA")
ENDIF()
IF(NOT I2S)
target_compile_definitions(${PROJECT_NAME} PRIVATE AUDIO_PWM_PIN=26)
ELSEIF(I2S_CS4334)
target_compile_definitions(${PROJECT_NAME} PRIVATE I2S_CS4334)
SET(BUILD_NAME "${BUILD_NAME}-I2S-CS4334")
ELSE()
SET(BUILD_NAME "${BUILD_NAME}-I2S-TDA1387")
ENDIF()
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "${BUILD_NAME}")
target_link_libraries(${PROJECT_NAME} PRIVATE
graphics
audio
nespad
sdcard
ps2kbd
fatfs
pico_runtime
pico_stdlib
pico_multicore
hardware_dma
hardware_pio
hardware_i2c
hardware_interp
hardware_timer
hardware_clocks
hardware_pwm
hardware_flash
tinyusb_host tinyusb_board
)
target_compile_definitions(${PROJECT_NAME} PRIVATE
PICO_FLASH_SIZE_BYTES=16777216
# SDCARD
SDCARD_PIN_SPI0_CS=5
SDCARD_PIN_SPI0_SCK=2
SDCARD_PIN_SPI0_MOSI=3
SDCARD_PIN_SPI0_MISO=4
# PS2KBD
USE_PS2_KBD
PS2KBD_GPIO_FIRST=0
# NES Gamepad
USE_NESPAD
NES_GPIO_CLK=14
NES_GPIO_DATA=16
NES_GPIO_LAT=15
# VGA 8 pins starts from pin:
VGA_BASE_PIN=6
# HDMI 8 pins starts from pin:
HDMI_BASE_PIN=6
# TFT
TFT_CS_PIN=6
TFT_RST_PIN=8
TFT_LED_PIN=9
TFT_DC_PIN=10
TFT_DATA_PIN=12
TFT_CLK_PIN=13
SMS_SINGLE_FILE=1
)
target_link_options(${PROJECT_NAME} PRIVATE -Xlinker --print-memory-usage --data-sections --function-sections)
pico_add_extra_outputs(${PROJECT_NAME})