Use platform/generator agnostic CMake commands #2539

Merged
will-v-pi merged 4 commits from will-v-pi-patch-1 into develop 2025-07-14 11:20:56 -05:00
will-v-pi commented 2025-06-23 10:20:21 -05:00 (Migrated from github.com)

Change the README to use platform/generator agnostic commands to create and build the CMake project

This means the generic commands work with Ninja or Makefiles, and avoids the need to cd into build directories

Change the README to use platform/generator agnostic commands to create and build the CMake project This means the generic commands work with Ninja or Makefiles, and avoids the need to `cd` into build directories
kilograham (Migrated from github.com) reviewed 2025-06-23 10:20:21 -05:00
lurch (Migrated from github.com) reviewed 2025-06-23 10:32:38 -05:00
@ -184,2 +182,3 @@
> 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.
lurch (Migrated from github.com) commented 2025-06-23 10:32:38 -05:00

IMHO we should either explain what these short command-line switches mean...

IMHO we should either explain what these short command-line switches mean...
lurch (Migrated from github.com) reviewed 2025-06-23 10:33:33 -05:00
lurch (Migrated from github.com) commented 2025-06-23 10:33:33 -05:00

...or we should be consistent and just use the long command-line switches? (which are "more self-documenting" than the short options)

...or we should be consistent and just use the long command-line switches? (which are "more self-documenting" than the short options)
will-v-pi (Migrated from github.com) reviewed 2025-06-23 10:36:58 -05:00
will-v-pi (Migrated from github.com) commented 2025-06-23 10:36:58 -05:00

Are there long options for -S and -B - if there are, they're not documented in the CMake docs

Are there long options for `-S` and `-B` - if there are, they're not documented in the CMake docs
will-v-pi (Migrated from github.com) reviewed 2025-06-23 10:41:47 -05:00
@ -184,2 +182,3 @@
> 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.
will-v-pi (Migrated from github.com) commented 2025-06-23 10:41:47 -05:00

Something like adding

cmake -S <source_dir> -B <build_dir>

below the command?

Something like adding > `cmake -S <source_dir> -B <build_dir>` below the command?
lurch (Migrated from github.com) reviewed 2025-06-23 11:19:15 -05:00
@ -184,2 +182,3 @@
> 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.
lurch (Migrated from github.com) commented 2025-06-23 11:19:15 -05:00

Yeah, or just something like

The cmake -S flag indicates the source directory, and -B tells cmake where to put the output files.

? 🤷

Yeah, or just something like > The cmake `-S` flag indicates the source directory, and `-B` tells cmake where to put the output files. ? :shrug:
lurch (Migrated from github.com) reviewed 2025-06-23 11:19:52 -05:00
lurch (Migrated from github.com) commented 2025-06-23 11:19:51 -05:00

Hooray for the enforced lack of consistency then 🙄

Hooray for the enforced lack of consistency then :roll_eyes:
lurch (Migrated from github.com) reviewed 2025-06-23 11:47:48 -05:00
lurch (Migrated from github.com) commented 2025-06-23 11:47:48 -05:00

Now that we're not cding into a directory, perhaps we ought to explicitly say that the named build directory here needs to match the -B value used earlier?

Now that we're not `cd`ing into a directory, perhaps we ought to explicitly say that the named `build` directory here needs to match the `-B` value used earlier?
will-v-pi (Migrated from github.com) reviewed 2025-06-23 11:49:01 -05:00
will-v-pi (Migrated from github.com) commented 2025-06-23 11:49:01 -05:00

I was wondering if it'd be cleaner to use ./build or build/ or something, to make it clearer it's a directory?

I was wondering if it'd be cleaner to use `./build` or `build/` or something, to make it clearer it's a directory?
lurch (Migrated from github.com) reviewed 2025-06-24 06:05:37 -05:00
@ -177,12 +177,11 @@ instructions for other platforms, and just in general, we recommend you see [Ras
1. Setup a CMake build directory.
lurch (Migrated from github.com) commented 2025-06-24 06:05:36 -05:00
      > 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.
```suggestion > 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. ```
lurch (Migrated from github.com) reviewed 2025-06-24 06:07:55 -05:00
lurch (Migrated from github.com) commented 2025-06-24 06:07:55 -05:00
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.
```suggestion 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. ```
lurch (Migrated from github.com) reviewed 2025-06-24 06:09:44 -05:00
lurch (Migrated from github.com) commented 2025-06-24 06:09:44 -05:00

Maybe a bit wordy, but I've suggested one possible way that we could explain this more clearly.

Maybe a bit wordy, but I've suggested one possible way that we could explain this more clearly.
will-v-pi (Migrated from github.com) reviewed 2025-06-24 06:39:43 -05:00
will-v-pi (Migrated from github.com) commented 2025-06-24 06:39:43 -05:00

Probably as an inline quote, like the other similar comment above

> 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.

Probably as an inline quote, like the other similar comment above ```suggestion > 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. ```
will-v-pi (Migrated from github.com) reviewed 2025-06-24 06:42:37 -05:00
@ -193,8 +192,9 @@ instructions for other platforms, and just in general, we recommend you see [Ras
will-v-pi (Migrated from github.com) commented 2025-06-24 06:42:37 -05:00
      > 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.
```suggestion > 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. ```
lurch (Migrated from github.com) approved these changes 2025-06-24 07:22:03 -05:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk!2539
No description provided.