@@ -71,6 +71,12 @@ define_property(TARGET
71
71
BRIEF_DOCS "Extra arguments to pass to uf2 conversion"
72
72
FULL_DOCS "Extra arguments to pass to uf2 conversion"
73
73
)
74
+ define_property (TARGET
75
+ PROPERTY PICOTOOL_PROCESSING_DONE
76
+ INHERITED
77
+ BRIEF_DOCS "Set once post-processing has been completed in CMake"
78
+ FULL_DOCS "Set once post-processing has been completed in CMake"
79
+ )
74
80
75
81
# Check pioasm is installed, or build it if not installed
76
82
function (pico_init_pioasm)
@@ -146,6 +152,13 @@ function(pico_init_picotool)
146
152
endif ()
147
153
endfunction ()
148
154
155
+ function (picotool_check_not_done TARGET )
156
+ get_target_property (done ${TARGET} PICOTOOL_PROCESSING_DONE)
157
+ if (done)
158
+ message (FATAL_ERROR "All picotool post-processing functions for \" ${TARGET} \" must come before pico_add_extra_outputs(${TARGET} )" )
159
+ endif ()
160
+ endfunction ()
161
+
149
162
# Generate pio header and include it in the build
150
163
# PICO_CMAKE_CONFIG: PICO_DEFAULT_PIOASM_OUTPUT_FORMAT, Default output format used by pioasm when using pico_generate_pio_header, type=string, default=c-sdk, group=build
151
164
function (pico_generate_pio_header TARGET PIO)
@@ -198,6 +211,7 @@ endfunction()
198
211
# dropping, and it will be copied to SRAM by the bootrom before execution.
199
212
# This sets PICOTOOL_UF2_PACKAGE_ADDR to PACKADDR.
200
213
function (pico_package_uf2_output TARGET PACKADDR)
214
+ picotool_check_not_done(${TARGET} )
201
215
set_target_properties (${TARGET} PROPERTIES
202
216
PICOTOOL_UF2_PACKAGE_ADDR ${PACKADDR}
203
217
)
@@ -207,6 +221,7 @@ endfunction()
207
221
# Output the public key hash and other necessary rows to an otp JSON file.
208
222
# This sets PICOTOOL_OTP_FILE to OTPFILE.
209
223
function (pico_set_otp_key_output_file TARGET OTPFILE)
224
+ picotool_check_not_done(${TARGET} )
210
225
set_target_properties (${TARGET} PROPERTIES
211
226
PICOTOOL_OTP_FILE ${OTPFILE}
212
227
)
@@ -217,6 +232,7 @@ endfunction()
217
232
# before loading the binary. This appends the `--clear` argument
218
233
# to PICOTOOL_EXTRA_PROCESS_ARGS.
219
234
function (pico_load_map_clear_sram TARGET )
235
+ picotool_check_not_done(${TARGET} )
220
236
# get and set, to inherit list
221
237
get_target_property (extra_args ${TARGET} PICOTOOL_EXTRA_PROCESS_ARGS)
222
238
if (extra_args)
@@ -234,6 +250,7 @@ endfunction()
234
250
# to PICOTOOL_EXTRA_PROCESS_ARGS if setting the rollback version, or set as compile
235
251
# definitions if only setting the major/minor versions.
236
252
function (pico_set_binary_version TARGET )
253
+ picotool_check_not_done(${TARGET} )
237
254
set (oneValueArgs MAJOR MINOR ROLLBACK)
238
255
set (multiValueArgs ROWS)
239
256
cmake_parse_arguments (PARSE_ARGV 1 SV "" "${oneValueArgs} " "${multiValueArgs} " )
@@ -283,6 +300,7 @@ endfunction()
283
300
# Set the UF2 family to use when creating the UF2.
284
301
# This sets PICOTOOL_UF2_FAMILY to FAMILY.
285
302
function (pico_set_uf2_family TARGET FAMILY)
303
+ picotool_check_not_done(${TARGET} )
286
304
set_target_properties (${TARGET} PROPERTIES
287
305
PICOTOOL_UF2_FAMILY ${FAMILY}
288
306
)
@@ -295,6 +313,7 @@ endfunction()
295
313
# specify a common SIGFILE for multiple targets, the SIGFILE property can be
296
314
# set for a given scope, and then the SIGFILE argument is optional.
297
315
function (pico_sign_binary TARGET )
316
+ picotool_check_not_done(${TARGET} )
298
317
# Enforce signing through target properties
299
318
set_target_properties (${TARGET} PROPERTIES
300
319
PICOTOOL_SIGN_OUTPUT true
@@ -320,6 +339,7 @@ endfunction()
320
339
# pico_hash_binary(TARGET)
321
340
# Hash the target binary. This sets PICOTOOL_HASH_OUTPUT to true.
322
341
function (pico_hash_binary TARGET )
342
+ picotool_check_not_done(${TARGET} )
323
343
# Enforce hashing through target properties
324
344
set_target_properties (${TARGET} PROPERTIES
325
345
PICOTOOL_HASH_OUTPUT true
@@ -330,6 +350,7 @@ endfunction()
330
350
# Create the specified partition table from JSON, and embed it in the
331
351
# block loop. This sets PICOTOOL_EMBED_PT to PTFILE.
332
352
function (pico_embed_pt_in_binary TARGET PTFILE)
353
+ picotool_check_not_done(${TARGET} )
333
354
set_target_properties (${TARGET} PROPERTIES
334
355
PICOTOOL_EMBED_PT ${PTFILE}
335
356
)
@@ -341,6 +362,7 @@ endfunction()
341
362
# This sets PICOTOOL_AESFILE to AESFILE, and PICOTOOL_ENC_SIGFILE to SIGFILE
342
363
# if present, else PICOTOOL_SIGFILE.
343
364
function (pico_encrypt_binary TARGET AESFILE)
365
+ picotool_check_not_done(${TARGET} )
344
366
set_target_properties (${TARGET} PROPERTIES
345
367
PICOTOOL_AESFILE ${AESFILE}
346
368
)
@@ -422,6 +444,9 @@ endfunction()
422
444
# Run picotool post-processing on the binary - must be called after
423
445
# all required properties have been set
424
446
function (picotool_postprocess_binary TARGET )
447
+ set_target_properties (${TARGET} PROPERTIES
448
+ PICOTOOL_PROCESSING_DONE true
449
+ )
425
450
# Read target properties
426
451
get_target_property (picotool_sign_output ${TARGET} PICOTOOL_SIGN_OUTPUT)
427
452
if (picotool_sign_output)
0 commit comments