Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking Conan Include to VS Code

Tags:

c++

cmake

conan

I'm currently using Conan on a C++ project using sqlite_orm as a dependency.

When using my personal include (like myClass.hpp for example) Visual Studio Code is able to provide auto-completion but with Conan's include, no auto-completion is possible.

I'm looking for a way to link the include path of Conan to my VSCode, any idea?

like image 909
Bibas Avatar asked Sep 24 '19 10:09

Bibas


People also ask

How do I use Conan with Visual Studio?

Use Conan Extension for Visual Studio To use this extension you will need a conanfile. txt or conanfile.py in your Visual Studio project declaring the requirements of your project. Conan will download them from the configured remotes (or build them if binaries are not available), the extension will generate the .

How do you use custom input in VS Code?

Go to settings (ctrl+,) -> Search settings -> : Code-runner : Run in terminal - Check this and you will be able to run the code directly in the terminal which takes input. :) Show activity on this post. Make sure you have code runner installed on your VS code. By default it remains unchecked.


2 Answers

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

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

like image 164
CodingMedalist Avatar answered Nov 15 '22 22:11

CodingMedalist


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
}
like image 25
dvorak4tzx Avatar answered Nov 15 '22 21:11

dvorak4tzx