1、编译环境
CMake
设置环境变量Path增加D:\Program Files\CMake\bin
mingw-x64
下载WinLibs – GCC+MinGW-w64 compiler for Windows安装。
安装路径D:\mingw64
设置链接及环境变量
设置环境变量Path增加D:\mingw64\bin
2、boost编译
Navigate to install
cd d:\install
unzip to “install/boost_1_77_0”
powershell -command "Expand-Archive d:\install\boost_1_77_0.zip d:\install"
This takes about 15 minutes
cd d:\install\boost_1_77_0
Make directories for building and install
mkdir d:\boost-build
mkdir d:\install\boost_1_77_0\boost-build
mkdir d:\boost
Boost.Build setup
cd d:\install\boost_1_77_0\tools\build
prepare b2
bootstrap.bat gcc
Build boost.build with b2
b2 --prefix="d:\boost-build" install
Add d:\boost-build\bin to your session PATH variable
set PATH=%PATH%;d:\boost-build\bin
Building Boost
navigate back up to the boost unzipped root directory
cd d:\install\boost_1_77_0
Build boost with b2
b2 address-model=32,64,32_64 --build-dir="d:\install\boost_1_77_0\build" --build-type=complete --prefix="d:\boost" toolset=gcc install -j12
设置环境变量BOOST_ROOT值d:\boost
Linux Building Boost
tar zxvf boost_1_78_0.tar.gz cd boost_1_78_0 ./bootstrap.sh --with-libraries=all --with-toolset=clang ./b2 --build-type=complete --layout=versioned --prefix=/usr/local toolset=clang install -j12
备注说明:编译的时候可以选择toolset为clang,但是在VS CODE的Cmake: scan for kits要选Clang 13.0.0 x86_64-w64-windows-gnu,使用clang或者GCC 11.2.0 x86_64-w64-mingw32编译时,需要编译64位的boost库,address-model=64
{ "version": "0.2.0", "configurations": [ { "name": "BasketLosses", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/BasketLosses/BasketLosses", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "BermudanSwaption", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/BermudanSwaption/BermudanSwaption", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "Bonds", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/Bonds/Bonds", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "CallableBonds", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/CallableBonds/CallableBonds", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "CDS", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/CDS/CDS", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "ConvertibleBonds", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/ConvertibleBonds/ConvertibleBonds", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "CVAIRS", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/CVAIRS/CVAIRS", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "DiscreteHedging", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/DiscreteHedging/DiscreteHedging", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "EquityOption", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/EquityOption/EquityOption", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "FittedBondCurve", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/FittedBondCurve/FittedBondCurve", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "FRA", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/FRA/FRA", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "Gaussian1dModels", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/Gaussian1dModels/Gaussian1dModels", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "GlobalOptimizer", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/GlobalOptimizer/GlobalOptimizer", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "LatentModel", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/LatentModel/LatentModel", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "MarketModels", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/MarketModels/MarketModels", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "MulticurveBootstrapping", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/MulticurveBootstrapping/MulticurveBootstrapping", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "MultidimIntegral", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/MultidimIntegral/MultidimIntegral", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "Replication", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/Replication/Replication", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "Repo", "type":"lldb", "request": "launch", "program": "${workspaceFolder}/build/Examples/Repo/Repo", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", "miDebuggerPath": "/usr/bin/lldb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] } ] }
{ "version": "0.2.0", "configurations": [ { "name": "BasketLosses", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/BasketLosses/BasketLosses", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "BermudanSwaption", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/BermudanSwaption/BermudanSwaption", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "Bonds", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/Bonds/Bonds", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "CallableBonds", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/CallableBonds/CallableBonds", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "CDS", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/CDS/CDS", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "ConvertibleBonds", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/ConvertibleBonds/ConvertibleBonds", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "CVAIRS", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/CVAIRS/CVAIRS", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "DiscreteHedging", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/DiscreteHedging/DiscreteHedging", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "EquityOption", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/EquityOption/EquityOption", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "FittedBondCurve", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/FittedBondCurve/FittedBondCurve", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "FRA", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/FRA/FRA", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "Gaussian1dModels", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/Gaussian1dModels/Gaussian1dModels", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "GlobalOptimizer", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/GlobalOptimizer/GlobalOptimizer", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "LatentModel", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/LatentModel/LatentModel", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "MarketModels", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/MarketModels/MarketModels", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "MulticurveBootstrapping", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/MulticurveBootstrapping/MulticurveBootstrapping", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "MultidimIntegral", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/MultidimIntegral/MultidimIntegral", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "Replication", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/Replication/Replication", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] }, { "name": "Repo", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/Repo/Repo", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ] } ] }
3、IDE设置
vscode安装
vscode插件
C/C++ C/C++ Extension Pack CMake Tools全部选中微软出品
CTRL+SHIFT+p –>cmake:scan for kits选择mingw-w64中的编译器
如果在扫描后仍选择不到mingw-w64的编译器,可删除QuantLib/CMakePresets.json文件,并重新扫描获得编译套件。
vscode打开quantlib代码所在目录,会自动配置cmake项目。
新增tasks.json和launch.json文件用于自动构建和案例执行。
tasks.json(LINUX系统下编译的tasks.json,后续使用VS CODE + WSL2大杀器)
GCC工具的编译任务配置文件:
{ // 这里配置了三个Task "tasks": [ // Task 1:生成build文件夹 // Task 1:生成build文件夹 { "type": "shell", // 这里决定了task的类型,shell类型就是在命令行里运行command的命令,还有一种类型是“process”,这里就不介绍了 "label": "mk_build", // task的名字 "command": "mkdir", // 需要被运行的命令 "args": [ "-p", "build" ], // 传递给command的参数 "options": { "cwd": "${workspaceFolder}", }, }, // Task 3:运行make-clean { "type": "shell", "label": "clean-debug", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Debug", "--parallel", "12", "--target", "clean" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [] }, // Task 2:运行cmake-debug { "type": "shell", "label": "cmake-debug", "command": "cmake", "args": [ "--no-warn-unused-cli", "-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE", //"-DCMAKE_BUILD_TYPE:STRING=Debug", "-DCMAKE_BUILD_TYPE=Debug", "-DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc", "-DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++", "-DCMAKE_C_FLAGS=-g", "-DCMAKE_CXX_FLAGS=-g -Wall -O0 -std=c++11 -pthread", "TIMEOUT", "3600", "-G", "Unix Makefiles", // 这里必须定义生成器,否则默认cmake生成的是VS Studio可编译的工程 "${workspaceFolder}" ], "options": { "cwd": "${workspaceFolder}/build", // 工作路径,就是说cmake的输出都会放在${workspaceFolder}/build文件夹下 }, "problemMatcher": [], "group": { "kind": "build", "isDefault": true }, "dependsOn": ["mk_build"] }, // Task 3:运行build ql_library debug { "type": "shell", "label": "buildlib-debug", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Debug", "--parallel", "12", "--target", "ql_library" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "cmake-debug" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 4:运行build test { "type": "shell", "label": "buildtest-debug", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Debug", "--parallel", "12", "--target", "test" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "buildtestmain-debug" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 5:运行build all { "type": "shell", "label": "buildall-debug", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Debug", "--parallel", "12", "--target", "all" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "cmake-debug" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 3:运行make-clean { "type": "shell", "label": "clean-release", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Release", "--parallel", "12", "--target", "clean" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [] }, // Task 2:运行cmake-debug { "type": "shell", "label": "cmake-release", "command": "cmake", "args": [ "--no-warn-unused-cli", "-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE", //"-DCMAKE_BUILD_TYPE:STRING=Debug", "-DCMAKE_BUILD_TYPE=Release", "-DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc", "-DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++", "-DCMAKE_C_FLAGS=-g", "-DCMAKE_CXX_FLAGS=-g -Wall -O0 -std=c++11 -pthread", "TIMEOUT", "3600", "-G", "Unix Makefiles", // 这里必须定义生成器,否则默认cmake生成的是VS Studio可编译的工程 "${workspaceFolder}" ], "options": { "cwd": "${workspaceFolder}/build", // 工作路径,就是说cmake的输出都会放在${workspaceFolder}/build文件夹下 }, "problemMatcher": [], "group": { "kind": "build", "isDefault": true }, "dependsOn": [ "mk_build" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 3:运行build ql_library release { "type": "shell", "label": "buildlib-release", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Release", "--parallel", "12", "--target", "ql_library" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "cmake-release" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 4:运行build test { "type": "shell", "label": "buildtest-release", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Release", "--parallel", "12", "--target", "test" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "buildtestmain-release" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 5:运行build all { "type": "shell", "label": "buildall-release", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Release", "--parallel", "12", "--target", "all" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "cmake-release" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 6:运行build ql_test_suite release { "type": "shell", "label": "buildtestsuite-release", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Release", "--parallel", "12", "--target", "ql_test_suite" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "buildlib-release" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 7:运行build ql_test_suite debug { "type": "shell", "label": "buildtestsuite-debug", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Debug", "--parallel", "12", "--target", "ql_test_suite" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "buildlib-debug" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 7:运行build ql_test_suite debug { "type": "shell", "label": "buildtestmain-debug", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Debug", "--parallel", "12", "--target", "ql_unit_test_main" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "buildtestsuite-debug" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 7:运行build ql_test_suite debug { "type": "shell", "label": "buildtestmain-release", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Release", "--parallel", "12", "--target", "ql_unit_test_main" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "buildtestsuite-release" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] } ], "version": "2.0.0" }
launch.json(LINUX系统下编译的tasks.json,后续使用VS CODE + WSL2大杀器)
{ "version": "0.2.0", "configurations": [ { "name": "BasketLosses", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/BasketLosses/BasketLosses", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], }, { "name": "BermudanSwaption", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/BermudanSwaption/BermudanSwaption", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], }, { "name": "Bonds", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/Bonds/Bonds", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], }, { "name": "CallableBonds", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/CallableBonds/CallableBonds", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], }, { "name": "CDS", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/CDS/CDS", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], }, { "name": "ConvertibleBonds", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/ConvertibleBonds/ConvertibleBonds", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], }, { "name": "CVAIRS", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/CVAIRS/CVAIRS", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], }, { "name": "DiscreteHedging", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/DiscreteHedging/DiscreteHedging", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], }, { "name": "EquityOption", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/EquityOption/EquityOption", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], }, { "name": "FittedBondCurve", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/FittedBondCurve/FittedBondCurve", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], }, { "name": "FRA", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/FRA/FRA", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], }, { "name": "Gaussian1dModels", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/Gaussian1dModels/Gaussian1dModels", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], }, { "name": "GlobalOptimizer", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/GlobalOptimizer/GlobalOptimizer", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], }, { "name": "LatentModel", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/LatentModel/LatentModel", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], }, { "name": "MarketModels", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/MarketModels/MarketModels", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], }, { "name": "MulticurveBootstrapping", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/MulticurveBootstrapping/MulticurveBootstrapping", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], }, { "name": "MultidimIntegral", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/MultidimIntegral/MultidimIntegral", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], }, { "name": "Replication", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/Replication/Replication", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], }, { "name": "Repo", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/Examples/Repo/Repo", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "console": "externalTerminal", "MIMode": "gdb", "miDebuggerPath": "/usr/bin/gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true, "preLaunchTask": "test" } ], } ] }
CLANG工具的编译任务配置文件:
{ // 这里配置了三个Task "tasks": [ // Task 1:生成build文件夹 // Task 1:生成build文件夹 { "type": "shell", // 这里决定了task的类型,shell类型就是在命令行里运行command的命令,还有一种类型是“process”,这里就不介绍了 "label": "mk_build", // task的名字 "command": "mkdir", // 需要被运行的命令 "args": [ "-p", "build" ], // 传递给command的参数 "options": { "cwd": "${workspaceFolder}", }, }, // Task 3:运行make-clean { "type": "shell", "label": "clean-debug", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Debug", "--parallel", "12", "--target", "clean" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [] }, // Task 2:运行cmake-debug { "type": "shell", "label": "cmake-debug", "command": "cmake", "args": [ "--no-warn-unused-cli", "-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE", //"-DCMAKE_BUILD_TYPE:STRING=Debug", "-DCMAKE_BUILD_TYPE=Debug", "-DCMAKE_C_COMPILER:FILEPATH=/usr/lib64/ccache/clang++", "-DCMAKE_CXX_COMPILER:FILEPATH=/usr/lib64/ccache/clang++", "-DCMAKE_MAKE_PROGRAM = ${CMAKE_MAKE_PROGRAM} -j 12", "-DCMAKE_C_FLAGS=-g", "parallelizeBuildables = YES", "-DCMAKE_CXX_FLAGS=-g -Wall -O0 -std=c++11 -pthread", "TIMEOUT", "3600", "-G", "Unix Makefiles", // 这里必须定义生成器,否则默认cmake生成的是VS Studio可编译的工程 "${workspaceFolder}" ], "options": { "cwd": "${workspaceFolder}/build", // 工作路径,就是说cmake的输出都会放在${workspaceFolder}/build文件夹下 }, "problemMatcher": [], "group": { "kind": "build", "isDefault": true }, "dependsOn": ["mk_build"] }, // Task 3:运行build ql_library debug { "type": "shell", "label": "buildlib-debug", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Debug", "--parallel", "12", "--target", "ql_library" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "cmake-debug" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 4:运行build test { "type": "shell", "label": "buildtest-debug", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Debug", "--parallel", "12", "--target", "test" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "buildtestmain-debug" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 5:运行build all { "type": "shell", "label": "buildall-debug", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Debug", "--parallel", "12", "--target", "all" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "cmake-debug" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 3:运行make-clean { "type": "shell", "label": "clean-release", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Release", "--parallel", "12", "--target", "clean" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [] }, // Task 2:运行cmake-debug { "type": "shell", "label": "cmake-release", "command": "cmake", "args": [ "--no-warn-unused-cli", "-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE", //"-DCMAKE_BUILD_TYPE:STRING=Debug", "-DCMAKE_BUILD_TYPE=Release", "-DCMAKE_C_COMPILER:FILEPATH=/usr/lib64/ccache/clang++", "-DCMAKE_CXX_COMPILER:FILEPATH=/usr/lib64/ccache/clang++", "-DCMAKE_C_FLAGS=-g", "-DCMAKE_MAKE_PROGRAM = ${CMAKE_MAKE_PROGRAM} -j 12", "parallelizeBuildables = YES", "-DCMAKE_CXX_FLAGS=-g -Wall -O0 -std=c++11 -pthread", "TIMEOUT", "3600", "-G", "Unix Makefiles", // 这里必须定义生成器,否则默认cmake生成的是VS Studio可编译的工程 "${workspaceFolder}" ], "options": { "cwd": "${workspaceFolder}/build", // 工作路径,就是说cmake的输出都会放在${workspaceFolder}/build文件夹下 }, "problemMatcher": [], "group": { "kind": "build", "isDefault": true }, "dependsOn": [ "mk_build" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 3:运行build ql_library release { "type": "shell", "label": "buildlib-release", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Release", "--parallel", "12", "--target", "ql_library" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "cmake-release" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 4:运行build test { "type": "shell", "label": "buildtest-release", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Release", "--parallel", "12", "--target", "test" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "buildtestmain-release" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 5:运行build all { "type": "shell", "label": "buildall-release", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Release", "--parallel", "12", "--target", "all" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "cmake-release" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 6:运行build ql_test_suite release { "type": "shell", "label": "buildtestsuite-release", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Release", "--parallel", "12", "--target", "ql_test_suite" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "buildlib-release" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 7:运行build ql_test_suite debug { "type": "shell", "label": "buildtestsuite-debug", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Debug", "--parallel", "12", "--target", "ql_test_suite" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "buildlib-debug" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 7:运行build ql_test_suite debug { "type": "shell", "label": "buildtestmain-debug", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Debug", "--parallel", "12", "--target", "ql_unit_test_main" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "buildtestsuite-debug" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] }, // Task 7:运行build ql_test_suite debug { "type": "shell", "label": "buildtestmain-release", "command": "cmake", "args": [ "--build", "${workspaceFolder}/build/", "--config", "Release", "--parallel", "12", "--target", "ql_unit_test_main" ], "options": { "cwd": "${workspaceFolder}/build", }, "problemMatcher": [], "group": { "kind": "build", // 这里说明这个任务时输入"build"类型的,也就是说明,这是一个生成任务 "isDefault": true }, "dependsOn": [ "buildtestsuite-release" // 这里设置,说明了这个任务一定要在Task “cmake”执行之后方可执行 ] } ], "version": "2.0.0" }
CCACHE支持:
1、安装ccache步骤略;
2、检查软链接是否创建
#在ccache安装完后,如果/usr/lib64/ccache/下已经有创建软连接该步骤跳过 ln -s /usr/bin/ccache /usr/lib64/ccache/clang ln -s /usr/bin/ccache /usr/lib64/ccache/clang++
3、修改tasks.json
"-DCMAKE_C_COMPILER:FILEPATH=/usr/lib64/ccache/clang++", "-DCMAKE_CXX_COMPILER:FILEPATH=/usr/lib64/ccache/clang++",
4、ccache相关命令
#清空缓存 ccache -C #检查缓存数量 ccache -s
CMAKE并行编译
#环境变量中增加配置 export MAKEFLAGS=-j$(($(grep -c ^processor /proc/cpuinfo) - 1))
备注:可使用WINDOWS下的VSCODE + WSL2编译,良心软!!!!!