Universal template of C++ project, was made to rapid start the new C++ project, easy debug and profile it.
Configured over MS C/C++ Extension Pack extension.
Conan: Install
- prepare build direcotry and install all needed packages (declared in fileconanfile.txt
) via ConanCMake: Configure
- runcmake.configure
commandCMake: Build
- runcmake.build
commandCMake: Clean
- runcmake.clean
commandLiveProcMon: 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)
- 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 and includes into the project's tree (non-recursive globbing); easy and flexible configuration process of source tree for current target: just add needed folder to list
- automatically adds some of libraries (if possible): Boost, Qt5, Qt6
- applies some compiler's extra flags because of safety. each compiler has a different set of flags: GCC, Clang or MSVC
- automatically finds and adds Boost 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
ㅤㅤㅤㅤㅤㅤㅤㅤ|- test
ㅤㅤㅤㅤㅤㅤㅤㅤ|- lib
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- [ somelib ]
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- CMakeLists.txt
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- include
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- src
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- test
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- thirdparty
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- [ thirdlib ]
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- CMakeLists.txt
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- include
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- src
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- test
- Linux (Debian-based):
sudo apt install clang clang-tidy clang-format lldb git code valgrind python3 python3-pip
pip3 install conan gprof2dot matplotlib pillow
conan profile detect
- clone that repositoy to your local machine
- add some external libraries in CMakeLists.txt_a_Libs.cmake
- add source of uint tests to folder
test
or add/change you testing configuration in CMakeLists.txt_b_Tests.cmake - change required libraries in conanfile.txt, the package manager will handle it automatically during first build
- if needed, you can customize safety flags for your current compiler: GCC, Clang or MSVC
- if neeeded, add HERE specific sources and includes of your current project (example you can see HERE)
- for the first time it will be proposed to choose sertain development kit via standard menu of CMake Tools (the same as
>CMake: Select a Kit
) - 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
) - use tasks
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 reports
you can use some of variables in your own configuration:
- variable
SAFETY_FLAGS
- contains the list of the compiler's flags (GCC, Clang and MSVC) to make your code more safe. example of usage you can find HERE, 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 HERE, HERE, HERE, HERE and HERE
you can use some of functions in your own configuration:
- function
get_sources_from_dir( SOURCES_DEST_VAR INCLUDES_DEST_VAR TARGET_FOLDER_PATH )
- scansTARGET_FOLDER_PATH
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 - function
target_add_boost( TARGET_NAME )
- adds boost library to your target (if it possible). example of usage you can find HERE - function
target_add_Qt( TARGET_NAME )
- adds Qt to your target (if it possible). example of usage you can find HERE - function
target_add_tests_from_folder( TARGET_NAME FOLDER_PATH )
- applies Boost unit tests from specified folder (relative or absolute path) for specified target. each source file will be used as individual testing module. examples of usage you can find HERE (for TESTS), HERE (for TESTS) and HERE (for TESTS)
- ms-vscode.cpptools-extension-pack - (required) support of C++ intellisense, refactoring, sources colorization, etc.
- vadimcn.vscode-lldb - (required) support of LLDB debugger
- ryuta46.multi-command - (required) support of custom commands
- tintinweb.graphviz-interactive-preview - (required) visualize charts, useful for Callgrind report
- fredericbonnet.cmake-test-adapter - (optional) support of Unit Tests
- Guyutongxue.cpp-reference - (optional) easy access to cppreference
- krosf.vscode-valgrind - (optional) colorization of Valgrind reports
- CFXS.BuildOutputColorizerIAR - (optional) colorization of output
- SR-team.vscode-autohide-fork - (optional) autohide bottom panel with terminal
- jiapeiyao.tab-group - (optional) grouped tabs
- Blackboxapp.blackbox - (optional) AI helper
- liangruliu.customize-toolbar - (optional) code folding/unfolding buttons in editor's toolbar
- 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"