Template of C++ project with config to make a VSCode be IDE-like with set of useful features for simplier development life.
Configured over MS C/C++ Extension Pack extension.
CMake: Clean
- runcmake.clean
command + remove all Valgrind reportsCMake: Configure and Build
- configure and runcmake.build
commandCMake: Configure and Rebuild
- configure and runcmake.cleanRebuild
commandCMake: Configure with Conan Install
- installconanfile.txt
and runcmake.configure
commandCppRunCurrentFile: Run/Debu
- 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
- easy to run inside Docker with already prepared configuration
- uses
CMake
to manage the project, configured to use extension ms-vscode.cmake-tools - uses Conan, automatically downloads packages from
conanfile.txt
before building the project - easy to make and show
Valgrind
reports LiveProcMon
feature checks resources consumption of the launched application, easy to configure, strart and stop:- easy access to cppreference (via hotkey
Ctrl+Shift+A
) to get description of specified data type, method, etc - enabled auto linting (with
clang-tidy
) - enabled auto formatting (with
clang-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
,Qt5
/Qt6
libraries - 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
ㅤㅤㅤㅤ[ 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. rename directory
.devcontainer_disabled
to.devcontainer
to enable config - 1.1.3. 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 conanfile.txt, the package manager will handle it automatically during 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 (example you can see HERE)
- 3.1. run task
Terminal
>Run Task
>CMake: 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). examples of usage you can find HERE and HERE - 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}
. example of usage you can find in CMakeLists.txt_z_Utils_Qt.cmake - variable
SAFETY_FLAGS
- contains the list of the compiler's flags (GCC, Clang or MSVC)
- required
- 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
- additional
- Gruntfuggly.activitusbar - debugging and profiling shortcuts 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
- liangruliu.customize-toolbar - code folding/unfolding buttons in editor's toolbar
- 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"