|
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
|
@@ -60,17 +42,6 @@ target_compile_options(BlitHalPico INTERFACE
|
60 | 42 | -Wno-ignored-qualifiers # pico-sdk generates a lot of these
|
61 | 43 | )
|
62 | 44 |
|
63 |
| -# detect board configuration |
64 |
| -include(board-config.cmake) |
65 |
| - |
66 |
| -# late SDK init |
67 |
| -# (pico_sdk_init needs to be after importing extras, which we don't know if we'll need until now) |
68 |
| -if(BLIT_REQUIRE_PICO_EXTRAS) |
69 |
| - include(pico_extras_import.cmake) |
70 |
| -endif() |
71 |
| - |
72 |
| -pico_sdk_init() |
73 |
| - |
74 | 45 | # generate PIO headers (has to be after SDK init)
|
75 | 46 | pico_generate_pio_header(BlitHalPico ${CMAKE_CURRENT_LIST_DIR}/dbi-spi.pio)
|
76 | 47 | pico_generate_pio_header(BlitHalPico ${CMAKE_CURRENT_LIST_DIR}/dbi-8bit.pio)
|
@@ -99,166 +70,3 @@ target_compile_definitions(BlitHalPico INTERFACE ${BLIT_BOARD_DEFINITIONS})
|
99 | 70 | target_link_libraries(BlitHalPico INTERFACE ${BLIT_BOARD_LIBRARIES})
|
100 | 71 |
|
101 | 72 | set(BLIT_BOARD_DEFINITIONS ${BLIT_BOARD_DEFINITIONS} PARENT_SCOPE)
|
102 |
| - |
103 |
| -# some file paths we need later |
104 |
| -if(32BLIT_PICO_2350) |
105 |
| - set(LINKER_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/memmap_blit_2350.ld.in PARENT_SCOPE) |
106 |
| -else() |
107 |
| - set(LINKER_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/memmap_blit.ld.in PARENT_SCOPE) |
108 |
| -endif() |
109 |
| -set(STARTUP_SRC ${CMAKE_CURRENT_LIST_DIR}/startup.S ${CMAKE_CURRENT_LIST_DIR}/startup.cpp PARENT_SCOPE) |
110 |
| -set(LAUNCHERSHARED_DIR ${CMAKE_CURRENT_LIST_DIR}/../launcher-shared PARENT_SCOPE) |
111 |
| - |
112 |
| -# functions |
113 |
| -function(blit_executable NAME) |
114 |
| - message(STATUS "Processing ${NAME}") |
115 |
| - blit_executable_args(${ARGN}) |
116 |
| - |
117 |
| - add_executable(${NAME} ${SOURCES}) |
118 |
| - target_link_libraries(${NAME} BlitEngine pico_platform_headers) |
119 |
| - |
120 |
| - if(PICO_STANDALONE_UF2) |
121 |
| - # standalone .uf2 |
122 |
| - # TODO: import pico hal if standalone build |
123 |
| - if(NOT TARGET LauncherShared) |
124 |
| - add_subdirectory(${LAUNCHERSHARED_DIR} launcher-shared) |
125 |
| - endif() |
126 |
| - |
127 |
| - pico_enable_stdio_uart(${NAME} 1) |
128 |
| - pico_enable_stdio_usb(${NAME} 0) |
129 |
| - |
130 |
| - target_compile_definitions(${NAME} PRIVATE BLIT_PICO_STANDALONE=1 PICO_EMBED_XIP_SETUP=1) |
131 |
| - target_link_libraries(${NAME} BlitHalPico) |
132 |
| - |
133 |
| - pico_add_extra_outputs(${NAME}) |
134 |
| - |
135 |
| - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.uf2 |
136 |
| - DESTINATION bin |
137 |
| - ) |
138 |
| - elseif(PICO_BLIT) |
139 |
| - # loadable .blit |
140 |
| - set_property(TARGET ${NAME} PROPERTY BLIT_PICO_BLIT TRUE) |
141 |
| - |
142 |
| - # calculate and verify flash offset |
143 |
| - if(NOT PICO_BLIT_OFFSET_KB) |
144 |
| - if(32BLIT_PICO_2350) |
145 |
| - # if we build the file for a 4MB offset, we can use address translation |
146 |
| - set(PICO_BLIT_OFFSET_KB 4096) |
147 |
| - else() |
148 |
| - set(PICO_BLIT_OFFSET_KB 512) |
149 |
| - endif() |
150 |
| - endif() |
151 |
| - |
152 |
| - math(EXPR offset_mod "${PICO_BLIT_OFFSET_KB} % 64") |
153 |
| - if(${PICO_BLIT_OFFSET_KB} LESS 256 OR offset_mod) |
154 |
| - message(FATAL_ERROR "Blit offset should be >= 256k and a multiple of 64k") |
155 |
| - endif() |
156 |
| - |
157 |
| - math(EXPR FLASH_OFFSET_BYTES "${PICO_BLIT_OFFSET_KB} * 1024") |
158 |
| - |
159 |
| - # customise linker script |
160 |
| - configure_file(${LINKER_SCRIPT} memmap_blit.ld) |
161 |
| - set(LINKER_SCRIPT_OUT ${CMAKE_CURRENT_BINARY_DIR}/memmap_blit.ld) |
162 |
| - |
163 |
| - target_compile_definitions(${NAME} PRIVATE ${BLIT_BOARD_DEFINITIONS}) # need these for framebuffer config |
164 |
| - target_compile_options(${NAME} PRIVATE -ffunction-sections -fdata-sections) |
165 |
| - |
166 |
| - # set device id in header, these should match the BlitDevice enum |
167 |
| - if(32BLIT_PICO_2350) |
168 |
| - set_source_files_properties(${STARTUP_SRC} PROPERTIES COMPILE_DEFINITIONS DEVICE_ID=3) |
169 |
| - else() |
170 |
| - set_source_files_properties(${STARTUP_SRC} PROPERTIES COMPILE_DEFINITIONS DEVICE_ID=2) |
171 |
| - endif() |
172 |
| - |
173 |
| - # minimal pico-sdk libs |
174 |
| - 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) |
175 |
| - target_compile_definitions(${NAME} PRIVATE PICO_TIME_DEFAULT_ALARM_POOL_DISABLED) # avoid pulling timer and irq code |
176 |
| - |
177 |
| - target_link_options(${NAME} PRIVATE --specs=nosys.specs LINKER:--script=${LINKER_SCRIPT_OUT} LINKER:--gc-sections) |
178 |
| - set_property(TARGET ${NAME} APPEND PROPERTY LINK_DEPENDS ${LINKER_SCRIPT_OUT}) |
179 |
| - |
180 |
| - target_sources(${NAME} PRIVATE ${STARTUP_SRC}) |
181 |
| - |
182 |
| - pico_add_bin_output(${NAME}) |
183 |
| - pico_add_dis_output(${NAME}) |
184 |
| - |
185 |
| - # Ideally we want the .blit filename to match the .elf, but TARGET_FILE_BASE_NAME isn't always available |
186 |
| - # (This only affects the firmware updater as it's the only thing setting a custom OUTPUT_NAME) |
187 |
| - if(${CMAKE_VERSION} VERSION_LESS "3.15.0") |
188 |
| - set(BLIT_FILENAME ${NAME}.blit) |
189 |
| - else() |
190 |
| - set(BLIT_FILENAME $<TARGET_FILE_BASE_NAME:${NAME}>.blit) |
191 |
| - endif() |
192 |
| - |
193 |
| - # no relocs, just copy it |
194 |
| - set(BIN_NAME "$<IF:$<BOOL:$<TARGET_PROPERTY:${NAME},OUTPUT_NAME>>,$<TARGET_PROPERTY:${NAME},OUTPUT_NAME>,$<TARGET_PROPERTY:${NAME},NAME>>.bin") |
195 |
| - add_custom_command(TARGET ${NAME} POST_BUILD |
196 |
| - VERBATIM |
197 |
| - COMMENT "Building ${NAME}.blit" |
198 |
| - COMMAND cp ${BIN_NAME} ${BLIT_FILENAME} |
199 |
| - ) |
200 |
| - |
201 |
| - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${BLIT_FILENAME} |
202 |
| - DESTINATION bin |
203 |
| - ) |
204 |
| - endif() |
205 |
| -endfunction() |
206 |
| - |
207 |
| -function(blit_metadata TARGET FILE) |
208 |
| - if(NOT IS_ABSOLUTE ${FILE}) |
209 |
| - set(FILE ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}) |
210 |
| - endif() |
211 |
| - |
212 |
| - # cause cmake to reconfigure whenever the asset list changes |
213 |
| - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${FILE}) |
214 |
| - |
215 |
| - # get the inputs/outputs for the asset tool (at configure time) |
216 |
| - execute_process( |
217 |
| - COMMAND ${32BLIT_TOOLS_EXECUTABLE} cmake --config ${FILE} --cmake ${CMAKE_CURRENT_BINARY_DIR}/metadata.cmake |
218 |
| - RESULT_VARIABLE TOOL_RESULT |
219 |
| - ) |
220 |
| - if(${TOOL_RESULT}) |
221 |
| - message(FATAL_ERROR "Reading metadata config failed!\n") |
222 |
| - endif() |
223 |
| - |
224 |
| - include(${CMAKE_CURRENT_BINARY_DIR}/metadata.cmake) |
225 |
| - |
226 |
| - get_property(PICO_BLIT TARGET ${TARGET} PROPERTY BLIT_PICO_BLIT) |
227 |
| - |
228 |
| - if(NOT PICO_BLIT) |
229 |
| - # create metadata/binary info source at build time |
230 |
| - set(METADATA_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_binary_info.cpp") |
231 |
| - |
232 |
| - add_custom_command( |
233 |
| - OUTPUT ${METADATA_SOURCE} |
234 |
| - COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${32BLIT_TOOLS_EXECUTABLE} metadata --force --config ${FILE} --pico-bi ${METADATA_SOURCE} |
235 |
| - DEPENDS ${FILE} |
236 |
| - VERBATIM |
237 |
| - ) |
238 |
| - |
239 |
| - # add the generated source |
240 |
| - target_sources(${TARGET} PRIVATE ${METADATA_SOURCE}) |
241 |
| - |
242 |
| - # avoid the fallback to target name |
243 |
| - target_compile_definitions(${TARGET} PRIVATE PICO_NO_BI_PROGRAM_NAME=1) |
244 |
| - else() |
245 |
| - # real .blit metadata |
246 |
| - if(${CMAKE_VERSION} VERSION_LESS "3.15.0") |
247 |
| - set(BLIT_FILENAME ${TARGET}.blit) |
248 |
| - else() |
249 |
| - set(BLIT_FILENAME $<TARGET_FILE_BASE_NAME:${TARGET}>.blit) |
250 |
| - endif() |
251 |
| - |
252 |
| - add_custom_command( |
253 |
| - TARGET ${TARGET} POST_BUILD |
254 |
| - COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${32BLIT_TOOLS_EXECUTABLE} metadata --config ${FILE} --file ${CMAKE_CURRENT_BINARY_DIR}/${BLIT_FILENAME} |
255 |
| - VERBATIM |
256 |
| - ) |
257 |
| - |
258 |
| - # force relink on change so that the post-build commands are rerun |
259 |
| - set_property(TARGET ${TARGET} APPEND PROPERTY LINK_DEPENDS ${FILE} ${METADATA_DEPENDS}) |
260 |
| - endif() |
261 |
| - |
262 |
| -endfunction() |
263 |
| - |
264 |
| -add_subdirectory(loader) |
0 commit comments