User-facing CMake variables do not update correctly when modified due to caching #2407
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#2407
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Some user-facing CMake variables (ie. the variables in this table from the SDK guide) have their values cached at various lines in the SDK, meaning that after the initial configuration, any changes to these variables by the user are handled unpredictably, due to adjacent definitions from the prior configuration persisting. It also prevents conditional statements, such as defining a default board intended to be overwritable:
Upon a surface-level search (regex
set\(PICO_.*CACHE), the following variables are affected:PICO_BOARDPICO_BOARD_HEADER_DIRSPICO_CMAKE_PRELOAD_PLATFORM_FILE(twice)PICO_DEFAULT_BOOT_STAGE2(also rp2350)PICO_DEFAULT_BOOT_STAGE2_FILE(also rp2350)PICO_GCC_TRIPLEPICO_NO_HARDWARE(also in on_device.cmake)PICO_ON_DEVICE(also in on_device.cmake)PICO_PLATFORMPICO_TOOLCHAIN_PATH(also in find_compiler.cmake)Having the CMake cache is helpful for larger projects; and by having variables be user-facing, that implies (to me) an assumption of mutability. It would be nice if users could reconfigure without needing to delete the build directory or pass
--freshto CMake.A more detailed description of chaching issues can be see in the related #1618.
I'd be happy to submit a PR to remove the caching for all variables listed above if changing this behaviour into more intentional caching would be something you lot would be open to 👍
Some of the caching is intentional, and/or needed to force passing variables across otherwise unrelated scopes
see also #2304
note also, that anything that affects the compiler choice (which many of the above do) are not really mutable as CMake doesn't like changing them in an existing build directory (we recently fixed an issue where the SDK didn't complain if you tried)
Awesome - great to know this is already on your radar. I wouldn't be familiar with deciding which caching is necessary regarding scope, but let me know if there's any ways I can help 👍