microsoft / microsoft/vscode-cmake-tools

VSCODE reports symbols not found, while jump to declaration works correctly.

Open
#3,790 10 comments 0 reactions 0 assignees View on GitHub
Feature: cpptools integration more info needed
Dominant language
TypeScript
Stars
1.7k
Forks
546
Avg merge
2d 16h
Merged PRs (30d)
32

Description

### Environment

Version: 1.89.1 (user setup)
Commit: dc96b837cf6bb4af9cd736aa3af08cf8279f7685
Date: 2024-05-07T05:13:33.891Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Windows_NT x64 10.0.22621

C/C++ version: v1.20.5
CMake Tools version: v1.17.17

### Bug Summary and Steps to Reproduce

- CMake is used as a configuration provider
- CMake successfully compiles the project, `adc.c` file is part of the compilation. I can see it in the `compile_commands.json` cmake output
- I cannot find `C/C++: Log Diagnostics` command, but there is `CMake: Log Diagnostics` command, exported below
- Control+CLICK on the `#include "adc.h"` does not work, but CTRL+CLICK on the `ADC_HandleTypeDef` does open the declaration. You can see them on the picture below, lines `1` and `6`
- `adc.c` is added to the project through the subdirectory, through the interface library

![image](https://github.com/microsoft/vscode-cpptools/assets/405717/6013e7c2-1166-4f99-aed0-a739d229e48e)

CMake diagnostics
```json
{
"os": "win32",
"vscodeVersion": "1.89.1",
"cmtVersion": "1.17.17",
"configurations": [
{
"folder": "c:\\path\\to\\project",
"cmakeVersion": "3.28.1",
"configured": true,
"generator": "Ninja",
"usesPresets": true,
"compilers": {}
}
],
"cpptoolsIntegration": {
"isReady": true,
"hasCodeModel": true,
"activeBuildType": "Debug",
"buildTypesSeen": [
"Debug"
],
"requests": [
"file:///c%3A/path/to/project/source/crypto.c",
"file:///c%3A/path/to/project/source/iwdg.c",
"file:///c%3A/path/to/project/source/system_stm32u5xx.c",
"file:///c%3A/path/to/project/source/flashif.c",
"file:///c%3A/path/to/project/app/source/adc.c",
"file:///c%3A/path/to/project/lib/drivers/STM32U5xx_HAL_Driver/Inc/stm32u5xx_hal_adc.h",
"file:///c%3A/path/to/project/lib/drivers/CMSIS/Device/ST/STM32U5xx/Include/stm32u575xx.h",
"file:///c%3A/path/to/project/app/source/i2c.c",
"file:///c%3A/path/to/project/lib/drivers/STM32U5xx_HAL_Driver/Inc/stm32u5xx_hal_i2c.h"
],
"responses": [
{
"uri": "file:///c%3A/path/to/project/source/crypto.c",
"configuration": {
"includePath": [
"c:/path/to/project/include",
"c:/path/to/project/lib/drivers/cmsis/device/st/stm32u5xx/include",
"c:/path/to/project/lib/drivers/cmsis/include",
"c:/path/to/project/lib/mbedtls/include",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/inc",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/inc/legacy",
"c:/path/to/project/lib/lwprintf/src/include",
"c:/path/to/project/build/app/lwprintf/lib_inc",
"c:/path/to/project/app/include",
"c:/path/to/project/app/include/lib",
"c:/path/to/project/app/include/application",
"c:/path/to/project/lib/cjson/include"
],
"defines": [
"APP_FW_MAX_LEN=0x00060000",
"APP_FW_START_OFFSET=0x00000400",
"APP_LOAD_ADDR=0x08020000",
"BOOTLOADER_FW_MAX_LEN=0x00020000",
"BOOTLOADER_LOAD_ADDR=0x08000000",
"DEBUG",
"DOWNLOAD_SLOT_FW_MAX_LEN=0x00060000",
"DOWNLOAD_SLOT_LOAD_ADDR=0x08080000",
"IS_APP=1",
"IS_BOOTLOADER=0",
"IS_DEVELOPMENT=0",
"STM32U575xx",
"USE_FULL_LL_DRIVER",
"USE_HAL_DRIVER",
"VERSION_FW_MAJOR=0",
"VERSION_FW_MINOR=0",
"VERSION_FW_PATCH=1",
"VERSION_FW_REV=0",
"VERSION_FW_TYPE=0",
"VERSION_HW_MAJOR=0",
"VERSION_HW_MINOR=0",
"VERSION_HW_PATCH=0"
],
"compilerPath": "c:/st/stm32cubeclt/gnu-tools-for-stm32/bin/arm-none-eabi-gcc.exe",
"compilerArgs": [],
"compilerFragments": [
"-fdata-sections -ffunction-sections -Wl,--gc-sections -g -std=gnu11",
"-mthumb",
"-mcpu=cortex-m33",
"-mfpu=fpv5-sp-d16",
"-mfloat-abi=hard",
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wno-unused-parameter",
"--specs=nano.specs"
]
}
},
{
"uri": "file:///c%3A/path/to/project/source/iwdg.c",
"configuration": {
"includePath": [
"c:/path/to/project/include",
"c:/path/to/project/lib/drivers/cmsis/device/st/stm32u5xx/include",
"c:/path/to/project/lib/drivers/cmsis/include",
"c:/path/to/project/lib/mbedtls/include",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/inc",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/inc/legacy",
"c:/path/to/project/lib/lwprintf/src/include",
"c:/path/to/project/build/app/lwprintf/lib_inc",
"c:/path/to/project/app/include",
"c:/path/to/project/app/include/lib",
"c:/path/to/project/app/include/application",
"c:/path/to/project/lib/cjson/include"
],
"defines": [
"APP_FW_MAX_LEN=0x00060000",
"APP_FW_START_OFFSET=0x00000400",
"APP_LOAD_ADDR=0x08020000",
"BOOTLOADER_FW_MAX_LEN=0x00020000",
"BOOTLOADER_LOAD_ADDR=0x08000000",
"DEBUG",
"DOWNLOAD_SLOT_FW_MAX_LEN=0x00060000",
"DOWNLOAD_SLOT_LOAD_ADDR=0x08080000",
"IS_APP=1",
"IS_BOOTLOADER=0",
"IS_DEVELOPMENT=0",
"STM32U575xx",
"USE_FULL_LL_DRIVER",
"USE_HAL_DRIVER",
"VERSION_FW_MAJOR=0",
"VERSION_FW_MINOR=0",
"VERSION_FW_PATCH=1",
"VERSION_FW_REV=0",
"VERSION_FW_TYPE=0",
"VERSION_HW_MAJOR=0",
"VERSION_HW_MINOR=0",
"VERSION_HW_PATCH=0"
],
"compilerPath": "c:/st/stm32cubeclt/gnu-tools-for-stm32/bin/arm-none-eabi-gcc.exe",
"compilerArgs": [],
"compilerFragments": [
"-fdata-sections -ffunction-sections -Wl,--gc-sections -g -std=gnu11",
"-mthumb",
"-mcpu=cortex-m33",
"-mfpu=fpv5-sp-d16",
"-mfloat-abi=hard",
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wno-unused-parameter",
"--specs=nano.specs"
]
}
},
{
"uri": "file:///c%3A/path/to/project/source/system_stm32u5xx.c",
"configuration": {
"includePath": [
"c:/path/to/project/include",
"c:/path/to/project/lib/drivers/cmsis/device/st/stm32u5xx/include",
"c:/path/to/project/lib/drivers/cmsis/include",
"c:/path/to/project/lib/mbedtls/include",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/inc",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/inc/legacy",
"c:/path/to/project/lib/lwprintf/src/include",
"c:/path/to/project/build/app/lwprintf/lib_inc",
"c:/path/to/project/app/include",
"c:/path/to/project/app/include/lib",
"c:/path/to/project/app/include/application",
"c:/path/to/project/lib/cjson/include"
],
"defines": [
"APP_FW_MAX_LEN=0x00060000",
"APP_FW_START_OFFSET=0x00000400",
"APP_LOAD_ADDR=0x08020000",
"BOOTLOADER_FW_MAX_LEN=0x00020000",
"BOOTLOADER_LOAD_ADDR=0x08000000",
"DEBUG",
"DOWNLOAD_SLOT_FW_MAX_LEN=0x00060000",
"DOWNLOAD_SLOT_LOAD_ADDR=0x08080000",
"IS_APP=1",
"IS_BOOTLOADER=0",
"IS_DEVELOPMENT=0",
"STM32U575xx",
"USE_FULL_LL_DRIVER",
"USE_HAL_DRIVER",
"VERSION_FW_MAJOR=0",
"VERSION_FW_MINOR=0",
"VERSION_FW_PATCH=1",
"VERSION_FW_REV=0",
"VERSION_FW_TYPE=0",
"VERSION_HW_MAJOR=0",
"VERSION_HW_MINOR=0",
"VERSION_HW_PATCH=0"
],
"compilerPath": "c:/st/stm32cubeclt/gnu-tools-for-stm32/bin/arm-none-eabi-gcc.exe",
"compilerArgs": [],
"compilerFragments": [
"-fdata-sections -ffunction-sections -Wl,--gc-sections -g -std=gnu11",
"-mthumb",
"-mcpu=cortex-m33",
"-mfpu=fpv5-sp-d16",
"-mfloat-abi=hard",
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wno-unused-parameter",
"--specs=nano.specs"
]
}
},
{
"uri": "file:///c%3A/path/to/project/source/flashif.c",
"configuration": {
"includePath": [
"c:/path/to/project/include",
"c:/path/to/project/lib/drivers/cmsis/device/st/stm32u5xx/include",
"c:/path/to/project/lib/drivers/cmsis/include",
"c:/path/to/project/lib/mbedtls/include",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/inc",
"c:/path/to/project/lib/drivers/stm32u5xx_hal_driver/inc/legacy",
"c:/path/to/project/lib/lwprintf/src/include",
"c:/path/to/project/build/app/lwprintf/lib_inc",
"c:/path/to/project/app/include",
"c:/path/to/project/app/include/lib",
"c:/path/to/project/app/include/application",
"c:/path/to/project/lib/cjson/include"
],
"defines": [
"APP_FW_MAX_LEN=0x00060000",
"APP_FW_START_OFFSET=0x00000400",
"APP_LOAD_ADDR=0x08020000",
"BOOTLOADER_FW_MAX_LEN=0x00020000",
"BOOTLOADER_LOAD_ADDR=0x08000000",
"DEBUG",
"DOWNLOAD_SLOT_FW_MAX_LEN=0x00060000",
"DOWNLOAD_SLOT_LOAD_ADDR=0x08080000",
"IS_APP=1",
"IS_BOOTLOADER=0",
"IS_DEVELOPMENT=0",
"STM32U575xx",
"USE_FULL_LL_DRIVER",
"USE_HAL_DRIVER",
"VERSION_FW_MAJOR=0",
"VERSION_FW_MINOR=0",
"VERSION_FW_PATCH=1",
"VERSION_FW_REV=0",
"VERSION_FW_TYPE=0",
"VERSION_HW_MAJOR=0",
"VERSION_HW_MINOR=0",
"VERSION_HW_PATCH=0"
],
"compilerPath": "c:/st/stm32cubeclt/gnu-tools-for-stm32/bin/arm-none-eabi-gcc.exe",
"compilerArgs": [],
"compilerFragments": [
"-fdata-sections -ffunction-sections -Wl,--gc-sections -g -std=gnu11",
"-mthumb",
"-mcpu=cortex-m33",
"-mfpu=fpv5-sp-d16",
"-mfloat-abi=hard",
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wno-unused-parameter",
"--specs=nano.specs"
]
}
},
{
"uri": "file:///c%3A/path/to/project/app/source/adc.c",
"configuration": {
"includePath": [],
"defines": [],
"compilerPath": "c:/st/stm32cubeclt/gnu-tools-for-stm32/bin/arm-none-eabi-g++.exe",
"compilerArgs": [],
"compilerFragments": []
}
},
{
"uri": "file:///c%3A/path/to/project/app/source/i2c.c",
"configuration": {
"includePath": [],
"defines": [],
"compilerPath": "c:/st/stm32cubeclt/gnu-tools-for-stm32/bin/arm-none-eabi-g++.exe",
"compilerArgs": [],
"compilerFragments": []
}
}
],
"partialMatches": [],
"targetCount": 5,
"executablesCount": 1,
"librariesCount": 3,
"targets": [
{
"name": "app",
"type": "INTERFACE_LIBRARY"
},
{
"name": "cJSON",
"type": "INTERFACE_LIBRARY"
},
{
"name": "file_rebuilder_always",
"type": "UTILITY"
},
{
"name": "application3_firmware",
"type": "EXECUTABLE"
},
{
"name": "stm32_hal_driver",
"type": "INTERFACE_LIBRARY"
}
]
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "auto",
"configureOnOpen": true
}
]
}
```

### Configuration and Logs

```shell
{
"version": 4,
"configurations": [
{
"name": "STM32",
"configurationProvider": "ms-vscode.cmake-tools",
"intelliSenseMode": "${default}"
}
]
}
```

### Other Extensions

_No response_

### Additional context

`adc.c` and `i2c.c` seem to have empty response by CMake Tools extension. They are *added* to the project as an external library to the main application, like so:

```cmake
add_subdirectory("app" app)
target_link_libraries(${CMAKE_PROJECT_NAME} app)
```

And then `CMakeLists.txt` in the `app` folder looks like so:
```cmake
cmake_minimum_required(VERSION 3.22)

# Register core library
add_library(app INTERFACE)
target_include_directories(app INTERFACE
${CMAKE_CURRENT_LIST_DIR}/include
${CMAKE_CURRENT_LIST_DIR}/include/lib
)

# Add all
file(GLOB_RECURSE sources ${CMAKE_CURRENT_LIST_DIR}/source/*.c)
target_sources(app PUBLIC ${sources})

# Add cJSON library to the build
add_subdirectory("../lib/cJSON" cJSON)
target_link_libraries(app INTERFACE cJSON)
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the report with the CMake configuration provider and inspect the generated compile_commands.json alongside CMake: Log Diagnostics. Trace how the CMake Tools integration supplies file configuration for adc.c and adc.h, then verify that Ctrl+Click on the include resolves while the existing declaration navigation remains functional.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cmake, cpp, typescript, vscode
Domain
build-system, developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.