0

I was wondering what the difference is between using cmake and (compile_commands and compile_flags) in VSCode? I'm running into an issue where even though I've got my CMake set up correctly (builds just fine on Clion), I run into issues when trying to use the exact same code in VSCode.

I've got the offending line below

#include "palisade.h"

where palisade is installed in "/usr/local/include/palisade" and my CMake explicitly looks for it and finds it

find_package(Palisade)


I've also generated the file compile_commands.json

via cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1

but I'm still running into issues of the library not being found

IanQ
  • 1,831
  • 5
  • 20
  • 29
  • Maybe your default include path does not include `/usr/local/include` are you using CMake with VSCode using "CMake Tools extension for VS Code" or how did you setup your code in VSCode? – drescherjm Apr 29 '21 at 21:25
  • Sure, but nowhere in my config(s) am I mentioning that it is located in `/usr/local/include/` :/ – IanQ Apr 29 '21 at 21:27
  • I set it up in clion? Sorry, I don't fully understand the question. I've got `cmake tools` and `cmake` installed if that's what you're asking? – IanQ Apr 29 '21 at 21:36
  • 1
    There is an extension "CMake Tools extension for VS Code" in VSCode where you can have it build your code using CMake. If you are not doing that and used the default VSCode settings you need to configure your `tasks.json` and `c_cpp_properties.json` with your include paths and `taks.json` with your linker settings which include folders and libraries to link. – drescherjm Apr 29 '21 at 21:41

1 Answers1

0

Probably it will helps.

In main CMakeLists.txt add line

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

and in c_cpp_properties.json

"compileCommands": "${workspaceFolder}/build/compile_commands.json"

This will allow InteliSence to use the dependencies created by cmake.

RTS007
  • 11
  • 1
  • 4