Linking Conan Include to VS Code

Add set(CMAKE_EXPORT_COMPILE_COMMANDS ON) to your CMakeLists.txt (or add to cmake: cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..) so a build/compile_commands.json will be generated.

VS Code (clion, etc) can utilize this file to support auto complete:

$ cat .vscode/c_cpp_properties.json
{
    "configurations": [
    {
        "name": "Linux",
            "defines": [],
            "compilerPath": "/usr/bin/g++",
            "cStandard": "c11",
            "cppStandard": "c++14",
            "intelliSenseMode": "clang-x64",
            "compileCommands": "${workspaceFolder}/build/compile_commands.json"
    }
    ],
    "version": 4
}

After searching in the settings of VSCode, I found that you can change the path of your include in c_cpp_properties.json file that you can find in your .vscode folder

Adding the path you want in the includePath field allow you to choose your own include path


Add the following line in your project's .vscode/c_cpp_properties.json file

"includePath": ["${workspaceFolder}/**", "~/.conan/data/**"]


Conan doesn't provide an extension for vscode yet, but you can try:

https://github.com/FIREFOXCYBER/conan-tools-vs-code

It's available on marketplace.

Otherwise, you can add manually the package folder path (e.g. ~/.conan/data/package/version/package/package_id/include) in your settings.

Tags:

C++

Cmake

Conan