Giter Site home page Giter Site logo

r3d9477 / ucmakeskeleton Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 16.04 MB

rapid start the new C++ project, easy to debug and obtain profiling reports

CMake 75.09% C++ 24.91%
cmake cmake-template build-system cpp vscode vscode-configs vscode-settings cpp-project cpp-project-template vscode-cmake-tools vscode-cpp vscode-cpptools vscode-extension valgrind-log-parsing valgrind-tool project-template debugging process-monitor profiling vscode-process-monitor

ucmakeskeleton's Introduction

CppProjectTemplate_VSCodeCMakeTools

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.

Main tasks

  • Conan: Install - prepare build direcotry and install all needed packages (declared in file conanfile.txt) via Conan
  • CMake: Configure - run cmake.configure command
  • CMake: Build - run cmake.build command
  • CMake: Clean - run cmake.clean command
  • LiveProcMon: Start Monitoring - start real-time monitoring of the target process (by default taken from cmake.launchTargetPath)
  • LiveProcMon: Stop Monitoring - stop monitoring
  • Valgrind: 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)

Features

  • 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: LiveProcMon
  • 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

Basic project's stucture

ㅤㅤㅤㅤ[ PROJECT_FOLDER = PROJECT_NAME ]
ㅤㅤㅤㅤㅤㅤㅤㅤ|
ㅤㅤㅤㅤㅤㅤㅤㅤ|- CMakeLists.txt
ㅤㅤㅤㅤㅤㅤㅤㅤ|- test
ㅤㅤㅤㅤㅤㅤㅤㅤ|- lib
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- [ somelib ]
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- CMakeLists.txt
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- include
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- src
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- test
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- thirdparty
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- [ thirdlib ]
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- CMakeLists.txt
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- include
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- src
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- test

Install needed stuff first

  • 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

How to use

  1. clone that repositoy to your local machine
  2. add some external libraries in CMakeLists.txt_a_Libs.cmake
  3. add source of uint tests to folder test or add/change you testing configuration in CMakeLists.txt_b_Tests.cmake
  4. change required libraries in conanfile.txt, the package manager will handle it automatically during first build
  5. if needed, you can customize safety flags for your current compiler: GCC, Clang or MSVC
  6. if neeeded, add HERE specific sources and includes of your current project (example you can see HERE)
  7. 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)
  8. press F5 to build Debug version (variant selected by default in CMake Tools) and run debugging process (by default using LLDB, can be changed in launch.json)
  9. use tasks
  • LiveProcMon: Start Monitoring to check resources consumption at real-time
  • Valgrind: Show Memcheck Report, Valgrind: Show Callgrind Report and Valgrind: Show Cachegrind Report to get profiler's reports

Extra variables

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 varibale PROJECT_NAME, but for Qt6 application it different: app${PROJECT_NAME}. example of usage you can find HERE, HERE, HERE, HERE and HERE

Extra functions

you can use some of functions in your own configuration:

  • function get_sources_from_dir( SOURCES_DEST_VAR INCLUDES_DEST_VAR TARGET_FOLDER_PATH ) - scans TARGET_FOLDER_PATH and adds C++ files by the mask into variables: SOURCES_DEST_VAR (list of source files) and INCLUDES_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)

Used extensions

Tested on

  • Linux (GCC,Clang)
  • Windows (Clang,MinGW,MSVC)

Notes:

  • Valgrind reports feature currently available for Linux only
  • LiveProcMon feature currently available for Linux only

Links

ucmakeskeleton's People

Contributors

r3d9477 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.