vscode intellisense can't find header files included in cmake project

Viewed 3753

I have a cmake project that has:
A static library called Project1
A static library called Project2 that depends on Project1
An executable called Project3 that depends on both libraries

Everything is working as expected (makefiles, it is building and running normally, ...), but the problem is that vscode intellisense just does not find the header files in the folders specified using target_include_directories on each subdirectory.

The intellisense can find the default headers (iostream, vector, etc).

example: https://i.stack.imgur.com/XeVGW.jpg

I also tried putting the include directories in c_cpp_properties.json:

"includePath": [
    "${workspaceFolder}/Project1/src/**",
    "${workspaceFolder}/Project2/src/**",
    "${workspaceFolder}/Project3/src/**"
]

But it also didn't work.

I also tried putting the headers/sources manually in all CMakeLists.txt files (without using file(GLOB_RECURSE)) But it also didn't work.

This project is just a small example I made to show the problem, but it also happens in all the other projects.

The project can be found here: https://github.com/gabrielmaia2/CmakeTest

1 Answers

Found it. The extension "C/C++ Clang Command Adapter" was showing the errors because clang was not configured. I just disabled it (since I'm not using it) and now its working as expected.

Related