Skip to content
Open
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
25 changes: 23 additions & 2 deletions cmake/stm32/devices.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,34 @@ macro(stm32_pretty_print_dev_list FAMILIES STM_DEVICES)
endmacro()



include(FetchContent)

# Allow user to optionally define this via command line or script
# Example: cmake -DCMSIS_CUSTOM_VERSION=5.9.0

# Define a list of valid CMSIS versions
# TODO: Update newer CMSIS versions when released
list(APPEND VALID_CMSIS_VERSIONS " 5.9.0" " 5.6.0_cm3" " 5.6.0_cm7" " 5.6.0_cm0" " 5.6.0_cm33" " 5.6.0" " 5.6.0_cm4" " 5.4.0" " 5.4.0_cm33" " 5.4.0_cm7")

set(CMSIS_CUSTOM_VERSION "" CACHE STRING "Optional custom CMSIS version")

# Use the custom version if provided, otherwise fall back to default
if(DEFINED CMSIS_CUSTOM_VERSION AND NOT "${CMSIS_CUSTOM_VERSION}" STREQUAL "")
list(FIND VALID_CMSIS_VERSIONS " ${CMSIS_CUSTOM_VERSION}" VALID_VERSION_INDEX)
if(VALID_VERSION_INDEX EQUAL -1)
message(FATAL_ERROR "Invalid CMSIS version provided ${CMSIS_CUSTOM_VERSION}. Supported versions are: ${VALID_CMSIS_VERSIONS}")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I like this, but it does make us follow the releases... Isn't letting the Fetch fail enough ?

What do you think @atsju ?

@atsju atsju Aug 13, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same. Have an explicit error message on how the user can find valid versions when fetch fails (with one or two examples).
But avoid having stm32-cmake to follow CMSIS releases. We have no automation for this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I will get back to this, I am currently involved in an internship

else()
set(CMSIS_VERSION_TO_USE "v${CMSIS_CUSTOM_VERSION}")
endif()
else()
set(CMSIS_VERSION_TO_USE "v5.6.0")
endif()

# FetchContent using the selected version
FetchContent_Declare(
STM32-CMSIS
GIT_REPOSITORY https://github.com/STMicroelectronics/cmsis_core/
GIT_TAG v5.6.0
GIT_TAG ${CMSIS_VERSION_TO_USE}
GIT_PROGRESS TRUE
)

Expand Down