Advanced Customization Guide
May 20, 2026 · View on GitHub
For experienced users who want to customize build tasks and configurations.
Task Structure Overview
All tasks are organized in .vscode/tasks.json with three main categories:
1. CMake Configuration Tasks (Initial Setup)
CMake: Configure DebugCMake: Configure Release
These prepare the build environment and must run before compilation.
2. Compilation & Running LibMan (Main Development)
Organized in a dropdown group with prefix Compilation & Running LibMan:
Build Debug- Compiles in Debug modeBuild Release- Compiles in Release modeRun Debug- Runs the debug executableRun Release- Runs the release executableBuild & Run Debug- Combined build and runBuild & Run Release- Combined build and run
3. Tests (Testing Group)
Organized in a dropdown group with prefix Tests:
Configure Tests- One-time CMake setup for testsBuild Tests- Compiles test suiteRun All Tests- Executes tests via CTest
Customizing Tasks
Changing Compiler
Edit .vscode/settings.json:
"C_Cpp.default.compilerPath": "C:/path/to/your/compiler/bin/c++.exe"
Adjusting Parallel Build Jobs
In .vscode/tasks.json, find the build tasks and change -j4 to your desired count:
"args": [
"--build", "build",
"--config", "Debug",
"-j8" // Change 4 to 8 or desired number
]
Recommendation:
-j2: Slow systems or 2-core CPU-j4: Standard (recommended for most systems)-j8: Powerful workstations (8+ cores)
Adding a New Build Configuration
Example: Adding an "AddressSanitizer" debug build
- Copy a build task in
.vscode/tasks.json - Modify the label and args:
{
"label": "Compilation & Running LibMan: Build AddressSanitizer",
"type": "shell",
"command": "cmake",
"args": [
"-B", "build-asan",
"-G", "MinGW Makefiles",
"-DCMAKE_BUILD_TYPE=Debug",
"-DCMAKE_CXX_FLAGS=-fsanitize=address"
],
"options": { "cwd": "${workspaceFolder}" },
"group": { "kind": "build", "isDefault": false },
"problemMatcher": "$gcc"
}
Using a Different Generator
Change generator in all CMake tasks:
"-G", "Ninja" // Replace "MinGW Makefiles"
Available generators for Windows:
- "MinGW Makefiles" (current)
- "Ninja" (requires Ninja installed)
- "NMake Makefiles" (requires NMake/MSVC)
- "Visual Studio 16 2019"
- "Visual Studio 17 2022"
Task Execution Methods
Method 1: Quick Build (Recommended)
Press Ctrl+Shift+B → Select from dropdown → Press Enter
Method 2: Command Palette
- Press
Ctrl+Shift+P - Type: "Tasks: Run Task"
- Select desired task
- Press Enter
Method 3: Terminal
cmake --build build --config Debug -j4
Method 4: Keyboard Shortcuts (Custom)
Add to .vscode/keybindings.json:
{
"key": "ctrl+alt+b",
"command": "workbench.action.tasks.runTask",
"args": "Compilation & Running LibMan: Build Debug"
}
Problem Matchers
Tasks use problem matchers to parse compiler output:
| Matcher | Purpose | Compiler |
|---|---|---|
$gcc | GCC/Clang errors | MinGW, GCC, Clang |
$cmake | CMake configuration errors | CMake |
$msCompile | MSVC errors | Visual Studio |
To add custom patterns, edit the "problemMatcher" field.
Pre-Launch and Dependent Tasks
Example: Debug task runs build first
"preLaunchTask": "Compilation & Running LibMan: Build Debug"
Example: Test task depends on build
"dependsOn": ["Tests: Build Tests"]
Presentation Options
Customize how tasks display output:
"presentation": {
"echo": true, // Show the command being run
"reveal": "always", // Always show terminal panel
"focus": false, // Keep focus on editor
"panel": "shared" // Share terminal across tasks
}
Options for reveal:
"always"- Always show terminal"silent"- Never show unless error"new"- Open new terminal each time
Environment Variables
Pass environment variables to tasks:
"options": {
"cwd": "${workspaceFolder}",
"env": {
"CMAKE_PREFIX_PATH": "C:/Qt/5.15.2/mingw81_64",
"ZLIB_ROOT": "C:/zlib-install"
}
}
Useful variables:
${workspaceFolder}- Root project directory${workspaceRootFolderName}- Folder name only${file}- Currently open file${fileDirname}- Directory of current file
Running Tests Automatically
After Every Build
Create a combined task:
{
"label": "Compilation & Running LibMan: Build Debug & Run Tests",
"type": "shell",
"command": "cmake --build build --config Debug -j4 && cd tests/build && ctest --output-on-failure",
"options": { "cwd": "${workspaceFolder}" },
"group": { "kind": "build" },
"problemMatcher": "$gcc"
}
Continuous Testing (Watch Mode)
Create a file watcher task (not directly supported in tasks.json):
- Use VS Code extension: "Task Buttons" or "Run on Save"
Debugging Tasks
View Task Execution Output
- Run any task
- Check the "Terminal" panel (
Ctrl+J) - See full command output
Troubleshoot "Command not found"
- Ensure command is in system
PATH - Use full path in command field
- Check working directory in
options.cwd
Debugging CMake Issues
Add verbose output:
"args": [
"--build", "build",
"--config", "Debug",
"--verbose" // Add this
]
Performance Optimization
Speed Up Builds
- Increase parallel jobs:
-j8or-j12 - Use faster linker:
"-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld" - Use precompiled headers (in CMakeLists.txt)
Speed Up CMake Configuration
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" // Already in config
Testing Multiple Configurations
Run Debug, Release, and Tests in sequence:
- Copy a task and modify
- Use task dependencies:
{
"label": "Full Test Suite",
"dependsOn": [
"Compilation & Running LibMan: Build Debug",
"Compilation & Running LibMan: Build Release",
"Tests: Run All Tests"
],
"problemMatcher": []
}
Restoring Default Configuration
If tasks get corrupted:
- Backup current: Copy
.vscode/tasks.json - Restore from docs: See reference in this folder
- Or use Git:
git checkout .vscode/tasks.json
Useful Extensions for Task Management
- Task Buttons - Quick task launcher in toolbar
- Task Runner - Enhanced task management
- Command Runner - Run any command from status bar
- Run on Save - Auto-run tasks on file changes
Install from VS Code Extensions marketplace.
Related Documentation
- Quick Start: Quick Start Guide
- Setup: VS Code Setup
- Reference: Quick Reference Card
- Troubleshooting: Troubleshooting Guide
Back to: Documentation Index