fsp icon indicating copy to clipboard operation
fsp copied to clipboard

[Cmake Build] How to add additional source and include paths ?

Open popsUlfr opened this issue 1 year ago • 2 comments

Hello,

I found a forum thread that pinpoints this problem but it doesn't let me reply to it so I'm posting this here

https://community.renesas.com/mcu-mpu/ra/f/forum/34016/adding-additional-source-path-and-include-path-to-visual-studio-code-build-extension

I'm running into this issue even for the RA examples that have multiple subfolders in the src/ directory. These sub folders don't get taken into account in the cmake source files when generating the configuration.

Modifying the cmake/GeneratedSrc.cmake file and adding the paths is a solution but it gets overwritten each time the configuration is regenerated.

The src/ folder in our project looks like this to separate concerns:

driver/
hci/
motor/
hal_entry.c

The contents of driver/, hci/, motor/ don't get taken into account as source and include folders in the cmake build.

There's a buildinfo.json with

  "sourcePaths": [
    "ra",
    "ra_gen",
    "src"
  ],
  "excludedFilePaths": [],
  "includePaths": [
    "ra/arm/CMSIS_5/CMSIS/Core/Include",
    "ra/fsp/inc",
    "ra/fsp/inc/api",
    "ra/fsp/inc/instances",
    "ra_cfg/fsp_cfg",
    "ra_cfg/fsp_cfg/bsp",
    "ra_gen",
    "src"
  ],

But changing anything here doesn't do anything. The file gets overwritten to defaults on configuration regeneration.

EDIT:

I wanted to amend this with a correction: source files under src/ actually do get picked up correctly thanks to GLOB_RECURSE in file(). But target_include_directories() fails to include all subfolders of src/. I can edit cmake/GeneratedSrc.cmake manually and add them like this:

target_include_directories(${PROJECT_NAME}.elf
    PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/ra/arm/CMSIS_5/CMSIS/Core/Include
    ${CMAKE_CURRENT_SOURCE_DIR}/ra/fsp/inc
    ${CMAKE_CURRENT_SOURCE_DIR}/ra/fsp/inc/api
    ${CMAKE_CURRENT_SOURCE_DIR}/ra/fsp/inc/instances
    ${CMAKE_CURRENT_SOURCE_DIR}/ra_cfg/fsp_cfg
    ${CMAKE_CURRENT_SOURCE_DIR}/ra_cfg/fsp_cfg/bsp
    ${CMAKE_CURRENT_SOURCE_DIR}/ra_gen
    ${CMAKE_CURRENT_SOURCE_DIR}/src/driver
    ${CMAKE_CURRENT_SOURCE_DIR}/src/hci
    ${CMAKE_CURRENT_SOURCE_DIR}/src/motor
    ${CMAKE_CURRENT_SOURCE_DIR}/src
    ${CMAKE_CURRENT_SOURCE_DIR}
)

And it finds everything without issue. But on the next regeneration the file will be overwritten.

popsUlfr avatar Jun 11 '24 07:06 popsUlfr

This is being internally tracked using FSPRA-3302.

renesas-brandon-hussey avatar Jun 13 '24 13:06 renesas-brandon-hussey

Thanks. I added a correction to my earlier post. Source files under src/ do get picked up correctly, it's an issue with the missing include directories.

popsUlfr avatar Jun 13 '24 15:06 popsUlfr