microsoft / vscode-cpptools

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

External dependency not found, but found #10216

Open cdecompilador opened 1 year ago

cdecompilador commented 1 year ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary: It marks external dependency headers at not found, but still you can jump to them and on the logs seems like the compile commands include them, but with wrong case Let's do a simple example with external dependency, with cmake and using git submodules: CMakeLists.txt

cmake_minimum_required(VERSION 3.0.0)
project(MyProject VERSION 0.1.0)

add_subdirectory("third_party/fmt")

add_executable(MyProject Main.cpp)
target_link_libraries(MyProject
    fmt)

Remember to clone the fmt library on third_party folder main.cpp

#include <fmt/core.h>

int 
main(int argc, char** argv) 
{
    fmt::print("Hello World");
    return 0;
}

If you compile this with cmake:

cmake -B build
cmake --build build

It works just fine, but cpptools is having trouble resolving <fmt/core.h> image

Here are the logs:

-------- Diagnostics - 1/12/2022, 17:54:34
Version: 1.13.5
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "windowsSdkVersion": "10.0.22000.0",
    "compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "windows-msvc-x64",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "compilerPathIsExplicit": false,
    "configurationProvider": "ms-vscode.cmake-tools",
    "browse": {
        "path": [
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Custom browse configuration: 
{
    "browsePath": [
        "c:/users/nnyag/documents/vs-test/deps/fmt/include",
        "c:/users/nnyag/documents/vs-test",
        "c:/users/nnyag/documents/vs-test/deps/fmt/src",
        "c:/users/nnyag/documents/vs-test/deps/fmt/include/fmt",
        "c:/users/nnyag/documents/vs-test/deps/fmt"
    ],
    "compilerPath": "c:/strawberry/c/bin/g++.exe",
    "compilerArgs": [],
    "compilerFragments": [
        "-g"
    ]
}
Custom configurations:
[ C:\Users\nnyag\Documents\vs-test\Main.cpp ]
{
    "includePath": [
        "c:/users/nnyag/documents/vs-test/deps/fmt/include"
    ],
    "defines": [],
    "compilerPath": "c:/strawberry/c/bin/g++.exe",
    "compilerArgs": [],
    "compilerFragments": [
        "-g"
    ]
}

There is a clear mistake here

The include paths contains the path with all the letters lowercase: image

This error also occurs with clangd so it might be related to the editor itself, also can't be the cmake tools extension, since I've tried generating the compile_commands.json manually (also the compile commands contains the proper path)

browntarik commented 1 year ago

Thank you for your issue, we are currently looking into this.

browntarik commented 1 year ago

After using your example, I was unable to reproduce your error. It seems there may be another difference between your environment and mine. Could you include all of your log information by setting the C/C++ Logging Level to Debug and copying the output? image