VS Code can't find FetchContent headers without compile_commands
@tylerd▲ 0 net votes
In a CMake project that pulls dependencies such as nlohmann/json via FetchContent, the VS Code C/C++ extension reports "cannot open source file nlohmann/json.hpp" and disables squiggles. The headers only exist under build/_deps after configuring, and the default includePath doesn't know about them. The code still builds. Configure with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON (or let the CMake Tools extension configure) and point the extension at build/compile_commands.json so IntelliSense picks up the fetched include paths.