This document describes the configurable CMake build system that allows
consumers (HAL layers, standalone projects, core examples) to select exactly
which drivers, handlers, and utilities are compiled into their build.
Design Goals
Goal
How It’s Achieved
Lean builds
Each driver/handler is opt-in — only enabled features are compiled
Zero duplication
HAL CMakeLists.txt no longer re-enumerate core source files
Driver delegation
Each external driver’s build_settings.cmake is the single source of truth for its sources and includes
Auto dependencies
Enabling a driver automatically enables the bus interfaces it needs (e.g., TMC9660 → UART)
Familiar pattern
Follows the same 3-layer CMake contract used by all HardFOC external drivers
┌──────────────────────────────────────────────────────────────┐
│ core/cmake/hf_core_build_settings.cmake │
│ (Configurable Source/Include Collector) │
│ │
│ • Feature toggles (HF_CORE_ENABLE_xxx) │
│ • Auto-enables bus dependencies │
│ • Includes each driver's build_settings.cmake │
│ • Collects HF_CORE_SOURCES, HF_CORE_INCLUDE_DIRS, │
│ HF_CORE_IDF_REQUIRES, HF_CORE_COMPILE_DEFINITIONS │
└────────────┬────────────────────────────┬────────────────────┘
│ │
┌────────────▼───────────────┐ ┌──────────▼──────────────────┐
│ Core ESP-IDF Wrapper │ │ HAL CMakeLists.txt │
│ (examples/esp32/ │ │ (hf-hal-vortex-v1/ etc.) │
│ components/hf_core/) │ │ │
│ │ │ • Enables feature subset │
│ • Enables ALL features │ │ • Includes build settings │
│ • Includes build settings │ │ • Adds HAL-specific API + │
│ • idf_component_register()│ │ managers on top │
└────────────────────────────┘ └─────────────────────────────┘
Usage
1. Set Feature Toggles
Before including the build settings, set variables for the features you need:
1
2
3
4
5
6
7
8
9
10
# Enable only what your HAL usesset(HF_CORE_ENABLE_TMC9660 ON)set(HF_CORE_ENABLE_PCAL95555 ON)set(HF_CORE_ENABLE_AS5047U ON)set(HF_CORE_ENABLE_BNO08X ON)set(HF_CORE_ENABLE_NTC_THERMISTOR ON)set(HF_CORE_ENABLE_WS2812 ON)set(HF_CORE_ENABLE_LOGGER ON)set(HF_CORE_ENABLE_UTILS_CANOPEN ON)set(HF_CORE_ENABLE_CAN ON)