Template of C++ project with config to make a VSCode be IDE-like with set of useful features for simplier development life.
- configured to run as on host, as inside Docker
- uses
CMake
to manage the project - configured to work with package managers (automatically downloads and sets packages during project configuration)
- by default uses vcpkg and
vcpkg.json
(should be defined environment variableVCPKG_ROOT
) - can use Conan and
conanfile.txt
(should NOT be defined environment variableVCPKG_ROOT
)
- by default uses vcpkg and
- easy to make and show
Valgrind
reports- Memcheck
- Cachegrind
- Callgrind
LiveProcMon
feature shows resources consumption of the launched application on the chartsCppRunCurrentFile
feature to run & debug currently opened C++ snippet- easy access to cppreference (via hotkey
Ctrl+Shift+A
) to get description of specified data type, method, etc - enabled auto linting (with
clang-tidy
) and auto formatting (withclang-format
) - automatically applies name of directory as name of a project/library
- automatically finds and adds needed sources from certain folders, and includes them into the project's tree (described in Configure and Internal functions and variables description)
- automatically adds (if possible)
Boost
andQt6
libraries (installed via package manager) - applies set of compiler's flags for extra safety: GCC, Clang or MSVC
- automatically finds and adds unit tests (don't use the dot symbol '
.
' in the name of test's source file!) - for MSVC automatically copies MS Visual C++ runtime libs to target building directory
C++ Project: Clean
- runscmake.clean
command + remove all Valgrind reportsC++ Project: Configure and Build
- configure and runcmake.build
commandC++ Project: Configure and Rebuild
- configure and runcmake.cleanRebuild
commandC++ Project: Configure and Install Packages
- installconanfile.txt
and runcmake.configure
commandCppRunCurrentFile: Run/Debug
- build, run & debug currently opened.cpp
source fileLiveProcMon: Start Monitoring
- start real-time monitoring of the target process (by default taken fromcmake.launchTargetPath
)LiveProcMon: Stop Monitoring
- stop monitoringValgrind: Show Memcheck Report
- show profiler's report (check for memory leaks)Valgrind: Show Cachegrind Report
- show profiler's report (check for chache missings)Valgrind: Show Callgrind Report
- show profiler's report (check for tree of calls and theirs performing times)
Debug
LiveProcMon: Start Monitoring
LiveProcMon: Stop Monitoring
Valgrind: Show Memcheck Report
Valgrind: Show Cachegrind Report
Valgrind: Show Callgrind Report
CppRunCurrentFile: Run/Debug
Fold level 4
Fold level 3
Fold level 2
Fold level 1
Unfold all
ㅤㅤㅤㅤ[ PROJECT_FOLDER = PROJECT_NAME ]
ㅤㅤㅤㅤㅤㅤㅤㅤ|
ㅤㅤㅤㅤㅤㅤㅤㅤ|- CMakeLists.txt
ㅤㅤㅤㅤㅤㅤㅤㅤ|- src
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- main.cpp
ㅤㅤㅤㅤㅤㅤㅤㅤ|- test
ㅤㅤㅤㅤㅤㅤㅤㅤ|- lib
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- [ somelib ]
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- CMakeLists.txt
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- include
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- src
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- test
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- thirdparty
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- [ thirdlib ]
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- CMakeLists.txt
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- include
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- src
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- test
- 1.1.1. (install docker) and (docker compose) on your host machine (solution for Fedora Silverblue)
- 1.1.2. Open an existing folder in a container
- 1.2.1. install gcc (e.g.
apt install gcc gdb
) - 1.2.2. install clang (e.g.
apt install clang clang-tidy clang-format lldb
) - 1.2.3. install python (e.g.
apt install python3 python3-venv
, dopython3 -m venv ~/.local --system-site-packages
and add~/.local/bin
to globalPATH
variable) - 1.2.4. install cmake (e.g.
pip install cmake
) - 1.2.5. install conan (e.g.
pip install conan
and doconan profile detect
) - 1.2.6. install ploting tools (e.g.
pip install gprof2dot matplotlib pillow
)
- 2.1. clone that repositoy to your local machine
- 2.2. current source directory is
./src
. if needed, change main sources directory HERE - 2.3. add some external libraries in CMakeLists.txt_a_Project_Libs.cmake
- 2.4. add source of uint tests to folder
test
or add/change you testing configuration in CMakeLists.txt_b_Project_Tests.cmake - 2.5. change required libraries in vcpkg.json or in conanfile.txt, the package manager will handle it automatically during the first build
- 2.6. if needed, you can customize safety flags for your current compiler: GCC, Clang or MSVC
- 2.7. if neeeded, add HERE specific sources and includes of your current project
- 3.1. run task
Terminal
>Run Task
>Project: Configure with Conan Install
- 3.2. press
F5
to buildDebug
version (variant selected by default in CMake Tools) and run debugging process (by default using LLDB, can be changed inlaunch.json
) - 3.3. use additinal tasks for profiling:
LiveProcMon: Start Monitoring
to check resources consumption at real-timeValgrind: Show Memcheck Report
,Valgrind: Show Callgrind Report
andValgrind: Show Cachegrind Report
to get profiler's reportsCppRunCurrentFile: Run/Debug
to compile and run currently snippet (e.g. single.cpp
file located in folder test_cpp_snippets)
- function
get_sources_from_dir( SOURCES_DEST_VAR INCLUDES_DEST_VAR TARGET_FOLDER_PATH )
- scansTARGET_FOLDER_PATH
(non-recursive globbing) and adds C++ files by the mask into variables:SOURCES_DEST_VAR
(list of source files) andINCLUDES_DEST_VAR
(list of include paths). - variable
OUTPUT_NAME
- the name of the current target name (target executable file name). usually it the same as varibalePROJECT_NAME
, but for Qt6 application it different:app${PROJECT_NAME}
. - variable
SAFETY_FLAGS
- contains the list of the compiler's flags (GCC, Clang or MSVC)
- required
- ms-vscode-remote.remote-containers - run development environment in a container
- ms-vscode.cpptools-extension-pack - support of C++ intellisense, refactoring, sources colorization, etc.
- xaver.clang-format - code formatter
- vadimcn.vscode-lldb - support of LLDB debugger
- tintinweb.graphviz-interactive-preview - visualize charts, required for Callgrind reports
- ryuta46.multi-command - support of custom commands
- rioj7.command-variable - advanced variables substitution
- ArturoDent.launch-config - allows to launch debugging with specific configuration
- fredericbonnet.cmake-test-adapter - unit tests explorer
- additional
- dacapoday.status-bar-button - debugging/profiling and code folding buttons in status bar
- matepek.vscode-catch2-test-adapter - a better unit tests explorer for GTests (but has no support of Boost.UnitTest)
- Guyutongxue.cpp-reference - easy access to cppreference
- krosf.vscode-valgrind - colorization of Valgrind reports
- CFXS.BuildOutputColorizerIAR - colorization of output
- SR-team.vscode-autohide-fork - autohide bottom panel with terminal
- jiapeiyao.tab-group - grouped tabs
- Blackboxapp.blackbox - AI helper
- hediet.vscode-drawio - draw.io diagrams right in VSCode
- Linux (GCC,Clang)
- Windows (Clang,MinGW,MSVC)
Valgrind
reports feature currently available for Linux onlyLiveProcMon
feature currently available for Linux only
- used in template of "Qml Multilingual Application"
- used in demo "Simple Custom Qml Item Qt6 Cmake"