pico-feedback icon indicating copy to clipboard operation
pico-feedback copied to clipboard

Changed requirements for cmake set(PICO_BOARD) in SDK 2.0.0

Open slimhazard opened this issue 1 year ago • 2 comments

This came up in the SDK forum, where @kilograham asked for a pico-feedback issue, so that it can be better documented.

https://forums.raspberrypi.com/viewtopic.php?t=376508&sid=19c9d2fc64cb0e6ba4d4cac25787e270

Prior to version 2.0.0, it was sufficient to call set(PICO_BOARD) in CMakeLists.txt before invoking pico_sdk_init(). The set() call could come after including the SDK import code:

include(pico_sdk_import.cmake)

project(myproject C CXX ASM)
# [...]
set(PICO_BOARD pico_w)

pico_sdk_init()

That would lead to a successful build for a PicoW.

But as of 2.0.0, that same code leads to this output from cmake:

Defaulting platform (PICO_PLATFORM) to 'rp2040' since not specified.
Defaulting target board (PICO_BOARD) to 'pico' since not specified.

And then the build fails for a PicoW.

Evidently it's now necessary to set PICO_BOARD before including the SDK import code:

set(PICO_BOARD pico_w)
include(pico_sdk_import.cmake)

project(myproject C CXX ASM)
# [...]

pico_sdk_init()

With that, cmake output confirms that the build is set for a PicoW, and the build succeeds.

slimhazard avatar Sep 11 '24 15:09 slimhazard

Note we didn't notice this change, as we always tend to pass PICO_BOARD to CMake either on the command line or from the env, or from the IDE

kilograham avatar Sep 11 '24 16:09 kilograham

@Memotech-Bill pointed out in the forum that this also came up in an SDK issue.

slimhazard avatar Sep 12 '24 08:09 slimhazard

Closing this as there's an SDK issue

peterharperuk avatar Jul 09 '25 10:07 peterharperuk