Skip to content

Conversation

@gojimmypi
Copy link
Contributor

@gojimmypi gojimmypi commented Oct 6, 2025

New Features

Known issues

  • CMake full sim testing is disabled (reference only; the default "no config" setting is the simulation. Applies only to GUI IDE)
  • CMake imx_rt testing is disabled (no workflow toolchain)
  • CMake presets stm32h5 and stm32l5 and stm32wb have "BUILD_TEST_APPS": "OFF" (toolchain / include file issue)


CMake reading .config files

This PR adds support for configuring the CMake build directly from a Kconfig-style .config file. When a .config is present at the repository root and USE_DOT_CONFIG=ON is set, CMake reads build options from that file instead of requiring them to be passed manually on the command line.

Example usage:

# From the repo root, with .config already in place
cmake -S . -B build-stm32h7 \
    -DUSE_DOT_CONFIG=ON \
    -DWOLFBOOT_TARGET=stm32h7

cmake --build build-stm32h7

For convenience, tools/scripts/cmake_dot_config.sh demonstrates one way to copy config/examples/<target>.config to .config and then run the CMake configure step using this mechanism, but it is just an example wrapper around the CMake interface shown above.

Test Drive

Work remains on CMake files, but the initial VS Code build should be working:

https://github.com/gojimmypi/wolfBoot.git
cd wolfboot
git checkout pr-cmake-improvements
git pull --recurse-submodules
git submodule update --init --recursive

#launch VS Code and open  wolfBoot.code-workspace  
code  ./IDE/VSCode/wolfBoot.code-workspace

# or your favorite cmake-aware editor such as Visual Studio 2022, etc.

Select STM32L4 wait for Cmake to finish, then click build. The output pane might be not visible. Grab frame to expand up:

image

I'm not sure yet which extensions are required, but at least the Microsoft ms-vscode.cmake-tools.

image

Here's a list of what I have installed:

code --list-extensions

davidanson.vscode-markdownlint
github.vscode-github-actions
marus25.cortex-debug
mcu-debug.debug-tracker-vscode
mcu-debug.memory-view
mcu-debug.peripheral-viewer
mcu-debug.rtos-views
ms-dotnettools.csdevkit
ms-dotnettools.csharp
ms-dotnettools.vscode-dotnet-runtime
ms-vscode-remote.remote-containers
ms-vscode-remote.remote-wsl
ms-vscode.cmake-tools
ms-vscode.cpptools
ms-vscode.cpptools-extension-pack
ms-vscode.cpptools-themes
ms-vscode.makefile-tools
nordic-semiconductor.nrf-kconfig
platformio.platformio-ide
trond-snekvik.gnu-mapfiles
twxs.cmake

Development

I use Visual Studio for CMake development but the objective is for an IDE-agnostic CMake build experience.

I use VisualGDB for embedded development; this will be a good exercise for flexible HAL file positioning and config.

I'm using an STM32L4, specifically the B-L475E-IOT01A Discovery kit IoT node that I happened to have on hand related to #585.

Some of the changes are specifically hard-code to the above. My objective is to make everything a configuration setting.

VS Code Presets

Was previously OS-specific, and needed to be launched from VS2022 command prompt. The stm32l4 tested (see above).

image

Visual Studio 2022

There's currently no VS2022 project file. Simply open the directory.

Select a device from the ribbon bar, shown here for the stm32l4

image

From Solution Explorer, right-click CmakeLists.txt and then select Configure wolfBoot.

image

To build, follow the same steps to right click, and select Build.

View the CMake and Build messages in the Output Window. Noter the dropdown to select view:

image


CMake Dev Status:

Status Environment Test With
VS 2022 Right-Click on CMakeLists.txt, Build
WSL ./tools/scripts/cmake_test.sh
Mac test-build-cmake-mac.yml
VS Code, Dev Prompt Click "build" on bottom toolbar ribbon
DOS Prompt, Dev Prompt .\tools\scripts\cmake_dev_prompt_test.bat
PowerShell, Dev Prompt .\tools\scripts\cmake_dev_prompt_test.bat
DOS Prompt, direct launch .\tools\scripts\cmake_test.bat (needs toolchain path)
PowerShell, direct launch .\tools\scripts\cmake_test.bat (needs toolchain path)
VS Code, direct launch Click "build"

Make Dev Status:

Status Environment Test With
? VS 2022 N/A (?)
WSL ./tools/scripts/wolfboot_build.sh --target stm32l4
⚠️ Mac test-build-cmake-mac.yml
? VS Code, Dev Prompt N/A (?)
DOS Prompt, Dev Prompt
PowerShell, Dev Prompt
DOS Prompt, direct launch
PowerShell, direct launch
? VS Code, direct launch N/A (?)

Copy link
Member

@danielinux danielinux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR Jim.

I did not test but I've spotted a bit too much pollution of the / directory. Please move .sh and .bat files under tools/scripts/. There are also some cmake-specific json files that could go under cmake/

The documentation for cmake builds (including existing one) should probably be moved in a new file under docs/ and referred to from /README.md

Let's not put platform-specific (stm32?) information in the main README.md either. This will confuse users on all other targets. Anything target-specific should be in docs/Targets.md.

Some files have meaningless or confusing names (my_test, wolfbuild)

Some instructions point to your private repository

@gojimmypi
Copy link
Contributor Author

gojimmypi commented Oct 16, 2025

Hi @danielinux

Thanks for your feedback! I realize that I came in for a remodel and left a bunch of trash laying around. I've cleaned this up in my latest 32e46e6 commit.

Thing are still WIP on my dev branch, but things here in this PR should be a bit cleaner now.

@dgarske - I've not yet addressed the unused cmake vars.

Changes of interest since my prior commit include non-os-specific presets. more testing, more docs (including cmake .config), script improvements, VS Code workspace moved to root directory, improved dynamic cmake downloads, main cmake functionality moved to include files in the cmake directory, and more.

There's more work to be done, particularly around supporting all of the targets. I'd like to get this initial update stable and merged before moving on to additional features and target devices.

Suggestions welcome.

EDIT: Launching VS Code from a non-VS2022 dev prompt (compiler NOT in the path by default) is not working, failing here:

[cmake] -- Completed VisualGDB detection.
[cmake] -- No .config files will be read; USE_DOT_CONFIG is disabled
[cmake] -- Tip: If find_program cannot find HOST_CC (not in path?), try launching from VS2022 dev prompt or edit path.
[cmake] CMake Error at CMakeLists.txt:112 (find_program):
[cmake]   Could not find HOST_CC using the following names: gcc, clang, cl

I'm revisiting compiler detection. I had this working, must have broke it. The features still work if everything is in the path (e.g. launch from Visual Studio command prompt), but it should support a fully specified toolchain & include path with no assumptions, nothing in path.

@gojimmypi gojimmypi requested a review from danielinux November 10, 2025 00:51
@gojimmypi
Copy link
Contributor Author

Still WIP, but I've applied cc4d2da that contains most of my current progress on cmake-specific updates from my dev branch.

A variety of other changes are also in the works, but those changes are in separate pull requests.

@gojimmypi
Copy link
Contributor Author

gojimmypi commented Nov 13, 2025

I've pushed my latest changes to pr-cmake-improvements branch for this PR. See my current workflow results.

There's only new WOLFBOOT_ROOT file: CMakePresets.json.

Required. See CMake docs:

--preset , --preset=
Reads a preset from CMakePresets.json and CMakeUserPresets.json files, which must be located in the same directory as the top level CMakeLists.txt file. The preset may specify the generator, the build directory, a list of variables, and other arguments to pass to CMake. At least one of CMakePresets.json or CMakeUserPresets.json must be present. The CMake GUI also recognizes and supports CMakePresets.json and CMakeUserPresets.json files.

Notable update: NO new VSCode files added to WOLFBOOT_ROOT. All VSCode settings moved to IDE/VSCode.

Open the wolfBoot.code-workspace file from VSCode:

cd ~/workspace/wolfBoot-$USER

code  ./IDE/VSCode/wolfBoot.code-workspace

See blog: CMake Presets integration in Visual Studio and Visual Studio Code

I plan to move ALL Visual Studio files to [WOLFBOOT_ROOT]/IDE/VisualStudio. See #598

Various other CMake improvements, a good spot for testing at 5266e0a .

@dgarske dgarske removed their request for review November 17, 2025 17:25
@gojimmypi gojimmypi force-pushed the pr-cmake-improvements branch 2 times, most recently from 63be6c9 to 0a6698d Compare November 19, 2025 00:56
@danielinux
Copy link
Member

Still reviewing changes. Please re-organize documentation flow. CMake section still growing, so it deserves its own file in docs/

Very important: remove docs/STM32.md and move the relevant info to Target.md (specific to STM32L4, requiring cubeMx, all other STM32 don't have that dependency and these instructions are very confusing because of this).

@gojimmypi gojimmypi requested a review from danielinux November 21, 2025 01:09
Copy link
Member

@danielinux danielinux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still adding a file docs/STM32.md with wrong "generic" instructions for STM32 targets, which in fact only apply to STM32L4, plus randomly introducing IDE-specific instructions. Remove that file as per previous comments.

Also, please add CMake build tests in the workflow for other targets as well. The main issue to resolve in this PR is CMake coverage across targets.

@gojimmypi
Copy link
Contributor Author

@danielinux I've added additional STM32 targets and updated workflows to test them all in 1ad66e9

I've also updated the docs and removed the docs/STM32.md file per your request.

I currently have a sim default preset with spaces in the name so that it shows up like this in the IDE list this:


image

However, I've had some problems using that from command-line, so those sim tests are disabled for now. See 4474cf8

I started down the road or other ARM targets, but the first one I tried doesn't have a GitHub workflow toolchain, so the imx-rt testing is also disabled for now.

@gojimmypi gojimmypi requested a review from danielinux November 22, 2025 19:07
Copy link
Member

@danielinux danielinux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor changes

@gojimmypi gojimmypi changed the title WIP CMake Improvements CMake Improvements Nov 24, 2025
@gojimmypi
Copy link
Contributor Author

@danielinux Thanks for the review; Applied updates and changes as requested. See 079fb00

I inadvertently left the in-source build error message test; reverted in f202980

@gojimmypi gojimmypi requested a review from danielinux November 24, 2025 21:13
@gojimmypi
Copy link
Contributor Author

Additional work remains, but this is still a good stopping point for this update.

In particular: See the "Known issues" I added at the beginning of the PR description.

@danielinux
Copy link
Member

LGTM, off to @dgarske for final review & merge

Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice set of CMake improvements! Thank you Jim

@dgarske dgarske removed the request for review from wolfSSL-Bot November 25, 2025 18:26
@dgarske dgarske merged commit 84bf772 into wolfSSL:master Nov 25, 2025
286 of 287 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants