microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.53k stars 1.56k forks source link

system includes from cmake and not pass as system #12417

Closed clshortfuse closed 4 months ago

clshortfuse commented 4 months ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary:

When using a cmake configuration that has a SYSTEM that inclusion isn't passed as system. This causes clang-tidy to analyze all external repositories.

Steps to reproduce:

  1. Create a cmake configuration that uses:
target_include_directories(${TARGET} SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/external/${REPO})
  1. Trace configuration passed

  2. See as clang/clang-tidy passes the include as not system, on build or tidy

Expected behavior:

System includes in cmake should be passed as system includes to clang/clang-tidy

Configuration and Logs

Custom configurations received:

{
  uri: {WORKSPACE_FILE}
  config: {
  "includePath": [
    "{WORKSPACE}/external/{REPO}"
  ],
  "compilerPath": "c:/program files/microsoft visual studio/2022/community/vc/tools/msvc/14.40.33807/bin/hostx64/x64/cl.exe",
  "compilerArgs": [],
  "compilerFragments": [
    "/DWIN32 /D_WINDOWS /GR /EHsc /O2 /Ob2 /DNDEBUG -std:c++20 -MD"
  ]
}
C:\Program Files\LLVM\bin\clang-tidy.exe
--export-fixes={LOCALAPPDATA}\Temp\{11890908921244206252}\fixes31200.yaml
--quiet
--use-color=false
{WORKSPACE}/src/file.cpp
--
-std=c++20
-xc++
-Wno-pragma-pack
-Wno-pragma-once-outside-header
-Ddevkit_EXPORTS
-DWIN32
-D_WINDOWS
-DNDEBUG
-D_MT
-D_DLL
-I{WORKSPACE}/external/{REPO}
-isystemC:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.40.33807/include
-isystemC:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.40.33807/atlmfc/include
-isystemC:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um
-isystemC:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/ucrt
-isystemC:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/shared
-isystemC:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/winrt
-isystemC:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/cppwinrt

Other Extensions

Additional context

Colengms commented 4 months ago

Hi @clshortfuse . This looks like a known issue with CMake Tools: https://github.com/microsoft/vscode-cmake-tools/issues/3240 . Could you comment on that issue with your specific repro?

The custom configuration provider API unfortunately does not currently differentiate between system and user (or other types of) includes in the IncludePath field. However, these could be passed by the provider in the compiler arguments field.