|
1 |
| -cmake_policy(SET CMP0079 NEW) # target_link_libraries() allows use with targets in other directories. |
2 |
| - |
3 |
| -set(CMAKE_C_STANDARD 11) |
4 |
| - |
5 |
| -# Initialise the Pico SDK |
6 |
| -set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}/board) |
7 |
| -include (pico_sdk_import.cmake) |
8 |
| - |
9 |
| -set(32BLIT_PICO 1 PARENT_SCOPE) |
10 |
| - |
11 |
| -if(PICO_PLATFORM MATCHES "^rp2350") |
12 |
| - set(32BLIT_PICO_2350 1) |
13 |
| - set(32BLIT_PICO_2350 ${32BLIT_PICO_2350} PARENT_SCOPE) |
| 1 | +if(TARGET BlitHalPico) |
| 2 | + return() |
14 | 3 | endif()
|
15 | 4 |
|
16 | 5 | # prevent find_package errors in pico_add_uf2_output later
|
17 | 6 | set(PICO_SDK_VERSION_MAJOR ${PICO_SDK_VERSION_MAJOR} PARENT_SCOPE)
|
18 | 7 | set(PICO_SDK_VERSION_MINOR ${PICO_SDK_VERSION_MINOR} PARENT_SCOPE)
|
19 | 8 | set(PICO_SDK_VERSION_REVISION ${PICO_SDK_VERSION_REVISION} PARENT_SCOPE)
|
20 | 9 |
|
21 |
| -# make sure BlitEngine is built with the right exception flags |
22 |
| -target_link_libraries(BlitEngine PUBLIC pico_cxx_options pico_base_headers) |
23 |
| - |
24 |
| -# also enable function/data sectons |
25 |
| -target_compile_options(BlitEngine PRIVATE -ffunction-sections -fdata-sections) |
26 |
| - |
27 | 10 | add_subdirectory(../32blit-shared ../32blit-shared)
|
28 | 11 |
|
29 |
| - |
30 | 12 | add_library(BlitHalPico INTERFACE)
|
31 | 13 | target_sources(BlitHalPico INTERFACE
|
32 | 14 | ${CMAKE_CURRENT_LIST_DIR}/blit_launch.cpp
|
@@ -66,17 +48,6 @@ target_compile_options(BlitHalPico INTERFACE
|
66 | 48 | -Wno-ignored-qualifiers # pico-sdk generates a lot of these
|
67 | 49 | )
|
68 | 50 |
|
69 |
| -# detect board configuration |
70 |
| -include(board-config.cmake) |
71 |
| - |
72 |
| -# late SDK init |
73 |
| -# (pico_sdk_init needs to be after importing extras, which we don't know if we'll need until now) |
74 |
| -if(BLIT_REQUIRE_PICO_EXTRAS) |
75 |
| - include(pico_extras_import.cmake) |
76 |
| -endif() |
77 |
| - |
78 |
| -pico_sdk_init() |
79 |
| - |
80 | 51 | # generate PIO headers (has to be after SDK init)
|
81 | 52 | pico_generate_pio_header(BlitHalPico ${CMAKE_CURRENT_LIST_DIR}/dbi-spi.pio)
|
82 | 53 | pico_generate_pio_header(BlitHalPico ${CMAKE_CURRENT_LIST_DIR}/dbi-8bit.pio)
|
@@ -127,167 +98,5 @@ target_link_libraries(BlitHalPico INTERFACE ${BLIT_BOARD_LIBRARIES})
|
127 | 98 |
|
128 | 99 | set(BLIT_BOARD_DEFINITIONS ${BLIT_BOARD_DEFINITIONS} PARENT_SCOPE)
|
129 | 100 |
|
130 |
| -# some file paths we need later |
131 |
| -if(32BLIT_PICO_2350) |
132 |
| - set(LINKER_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/memmap_blit_2350.ld.in PARENT_SCOPE) |
133 |
| -else() |
134 |
| - set(LINKER_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/memmap_blit.ld.in PARENT_SCOPE) |
135 |
| -endif() |
136 |
| -set(STARTUP_SRC ${CMAKE_CURRENT_LIST_DIR}/startup.S ${CMAKE_CURRENT_LIST_DIR}/startup.cpp PARENT_SCOPE) |
137 |
| -set(LAUNCHERSHARED_DIR ${CMAKE_CURRENT_LIST_DIR}/../launcher-shared PARENT_SCOPE) |
138 |
| - |
139 | 101 | # for enabling stdio_usb
|
140 | 102 | set(BLIT_USB_DRIVER ${BLIT_USB_DRIVER} PARENT_SCOPE)
|
141 |
| - |
142 |
| -# functions |
143 |
| -function(blit_executable NAME) |
144 |
| - message(STATUS "Processing ${NAME}") |
145 |
| - blit_executable_args(${ARGN}) |
146 |
| - |
147 |
| - add_executable(${NAME} ${SOURCES}) |
148 |
| - target_link_libraries(${NAME} BlitEngine pico_platform_headers) |
149 |
| - |
150 |
| - if(PICO_STANDALONE_UF2) |
151 |
| - pico_enable_stdio_uart(${NAME} 1) |
152 |
| - if(NOT BLIT_USB_DRIVER STREQUAL "host") |
153 |
| - pico_enable_stdio_usb(${NAME} 1) |
154 |
| - # re-enable baud rate reset (we don't define our own tud_cdc_line_coding_cb) |
155 |
| - # we have to set all the defines to compile? (something broken with the defaults?) |
156 |
| - target_compile_definitions(${NAME} PRIVATE PICO_STDIO_USB_ENABLE_RESET_VIA_BAUD_RATE=1 PICO_STDIO_USB_RESET_MAGIC_BAUD_RATE=1200 PICO_STDIO_USB_RESET_BOOTSEL_INTERFACE_DISABLE_MASK=0) |
157 |
| - endif() |
158 |
| - |
159 |
| - # standalone .uf2 |
160 |
| - # TODO: import pico hal if standalone build |
161 |
| - if(NOT TARGET LauncherShared) |
162 |
| - add_subdirectory(${LAUNCHERSHARED_DIR} launcher-shared) |
163 |
| - endif() |
164 |
| - |
165 |
| - target_compile_definitions(${NAME} PRIVATE BLIT_PICO_STANDALONE=1 PICO_EMBED_XIP_SETUP=1) |
166 |
| - target_link_libraries(${NAME} BlitHalPico) |
167 |
| - |
168 |
| - pico_add_extra_outputs(${NAME}) |
169 |
| - |
170 |
| - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.uf2 |
171 |
| - DESTINATION bin |
172 |
| - ) |
173 |
| - elseif(PICO_BLIT) |
174 |
| - # loadable .blit |
175 |
| - set_property(TARGET ${NAME} PROPERTY BLIT_PICO_BLIT TRUE) |
176 |
| - |
177 |
| - # calculate and verify flash offset |
178 |
| - if(NOT PICO_BLIT_OFFSET_KB) |
179 |
| - if(32BLIT_PICO_2350) |
180 |
| - # if we build the file for a 4MB offset, we can use address translation |
181 |
| - set(PICO_BLIT_OFFSET_KB 4096) |
182 |
| - else() |
183 |
| - set(PICO_BLIT_OFFSET_KB 512) |
184 |
| - endif() |
185 |
| - endif() |
186 |
| - |
187 |
| - math(EXPR offset_mod "${PICO_BLIT_OFFSET_KB} % 64") |
188 |
| - if(${PICO_BLIT_OFFSET_KB} LESS 256 OR offset_mod) |
189 |
| - message(FATAL_ERROR "Blit offset should be >= 256k and a multiple of 64k") |
190 |
| - endif() |
191 |
| - |
192 |
| - math(EXPR FLASH_OFFSET_BYTES "${PICO_BLIT_OFFSET_KB} * 1024") |
193 |
| - |
194 |
| - # customise linker script |
195 |
| - configure_file(${LINKER_SCRIPT} memmap_blit.ld) |
196 |
| - set(LINKER_SCRIPT_OUT ${CMAKE_CURRENT_BINARY_DIR}/memmap_blit.ld) |
197 |
| - |
198 |
| - target_compile_definitions(${NAME} PRIVATE ${BLIT_BOARD_DEFINITIONS}) # need these for framebuffer config |
199 |
| - target_compile_options(${NAME} PRIVATE -ffunction-sections -fdata-sections) |
200 |
| - |
201 |
| - # set device id in header, these should match the BlitDevice enum |
202 |
| - if(32BLIT_PICO_2350) |
203 |
| - set_source_files_properties(${STARTUP_SRC} PROPERTIES COMPILE_DEFINITIONS DEVICE_ID=3) |
204 |
| - else() |
205 |
| - set_source_files_properties(${STARTUP_SRC} PROPERTIES COMPILE_DEFINITIONS DEVICE_ID=2) |
206 |
| - endif() |
207 |
| - |
208 |
| - # minimal pico-sdk libs |
209 |
| - target_link_libraries(${NAME} boot_picobin_headers pico_bit_ops pico_clib_interface pico_cxx_options pico_divider pico_double pico_int64_ops pico_float pico_malloc pico_mem_ops pico_runtime_headers) |
210 |
| - target_compile_definitions(${NAME} PRIVATE PICO_TIME_DEFAULT_ALARM_POOL_DISABLED) # avoid pulling timer and irq code |
211 |
| - |
212 |
| - target_link_options(${NAME} PRIVATE --specs=nosys.specs LINKER:--script=${LINKER_SCRIPT_OUT} LINKER:--gc-sections) |
213 |
| - set_property(TARGET ${NAME} APPEND PROPERTY LINK_DEPENDS ${LINKER_SCRIPT_OUT}) |
214 |
| - |
215 |
| - target_sources(${NAME} PRIVATE ${STARTUP_SRC}) |
216 |
| - |
217 |
| - pico_add_bin_output(${NAME}) |
218 |
| - pico_add_dis_output(${NAME}) |
219 |
| - |
220 |
| - set(BLIT_FILENAME $<TARGET_FILE_BASE_NAME:${NAME}>.blit) |
221 |
| - |
222 |
| - # no relocs, just copy it |
223 |
| - set(BIN_NAME "$<IF:$<BOOL:$<TARGET_PROPERTY:${NAME},OUTPUT_NAME>>,$<TARGET_PROPERTY:${NAME},OUTPUT_NAME>,$<TARGET_PROPERTY:${NAME},NAME>>.bin") |
224 |
| - add_custom_command(TARGET ${NAME} POST_BUILD |
225 |
| - VERBATIM |
226 |
| - COMMENT "Building ${NAME}.blit" |
227 |
| - COMMAND cp ${BIN_NAME} ${BLIT_FILENAME} |
228 |
| - ) |
229 |
| - |
230 |
| - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${BLIT_FILENAME} |
231 |
| - DESTINATION bin |
232 |
| - ) |
233 |
| - endif() |
234 |
| -endfunction() |
235 |
| - |
236 |
| -function(blit_metadata TARGET FILE) |
237 |
| - if(NOT IS_ABSOLUTE ${FILE}) |
238 |
| - set(FILE ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}) |
239 |
| - endif() |
240 |
| - |
241 |
| - # cause cmake to reconfigure whenever the asset list changes |
242 |
| - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${FILE}) |
243 |
| - |
244 |
| - # get the inputs/outputs for the asset tool (at configure time) |
245 |
| - execute_process( |
246 |
| - COMMAND ${32BLIT_TOOLS_EXECUTABLE} cmake --config ${FILE} --cmake ${CMAKE_CURRENT_BINARY_DIR}/metadata.cmake |
247 |
| - RESULT_VARIABLE TOOL_RESULT |
248 |
| - ) |
249 |
| - if(${TOOL_RESULT}) |
250 |
| - message(FATAL_ERROR "Reading metadata config failed!\n") |
251 |
| - endif() |
252 |
| - |
253 |
| - include(${CMAKE_CURRENT_BINARY_DIR}/metadata.cmake) |
254 |
| - |
255 |
| - get_property(PICO_BLIT TARGET ${TARGET} PROPERTY BLIT_PICO_BLIT) |
256 |
| - |
257 |
| - if(NOT PICO_BLIT) |
258 |
| - # create metadata/binary info source at build time |
259 |
| - set(METADATA_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_binary_info.cpp") |
260 |
| - |
261 |
| - add_custom_command( |
262 |
| - OUTPUT ${METADATA_SOURCE} |
263 |
| - COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${32BLIT_TOOLS_EXECUTABLE} metadata --force --config ${FILE} --pico-bi ${METADATA_SOURCE} |
264 |
| - DEPENDS ${FILE} |
265 |
| - VERBATIM |
266 |
| - ) |
267 |
| - |
268 |
| - # add the generated source |
269 |
| - target_sources(${TARGET} PRIVATE ${METADATA_SOURCE}) |
270 |
| - |
271 |
| - # avoid the fallback to target name |
272 |
| - target_compile_definitions(${TARGET} PRIVATE PICO_NO_BI_PROGRAM_NAME=1) |
273 |
| - else() |
274 |
| - # real .blit metadata |
275 |
| - set(BLIT_FILENAME $<TARGET_FILE_BASE_NAME:${TARGET}>.blit) |
276 |
| - |
277 |
| - add_custom_command( |
278 |
| - TARGET ${TARGET} POST_BUILD |
279 |
| - COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${32BLIT_TOOLS_EXECUTABLE} metadata --config ${FILE} --file ${CMAKE_CURRENT_BINARY_DIR}/${BLIT_FILENAME} |
280 |
| - VERBATIM |
281 |
| - ) |
282 |
| - |
283 |
| - # force relink on change so that the post-build commands are rerun |
284 |
| - set_property(TARGET ${TARGET} APPEND PROPERTY LINK_DEPENDS ${FILE} ${METADATA_DEPENDS}) |
285 |
| - endif() |
286 |
| - |
287 |
| -endfunction() |
288 |
| - |
289 |
| -# use this as an indicator that we're building the SDK |
290 |
| -# (until we have a proper split to not build the loader in an out-of-tree build) |
291 |
| -if(${PROJECT_NAME} STREQUAL "32blit") |
292 |
| - add_subdirectory(loader) |
293 |
| -endif() |
0 commit comments