raspberrypi / pico-feedback

25 stars 2 forks source link

Changed requirements for cmake set(PICO_BOARD) in SDK 2.0.0 #411

Open slimhazard opened 2 months ago

slimhazard commented 2 months ago

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.

kilograham commented 2 months ago

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

slimhazard commented 2 months ago

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