Windows 10
VSCode(https://code.visualstudio.com/)
VSCode插件 C/C++(ms-vscode.cpptools)
VSCode插件 CMake(twxs.cmake)
VSCode插件 CMake Tools(ms-vscode.cmake-tools)
VSCode插件 Visual Studio IntelliCode(visualstudioexptteam.vscodeintellicode)
Microsoft C++ 生成工具 独立 MSVC 编译器、库和脚本(https://visualstudio.microsoft.com/zh-hans/visual-cpp-build-tools/)
Microsoft C++ 生成工具
工程目录如下
CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(Rasterizer)
set(OpenCV_DIR "D:/opencv/build/x64/vc15/lib")
find_package(OpenCV REQUIRED)
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
set(CMAKE_CXX_STANDARD 17)
include_directories(D:/Eigen3/include D:/opencv/build/include)
add_executable(Rasterizer main.cpp rasterizer.hpp rasterizer.cpp global.hpp Triangle.hpp Triangle.cpp Texture.hpp Texture.cpp Shader.hpp OBJ_Loader.h)
target_link_libraries(Rasterizer ${OpenCV_LIBS})
#target_compile_options(Rasterizer PUBLIC -Wall -Wextra -pedantic)
进入工程目录, SHIFT+右键, 通过Code打开,自动弹出窗口(没有也不影响)
CTRL+SHIFT+P 打开命令面板, 搜索 cmake scan, 选择
CTRL+SHIFT+P 打开命令面板, 搜索 cmake select a kit, 选择
根据需求, 选择工具集
CTRL+SHIFT+P 打开命令面板, 搜索 cmake configure, 选择
输出
选择允许
CTRL+SHIFT+P 打开命令面板, 搜索 cmake build, 选择
输出
创建文件
launch.json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) 启动",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/build/Debug/Rasterizer.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"preLaunchTask": "cmake build active file"
}
]
}
tasks.json
{
"tasks": [
{
"type": "shell",
"label": "cmake build active file",
"command": "cmake --build ${workspaceFolder}\\build --config Debug --target ALL_BUILD -- /maxcpucount:8",
"args": [
],
"options": {
"cwd": "C:/msys64/mingw64/bin"
}
}
],
"version": "2.0.0"
}
其中, command可以通过按F7查看cmake命令, 再进行拷贝, 如
最后 F5 ...................................................................................
详细资料和其他工具集设置参考
https://code.visualstudio.com/docs/cpp/config-msvc