Skip to content
/ MarkWareVCMake Public template

MarkWare VCMake is a comprehensive, modern C++ project template designed for cross-platform development in Visual Studio Code.

License

Notifications You must be signed in to change notification settings

tomasmark79/MarkWareVCMake

Repository files navigation

MarkWare VCMake

Ubuntu MacOS Windows

Overview

MarkWare VCMake is a comprehensive, modern C++ project template designed for cross-platform development in Visual Studio Code. The template provides a robust foundation for both standalone executables and libraries, incorporating industry best practices and modern build tools.

Just seconds away from starting πŸš€ development in awesome C++ πŸ’»βœ¨

Key Features🎈

  • Awesome OneClick Installer with setup-cpp
  • Linux, MacOS, Windows compatible
  • Modern CMake with targets design
  • Modern projects design Standalone & Library
  • Conan 2 by conanfile.py
  • CPM.cmake, CPM.license, cxxopt (cxxoptwiki)
  • Sanitizers, Static Analysis, and Hardening
  • Template Renamer
  • Template Upgrader
  • Counts with Cross-compilation
  • Compatible to SSH, WSL remote development
  • Automated Wrapper for CMake Build System by Tasks
  • Native C++ debugging by Microsoft C++ extension
  • CMake debugger
  • GitHub Actions workflows for continuous integration

Projects used this template

MWImGuiStarter
MWwxWidgetsStarter
MyPersonalDiscordBot
snake-in-shell-cpp
MassCode2Md
...

System Requirements

Essential Tools

All these required tools are installed automatically if missing by the installer script.

Getting Started

Environment installers

Below are the commands that will install the necessary dependencies for the listed operating systems to successfully start development using this template project.

Debian based

curl -sSL https://raw.githubusercontent.com/tomasmark79/MarkWareVCMake/main/.init/installers/DebianBasedInstaller.sh | bash

Fedora based

curl -sSL https://raw.githubusercontent.com/tomasmark79/MarkWareVCMake/main/.init/installers/FedoraInstaller.sh | bash

Windows 10/11

note: CMake generator -G "MinGW Makefiles" is in SolutionController.py at row 227 hardcoded. You need to change to your on demand.

PowerShell installer (be patient, take a while)

powershell -Command "Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/tomasmark79/MarkWareVCMake/main/.init/installers/WindowsInstaller.ps1' -OutFile 'WindowsInstaller.ps1'; Set-ExecutionPolicy Bypass -Scope Process -Force; .\WindowsInstaller.ps1"
# MacOS (required contributor)

Install template

git clone https://github.com/tomasmark79/MarkWareVCMake
cd MarkWareVCMake/
code .

Development Workflow

Keyboard Shortcuts

  • Shift+F7: TASK MENU (standalone, library, both)
  • F7: πŸ”¨ Quick build Standalone
  • F5: πŸͺ² Quick debug Standalone
  • Ctrl+Alt+R: just Launch Standalone binary
  • Ctrl+Alt+L: πŸ” clang-tidy
  • Ctrl+Alt+F: πŸ“ clang-format
  • Ctrl+Alt+M: πŸ“ cmake-format

Automatic Tasks

By Shift+F7 invoked TASK MENU includes the following automation commands:

  • πŸš€ Zero to Build means 🧹 πŸ—‘οΈ πŸ”§ πŸ”¨
  • 🦸 Zero to Hero means 🧹 πŸ—‘οΈ πŸ”§ πŸ”¨ πŸ“Œ πŸ—œοΈ
  • 🧹 Clean build directories
  • πŸ—‘οΈ Dependency installation with Conan 2
  • πŸ”§ CMake configuration
  • πŸͺ² CMake configuration with CMake πŸ¦‰ debugger
  • πŸ”¨ Build (Re-Build F7)
  • πŸ“œ License collection with CPM for CPM
  • πŸ“Œ Install artefacts
  • πŸ—œοΈ Release tarballs
  • πŸ›Έ Run CPack
  • βš”οΈ Conan create library recipe
  • πŸ“Š Conan dependencies in graph.html
  • πŸ” CLang-tidy
  • πŸ“πŸ“ CLang & CMake formatting

CMake Build Options

Supports multiple build types hardcoded in tasks.json:

Debug, Release, RelWithDebInfo, MinSizeRel

Configurable CMake options for:

BUILD_SHARED_LIBS, USE_STATIC_RUNTIME, SANITIZE_ADDRESS, SANITIZE_UNDEFINED, SANITIZE_THREAD, SANITIZE_MEMORY, ENABLE_HARDENING, ENABLE_IPO, ENABLE_CCACHE

CLI Build everything at once

Build standalone part will also build library if linked in CMake configuration.

conan install "." --output-folder="./build/standalone/default/debug" --deployer=full_deploy --build=missing --profile default --settings build_type=Debug
source "./build/standalone/default/debug/conanbuild.sh" && cmake -S "./standalone" -B "./build/standalone/default/debug" -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="./build/installation/default/debug"
source "./build/standalone/default/debug/conanbuild.sh" && cmake --build "./build/standalone/default/debug"  -j 16
source "./build/standalone/default/debug/conanbuild.sh" && cmake --build "./build/standalone/default/debug" --target install -j 16

Additional Features

Cross-Compilation Support

The template includes preconfigured menu items. The default Conan profile represents the default value in the buildArch definition. Other profiles can be edited and supplemented according to your existing Conan profiles.

{
    /* ARCH ITEMS */
    "id": "buildArch",
    "type": "pickString",
    "description": "Select target architecture",
    "options": [
        "default", 
        "x86_64-clang-linux-gnu",
        "x86_64-w64-mingw32",
        "aarch64-rpi4-linux-gnu"
    ],
    "default": "default"
}

Project Maintenance

Renaming

by python script SolutionRenamer.py

Upgrade custom template parts

by pyton script SolutionUpgrader.py

Log using history

in existing log file Solution.log

Template Structure

Template is using Two projects in One Solution.

MarkWareVCMake/
β”œβ”€β”€ include/

Contains library project public header files (.hpp) intended for use in other projects or modules.

MarkWareVCMake/
β”œβ”€β”€ src/

Contains library project source files (.cpp) and internal header files (.hpp) that are not intended for public use.

MarkWareVCMake/
β”œβ”€β”€ standalone/

Contains just standalone project.

MarkWareVCMake/
β”œβ”€β”€ assets/

Contains project assets. All content included in this folder is accessible via file path by macro ASSET_PATH.

Standalone arguments

Template C++ is using basic cxxopt implementation to smart manage passed arguments for Standalone.

  • -o omitt library loading
  • -h show help

Conventions

To avoid future issues with folder and file names, I have set these rules.

  • All standard template folders, including those generated later, use lowercase letters only.
  • User-defined folders can contain any combination of uppercase and lowercase letters.
  • All C and C++ files provided in the template will use CamelCase convention, including an uppercase letter at the beginning.

Indentation

C/C++ 2 spaces
Python 4 spaces

FAQ

Q: Build task error
Error: /home/.../Build/Standalone/default/Debug is not a directory
Error: /home/.../Build/Library/default/Debug is not a directory
A: There is nothing to build. You must first create the configurations for the product, and only then can you compile separately with the build task. The "Zero to Build," "Zero to Hero," or CMake configuration tasks will help you create the configuration, which can then be compiled.

Q: CMake-tidy error
Error while trying to load a compilation database: Could not auto-detect compilation database from directory, etc.
A: For static code analysis to work correctly, you need to have the CMake configurations prepared. Also, ensure that the CMAKE_EXPORT_COMPILE_COMMANDS variable is set to ON in CMakeLists.txt.

Tips

xxd -i file.bin > file.h

Thanks

To everyone who supported me in creating this template. These are various people and information from the web. Of course, also literature and courses that I have taken in the past. Various Discord servers and individuals who took a moment to make an indelible mark on this amazing work for me. Thank you very much!

Credits

dsdotname, littlemushroom

License

MIT License Copyright (c) 2024-2025 TomΓ‘Ε‘ Mark

This project is licensed under the MIT License. No warranty of functionality or liability is provided. If you use this project, please mention my credentials. If you need software and technical support, you can contact me.