Properly respect setting PICO_DEFAULT_BINARY_TYPE (#2381)

* Properly respect setting PICO_DEFAULT_BINARY_TYPE (rather than say PICO_NO_FLASH), and add a build error for specifying different types simulataneously
* remove dead code
This commit is contained in:
Graham Sanderson 2025-04-03 09:58:41 -05:00 committed by GitHub
parent f154f58cf9
commit f62bc4f5ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -30,6 +30,7 @@ if (NOT TARGET pico_standard_link)
set_target_properties(${TARGET} PROPERTIES PICO_TARGET_BINARY_TYPE ${TYPE})
endfunction()
# slightly messy as we support both the preferred PICO_DEFAULT_BINARY_TYPE and the individual variables
if (NOT PICO_DEFAULT_BINARY_TYPE)
if (PICO_NO_FLASH)
set(PICO_DEFAULT_BINARY_TYPE no_flash)
@ -40,6 +41,23 @@ if (NOT TARGET pico_standard_link)
else()
set(PICO_DEFAULT_BINARY_TYPE default)
endif()
else()
# we must set the individual variables here, as they are used in generator expressions,
# but also for our checks below
if (PICO_DEFAULT_BINARY_TYPE STREQUAL no_flash)
set(PICO_NO_FLASH 1)
endif()
if (PICO_DEFAULT_BINARY_TYPE STREQUAL blocked_ram)
set(PICO_USE_BLOCKED_RAM 1)
endif()
if (PICO_DEFAULT_BINARY_TYPE STREQUAL copy_to_ram)
set(PICO_COPY_TO_RAM 1)
endif()
endif()
if ((PICO_NO_FLASH AND PICO_USE_BLOCKED_RAM) OR
(PICO_USE_BLOCKED_RAM AND PICO_COPY_TO_RAM) OR
(PICO_COPY_TO_RAM AND PICO_NO_FLASH))
message(FATAL_ERROR "Conflicting binary types specified amongst PICO_DEFAULT_BINARY_TYPE, PICO_NO_FLASH, PICO_USE_BLOCKED_RAM and PICO_COPY_TO_RAM")
endif()
# todo only needed if not using a custom linker script