pi_pico/cmake/cmake_config/sources_config.cmake
Mohamed Salem 3687e48684 Add complete firmware stack with USB-CDC proof of life
Dockerized build system (Dockerfile, docker-compose, build.sh) with
Pico SDK cross-compilation. Modular CMake split into project_config,
mcu_config, and sources_config under cmake/. Component architecture
following inc/prg/cfg convention: STD_TYPES, MCU_USB, HAL_COM,
APP_CLSW, SYS_ECU. Full call chain SYS_ECU -> APP_CLSW -> HAL_COM
-> MCU_USB verified end-to-end on RP2040-Zero hardware over USB-CDC.
Includes flash.sh for automated .uf2 flashing on macOS and
devcontainer config for VS Code.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 18:23:24 +02:00

62 lines
2.8 KiB
CMake

# ============================================================================
# sources_config.cmake
# ----------------------------------------------------------------------------
# Collects the list of source files and include directories for the build.
# Does NOT declare the executable - the top-level CMakeLists.txt handles
# add_executable() so the build target is visible in one obvious place.
#
# Exported variables:
# PROJECT_SOURCES - list of every .c file under src/
# PROJECT_INCLUDE_DIRS - list of include paths for each component
# ============================================================================
# NOTE: all source/header paths below are rooted at PROJECT_ROOT_DIR, which
# the top-level CMakeLists.txt computes as the parent of its own directory
# (i.e. one level above cmake/). We do NOT use CMAKE_SOURCE_DIR here because
# that variable points at the cmake/ folder itself, not at the project root.
# Recursively collect every .c file under src/. CONFIGURE_DEPENDS makes
# CMake re-check the glob on every build, so newly added .c files are
# picked up without having to manually re-run cmake. The trade-off is a
# tiny build-time stat check on each file, which is well worth it for a
# small project where we add files often.
file(GLOB_RECURSE PROJECT_SOURCES CONFIGURE_DEPENDS
"${PROJECT_ROOT_DIR}/src/*.c")
# Every component follows the same folder convention:
# inc/ - public API headers (safe for any other component to include)
# prg/ - private headers and implementation files (component-internal)
# cfg/ - configuration headers and constants
#
# All three are added to the include path here so #include "MCU_UART.h"
# etc. resolves regardless of which translation unit is doing the include.
set(PROJECT_INCLUDE_DIRS
# Shared library layer - fundamental types used by every component
${PROJECT_ROOT_DIR}/src/STD_TYPES/inc
# MCU layer - hardware abstraction for the RP2040 UART peripheral
${PROJECT_ROOT_DIR}/src/MCU_UART/inc
${PROJECT_ROOT_DIR}/src/MCU_UART/prg
${PROJECT_ROOT_DIR}/src/MCU_UART/cfg
# MCU layer - hardware abstraction for the RP2040 USB-CDC peripheral
# (the Pico appears as a virtual serial port on the host computer)
${PROJECT_ROOT_DIR}/src/MCU_USB/inc
${PROJECT_ROOT_DIR}/src/MCU_USB/prg
${PROJECT_ROOT_DIR}/src/MCU_USB/cfg
# HAL layer - transport-agnostic communication abstraction that
# dispatches to MCU_UART, MCU_USB, or both depending on configuration
${PROJECT_ROOT_DIR}/src/HAL_COM/inc
${PROJECT_ROOT_DIR}/src/HAL_COM/prg
${PROJECT_ROOT_DIR}/src/HAL_COM/cfg
# Application layer - color switcher application logic
${PROJECT_ROOT_DIR}/src/APP_CLSW/inc
${PROJECT_ROOT_DIR}/src/APP_CLSW/prg
${PROJECT_ROOT_DIR}/src/APP_CLSW/cfg
# Application layer - system ECU / top-level orchestrator
${PROJECT_ROOT_DIR}/src/SYS_ECU/prg
)