我通常使用VSCode+CMake开发C++的程序,但是即使我在CMakeLists.txt中配置了Include的路径VSCode在#include时不但不自动补全路径还显示红色的波浪下划线。为了让VSCode能够知道Include的路径还需要针对当前工程配置.vscode/c_cpp_properties.json文件,可以通过shift+command+P然后选择C/C++: Edit Configurations(JSON)生成该文件。
然后配置c_cpp_properties.json中的includePath字段:

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**",
                "${workspaceFolder}/glm",
                "${workspaceFolder}/glad",
            ],
            "defines": [],
            "macFrameworkPath": [],
            "compilerPath": "/usr/local/bin/gcc-8",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

配置后导入头文件:(例如demo.cpp在根目录下)

// This is demo.cpp
#include "glad/include/glad.h"
#include "glm/glm.hpp"

这时候就能够智能补全,红色波浪下划线也消失了。