Skip to content

Rework use of pico_cmake_set in board headers to make it slightly less magic/confusing #2397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions cmake/generic_board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,22 @@ if (EXISTS ${PICO_BOARD_HEADER_FILE})

while(HEADER_FILE_CONTENTS)
list(POP_FRONT HEADER_FILE_CONTENTS LINE)
if (LINE MATCHES "^[ \t\]*//[ \t\]*pico_cmake_set[ \t\]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t\]*=[ \t\]*(.*)")
# pico_board_cmake_set(var, value)
if (LINE MATCHES "^[ \t\]*pico_board_cmake_set[ \t\]*\\([ \t\]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t\]*,[ \t\]*(.*)[ \t\]*\\)[ \t\]*")
set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}")
endif()
if (LINE MATCHES "^[ \t\]*//[ \t\]*pico_cmake_set_default[ \t\]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t\]*=[ \t\]*(.*)")
# pico_board_cmake_set_default(var, value)
elseif (LINE MATCHES "^[ \t\]*pico_board_cmake_set_default[ \t\]*\\([ \t\]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t\]*,[ \t\]*(.*)[ \t\]*\\)[ \t\]*")
if (NOT DEFINED "${CMAKE_MATCH_1}")
set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}")
else()
list(APPEND PICO_BOARD_CMAKE_OVERRIDES ${CMAKE_MATCH_1})
endif()
# continue to support these for now
# // pico_cmake_set var = value
elseif (LINE MATCHES "^[ \t\]*//[ \t\]*pico_cmake_set[ \t\]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t\]*=[ \t\]*(.*)")
set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}")
# // pico_cmake_set_default var = value
elseif (LINE MATCHES "^[ \t\]*//[ \t\]*pico_cmake_set_default[ \t\]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t\]*=[ \t\]*(.*)")
if (NOT DEFINED "${CMAKE_MATCH_1}")
set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}")
else()
Expand Down
6 changes: 3 additions & 3 deletions src/boards/include/boards/0xcb_helios.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
//------------------------------------------------------------------------------------------
// Board definition for the 0xCB Helios

// pico_cmake_set PICO_PLATFORM=rp2040

#ifndef _BOARDS_0XCB_HELIOS_H
#define _BOARDS_0XCB_HELIOS_H

pico_board_cmake_set(PICO_PLATFORM, rp2040)

// For board detection
#define _0XCB_HELIOS

Expand Down Expand Up @@ -73,7 +73,7 @@
#endif

// board has 16M onboard flash
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (16 * 1024 * 1024))
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/boards/include/boards/adafruit_feather_rp2040.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------

// pico_cmake_set PICO_PLATFORM=rp2040

#ifndef _BOARDS_ADAFRUIT_FEATHER_RP2040_H
#define _BOARDS_ADAFRUIT_FEATHER_RP2040_H

pico_board_cmake_set(PICO_PLATFORM, rp2040)

// For board detection
#define ADAFRUIT_FEATHER_RP2040

Expand Down Expand Up @@ -83,7 +83,7 @@
#define PICO_FLASH_SPI_CLKDIV 4
#endif

// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (8 * 1024 * 1024))
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/boards/include/boards/adafruit_feather_rp2040_usb_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------

// pico_cmake_set PICO_PLATFORM=rp2040

#ifndef _BOARDS_ADAFRUIT_FEATHER_RP2040_USB_HOST_H
#define _BOARDS_ADAFRUIT_FEATHER_RP2040_USB_HOST_H

pico_board_cmake_set(PICO_PLATFORM, rp2040)

// For board detection
#define ADAFRUIT_FEATHER_RP2040_USB_HOST

Expand Down Expand Up @@ -79,7 +79,7 @@
#define PICO_FLASH_SPI_CLKDIV 4
#endif

// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (8 * 1024 * 1024))
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/boards/include/boards/adafruit_feather_rp2350.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

// This header may be included by other board headers as "boards/adafruit_feather_rp2350.h"

// pico_cmake_set PICO_PLATFORM=rp2350

#ifndef _BOARDS_ADAFRUIT_FEATHER_RP2350_H
#define _BOARDS_ADAFRUIT_FEATHER_RP2350_H

pico_board_cmake_set(PICO_PLATFORM, rp2350)

// On some samples, the xosc can take longer to stabilize than is usual
#ifndef PICO_XOSC_STARTUP_DELAY_MULTIPLIER
#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64
Expand Down Expand Up @@ -78,12 +78,12 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif

// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (8 * 1024 * 1024))
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif

// pico_cmake_set_default PICO_RP2350_A2_SUPPORTED = 1
pico_board_cmake_set_default(PICO_RP2350_A2_SUPPORTED, 1)
#ifndef PICO_RP2350_A2_SUPPORTED
#define PICO_RP2350_A2_SUPPORTED 1
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/boards/include/boards/adafruit_itsybitsy_rp2040.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------

// pico_cmake_set PICO_PLATFORM=rp2040

#ifndef _BOARDS_ADAFRUIT_ITSYBITSY_RP2040_H
#define _BOARDS_ADAFRUIT_ITSYBITSY_RP2040_H

pico_board_cmake_set(PICO_PLATFORM, rp2040)

// For board detection
#define ADAFRUIT_ITSYBITSY_RP2040

Expand Down Expand Up @@ -86,7 +86,7 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif

// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (8 * 1024 * 1024))
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/boards/include/boards/adafruit_kb2040.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------

// pico_cmake_set PICO_PLATFORM=rp2040

#ifndef _BOARDS_ADAFRUIT_KB2040_H
#define _BOARDS_ADAFRUIT_KB2040_H

pico_board_cmake_set(PICO_PLATFORM, rp2040)

// For board detection
#define ADAFRUIT_KB2040

Expand Down Expand Up @@ -78,7 +78,7 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif

// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (8 * 1024 * 1024))
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/boards/include/boards/adafruit_macropad_rp2040.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#ifndef _BOARDS_ADAFRUIT_MACROPAD_RP2040_H
#define _BOARDS_ADAFRUIT_MACROPAD_RP2040_H

// pico_cmake_set PICO_PLATFORM=rp2040

// For board detection
#define ADAFRUIT_MACROPAD_RP2040

pico_board_cmake_set(PICO_PLATFORM, rp2040)

// On some samples, the xosc can take longer to stabilize than is usual
#ifndef PICO_XOSC_STARTUP_DELAY_MULTIPLIER
#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64
Expand Down Expand Up @@ -173,7 +173,7 @@
#define PICO_FLASH_SPI_CLKDIV 4
#endif

// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (8 * 1024 * 1024))
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/boards/include/boards/adafruit_qtpy_rp2040.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------

// pico_cmake_set PICO_PLATFORM=rp2040

#ifndef _BOARDS_ADAFRUIT_QTPY_RP2040_H
#define _BOARDS_ADAFRUIT_QTPY_RP2040_H

pico_board_cmake_set(PICO_PLATFORM, rp2040)

// For board detection
#define ADAFRUIT_QTPY_RP2040

Expand Down Expand Up @@ -85,7 +85,7 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif

// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (8 * 1024 * 1024))
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/boards/include/boards/adafruit_trinkey_qt2040.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------

// pico_cmake_set PICO_PLATFORM=rp2040

#ifndef _BOARDS_ADAFRUIT_TRINKEY_QT2040_H
#define _BOARDS_ADAFRUIT_TRINKEY_QT2040_H

pico_board_cmake_set(PICO_PLATFORM, rp2040)

// For board detection
#define ADAFRUIT_TRINKEY_QT2040

Expand Down Expand Up @@ -63,7 +63,7 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif

// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (8 * 1024 * 1024))
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/boards/include/boards/amethyst_fpga.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------

// pico_cmake_set PICO_PLATFORM=rp2350

#ifndef _BOARDS_AMETHYST_FPGA_H
#define _BOARDS_AMETHYST_FPGA_H

pico_board_cmake_set(PICO_PLATFORM, rp2350)

#if !PICO_RP2350
#error "Invalid PICO_PLATFORM for amethyst_fpga.h: must be rp2350 or rp2350-riscv"
#endif
Expand Down Expand Up @@ -98,7 +98,7 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif

// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (16 * 1024 * 1024))
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/boards/include/boards/archi.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

// This header may be included by other board headers as "boards/archi.h"

// pico_cmake_set PICO_PLATFORM=rp2040

#ifndef _BOARDS_ARCHI_H
#define _BOARDS_ARCHI_H

pico_board_cmake_set(PICO_PLATFORM, rp2040)

// For board detection
#define ARCHI

Expand Down Expand Up @@ -104,7 +104,7 @@
#define PICO_FLASH_SPI_CLKDIV 4
#endif

// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (4 * 1024 * 1024)
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (4 * 1024 * 1024))
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (4 * 1024 * 1024)
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/boards/include/boards/arduino_nano_rp2040_connect.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------

// pico_cmake_set PICO_PLATFORM=rp2040

#ifndef _BOARDS_ARDUINO_NANO_RP2040_CONNECT_H
#define _BOARDS_ARDUINO_NANO_RP2040_CONNECT_H

pico_board_cmake_set(PICO_PLATFORM, rp2040)

// For board detection
#define ARDUINO_NANO_RP2040_CONNECT

Expand Down Expand Up @@ -74,7 +74,7 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif

// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (16 * 1024 * 1024))
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/boards/include/boards/cytron_maker_pi_rp2040.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------

// pico_cmake_set PICO_PLATFORM=rp2040

#ifndef _BOARDS_CYTRON_MAKER_PI_RP2040_H
#define _BOARDS_CYTRON_MAKER_PI_RP2040_H

pico_board_cmake_set(PICO_PLATFORM, rp2040)

// For board detection
#define CYTRON_MAKER_PI_RP2040

Expand Down Expand Up @@ -179,7 +179,7 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif

// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (2 * 1024 * 1024))
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/boards/include/boards/datanoisetv_rp2040_dsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
//
// This header may be included by other board headers as "boards/datanoisetv_rp2040_dsp.h"

// pico_cmake_set PICO_PLATFORM=rp2040

#ifndef _BOARDS_DATANOISETV_RP2040_DSP_H
#define _BOARDS_DATANOISETV_RP2040_DSP_H

pico_board_cmake_set(PICO_PLATFORM, rp2040)

// For board detection
#define DATANOISETV_RP2040_DSP

Expand All @@ -40,7 +40,7 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif

// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (16 * 1024 * 1024))
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/boards/include/boards/datanoisetv_rp2350_dsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
//
// This header may be included by other board headers as "boards/datanoisetv_rp2350_dsp.h"

// pico_cmake_set PICO_PLATFORM=rp2350

#ifndef _BOARDS_DATANOISETV_RP2350_DSP_H
#define _BOARDS_DATANOISETV_RP2350_DSP_H

pico_board_cmake_set(PICO_PLATFORM, rp2350)

// For board detection
#define DATANOISETV_RP2350_DSP

Expand All @@ -43,12 +43,12 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif

// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024)
pico_board_cmake_set_default(PICO_FLASH_SIZE_BYTES, (8 * 1024 * 1024))
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif

// pico_cmake_set_default PICO_RP2350_A2_SUPPORTED = 1
pico_board_cmake_set_default(PICO_RP2350_A2_SUPPORTED, 1)
#ifndef PICO_RP2350_A2_SUPPORTED
#define PICO_RP2350_A2_SUPPORTED 1
#endif
Expand Down
Loading