3

I have a cmake project, which use find_package(OpenCV) to find and include opencv lib and headers.

It work well to compiler and run. But the vscode can't automatic parse cmake config to get right include path.

The screenshot is enter image description here

After some research. I find some manually config like Visual Studio Code: C++ include path

My question is: Is the any why to let vscode automatic parse cmake include_path??

My English is poor. If I explain not clearly, please let me know. Thank you!

Update:

After do CMake: configure, it resolved.

user3875388
  • 541
  • 1
  • 6
  • 19
  • 2
    "But the vscode can't automatic parse cmake config to get right include path." - There is no "cmake config" which contains include paths. These paths are obtained only when `CMakeLists.txt` is **processed** (not *parsed*, but *executed*, line by line). If VSCode doesn't process `CMakeLists.txt`, then you need to create a `compile_commands.json` file from CMake project. This file contains all compiler settings and it can be used by VSCode. [That answer] and its comment (https://stackoverflow.com/a/50360945/3440745) describes how to obtain such `.json` file. – Tsyvarev Jul 28 '20 at 07:43
  • Are you using the vscode-cmake-tools extension? When CMake is invoked through the extension, it should automatically add arguments to export compile commands. Apparantly though, compile_commands.json is not required for certain setups. See the [extension docs on setting up include-path intellisense](https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/how-to.md#set-up-include-paths-for-c-intellisense). – starball Aug 30 '22 at 19:33

1 Answers1

1

Crtl + shift + p

>Cmake configure

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 06 '22 at 03:45