-
Notifications
You must be signed in to change notification settings - Fork 335
Description
Overview
I’d like to contribute CMake integration for this repository, enabling projects that use CMake to easily consume it as a dependency.
Proposal
Find Package Support
Add support to allow this repository to be discovered via CMake’s find_package()
command. This involves providing a Find<package>.cmake
module file, where <package>
is a name representing this repository.
For example: FindSTM32CubeH7.cmake
.
Usage
Fetching the Repository
Consuming projects would include the following in their CMake configuration:
FetchContent_Declare(
stm32cubeH7
GIT_REPOSITORY git@github.com:STMicroelectronics/STM32CubeH7.git
GIT_TAG v1.12.1
GIT_SUBMODULES_RECURSE TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(stm32cubeH7)
list(APPEND CMAKE_MODULE_PATH ${stm32cubeH7_SOURCE_DIR})
This fetches the repository (including submodules) into the CMake build directory.
The CMAKE_MODULE_PATH
is then updated to include the repository path, so CMake can find the custom FindSTM32CubeH7.cmake
file during find_package()
calls.
Finding the Package
Once fetched, the consuming project would locate and request specific components using:
find_package(
STM32CubeH7
COMPONENTS
rcc
gpio
i2c
usb_hid_device
REQUIRED
)
This locates FindSTM32CubeH7.cmake
and triggers additional includes for CMake files within this repository that manage locating source files for the requested components.
In the example above, the consuming project requests the rcc
, gpio
, i2c
, and usb_hid_device
drivers. The added CMake support will identify the relevant source files and configure them into a library for the consuming project.
Linking
Finally, the consuming project would link against the created library using:
target_link_libraries(<target> PRIVATE stm32cubeh7)
Where <target>
is the name of the executable or library target defined by the consuming project via add_executable()
or add_library()
.
Summary
This proposal improves CMake interoperability for this repository, making it easier to integrate into modern, CMake-based embedded projects via standard tooling like FetchContent
and find_package()
.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status