From 4ee09729cf708de912bae17a9057ac99f6f3d3c2 Mon Sep 17 00:00:00 2001 From: will-v-pi <108662275+will-v-pi@users.noreply.github.com> Date: Mon, 14 Jul 2025 17:20:55 +0100 Subject: [PATCH] Use platform/generator agnostic CMake commands (#2539) * Use platform/generator agnostic CMake commands Change the README to use platform/generator agnostic commands to create and build the CMake project * review fixup * Apply suggestions from code review Co-authored-by: Andrew Scheller * Whitespace fix --------- Co-authored-by: Andrew Scheller --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 08a10402..bb89fc0b 100644 --- a/README.md +++ b/README.md @@ -177,12 +177,11 @@ instructions for other platforms, and just in general, we recommend you see [Ras 1. Setup a CMake build directory. For example, if not using an IDE: ``` - $ mkdir build - $ cd build - $ cmake .. - ``` + $ cmake -S . -B build + ``` + > The cmake -S flag indicates the source directory, and the -B flag tells cmake the name of the output-directory to create. This doesn't have to be named "build", you can call it whatever you want. - When building for a board other than the Raspberry Pi Pico, you should pass `-DPICO_BOARD=board_name` to the `cmake` command above, e.g. `cmake -DPICO_BOARD=pico2 ..` or `cmake -DPICO_BOARD=pico_w ..` to configure the SDK and build options accordingly for that particular board. + When building for a board other than the Raspberry Pi Pico, you should pass `-DPICO_BOARD=board_name` to the `cmake` command above, e.g. `cmake -S . -B build -DPICO_BOARD=pico2` or `cmake -S . -B build -DPICO_BOARD=pico_w` to configure the SDK and build options accordingly for that particular board. Specifying `PICO_BOARD=` sets up various compiler defines (e.g. default pin numbers for UART and other hardware) and in certain cases also enables the use of additional libraries (e.g. wireless support when building for `PICO_BOARD=pico_w`) which cannot @@ -193,8 +192,9 @@ instructions for other platforms, and just in general, we recommend you see [Ras 1. Make your target from the build directory you created. ```sh - $ make hello_world + $ cmake --build build --target hello_world ``` + > The directory-name supplied to the `--build` flag needs to match the directory-name that was passed to the `-B` flag in the earlier cmake command. 1. You now have `hello_world.elf` to load via a debugger, or `hello_world.uf2` that can be installed and run on your Raspberry Pi Pico-series device via drag and drop.