Skip to content

feat: allow user to define custom CMSIS version via CMake cache variable #352

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
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 ?

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