Author: Tomรกลก Mark
Version: main
๐๐๐
The MarkWare VCMake Template provides a modern solution for C and C++ development by combining application and library workflows within a single configurable template. Designed for developers who value efficiency and modern tools, it simplifies project initialization while adhering to industry best practices. Built with Modern CMake, Conan 2, and VSCode integration, this template is an essential starting point for your next project.
๐๐๐
โจโจโจ
- Quick Start: Minimal setup required, ready to use immediately after cloning.
- Modern Standards: Supports best practices for C and C++ development.
- Native Debugging: Step-by-step debugging directly on Linux.
- Cross-Platform: Runs natively on Linux ๐ง, macOS ๐, and Windows ๐ช.
- Cross-Compilation: Easily target multiple architectures.
- Highly Customizable: Modular structure tailored to your specific project needs.
โจโจโจ
๐๐๐
- Visual Studio Code: Preconfigured for seamless development.
https://code.visualstudio.com/ - Modern CMake: Advanced configuration and build management.
https://cmake.org/download/ - Pyenv: Simplifies Python version management.
https://github.com/pyenv/pyenv - Python 3: Integrated for scripting and automation.
https://www.python.org/downloads/ - Conan 2: Simplifies dependency management.
https://docs.conan.io - ModernCppStarter: Inspired by industry best practices for initializing C++ projects.
https://github.com/TheLartians/ModernCppStarter - GitHub Action Workflows: Actively monitors the source code status across all major platforms. https://github.com/tomasmark79/MarkWareVCMake/actions
๐๐๐
- CPM.cmake: Lightweight dependency management as the add-in if neccessary.
https://github.com/cpm-cmake/CPM.cmake - CPM.license: Automates third-party license management.
https://github.com/cpm-cmake/CPMLicenses.cmake - Formatters: Preconfigured for consistent code formatting.
Note: Combining Conan 2 and CPM.cmake is generally not recommended, but it is not prohibited either. If you approach the dependency management concept with Conan 2 as the primary dependency manager and CPM.cmake as a supplementary dependency manager, everything will be fine. Just make sure to watch out for conflicts.
๐ก๏ธ๐ก๏ธ๐ก๏ธ
โ๏ธโ๏ธโ๏ธ
-
Update system packages:
sudo apt update && sudo apt upgrade -y sudo apt install cmake python3-pip curl git libssl-dev \ libbz2-dev libcurses-ocaml-dev build-essential gdb libffi-dev \ libsqlite3-dev liblzma-dev libreadline-dev libtk-img-dev
-
Install and configure Pyenv:
curl https://pyenv.run | bash pyenv install 3.9.2 pyenv virtualenv 3.9.2 env392 pip install --upgrade pip
-
Install Conan:
pip install conan conan profile detect --force
- Install and configure Pyenv for Windows:
Powershell Installation Steps
pyenv install 3.9.2 pyenv global 3.9.2 pyenv local 3.9.2 pip install --upgrade pip
- Install Conan:
pip install conan conan profile detect --force
- Enable WSL and install Debian:
wsl --install wsl --list --online wsl --install Debian wsl --set-default-version 2 shutdown /r
- Install required VSCode extensions:
ms-vscode-remote.remote-wsl
ms-vscode.cpptools
- Connect to WSL and open the project in VSCode
code .
๐๐๐
- Clone the template:
git clone https://github.com/tomasmark79/MarkWareVCMake cd MarkWareVCMake/
- Rename components:
python SolutionRenamer.py VCMLib MyLibrary VCMStandalone MyStandalone
- Open the project in VSCode:
code .
- File SolutionUpgrader.py can update the template files from the repository that you choose. More information inside the script.
From this point, you have a fully functional solution for developing Linux binaries, regardless of the host platform.
๐๐๐
๐๐๐
Default
(automatic system default compiler toolchain selection)x86_64-unknown-linux-gnu
(requires cross-compilation toolchain)x86_64-w64-mingw32
(requires cross-compilation toolchain)aarch64-linux-gnu
(requires cross-compilation toolchain)
Je jednoduchรฉ pลidat novou architekturu.
๐๐๐
๐๏ธ๐๏ธ๐๏ธ
Debug
Release
RelWithDebInfo
MinSizeRel
๐๏ธ๐๏ธ๐๏ธ
๐๐๐
.
โโโ cmake
โย ย โโโ Modules
โย ย โย ย โโโ FindX11.cmake
โย ย โโโ CPM.cmake
โย ย โโโ tools.cmake
โโโ .github
โย ย โโโ workflows
โย ย โโโ install.yml
โย ย โโโ macos.yml
โย ย โโโ ubuntu.yml
โย ย โโโ windows.yml
โโโ include
โย ย โโโ VCMLib
โย ย โโโ VCMLib.hpp
โโโ Source
โย ย โโโ VCMLib.cpp
โโโ Standalone
โย ย โโโ Source
โย ย โย ย โโโ Main.cpp
โย ย โโโ CMakeLists.txt
โย ย โโโ LICENSE
โโโ Utilities
โย ย โโโ CMakeToolChains
โย ย โย ย โโโ aarch64-linux-gnu.cmake
โย ย โย ย โโโ x86_64-unknown-linux-gnu.cmake
โย ย โย ย โโโ x86_64-w64-mingw32.cmake
โย ย โโโ ConanProfiles
โย ย โย ย โโโ aarch64-linux-gnu
โย ย โย ย โโโ x86_64-unknown-linux-gnu
โย ย โย ย โโโ x86_64-w64-mingw32
โย ย โโโ AboutThisFolder.md
โโโ .vscode
โย ย โโโ c_cpp_properties.json
โย ย โโโ keybindings.json
โย ย โโโ launch.json
โย ย โโโ settings.json
โย ย โโโ tasks.json
โโโ .clang-format
โโโ .cmake-format
โโโ CMakeLists.txt
โโโ conanfile.py
โโโ .gitattributes
โโโ .gitignore
โโโ LICENSE
โโโ .python-version
โโโ README.md
โโโ SolutionController.py
โโโ SolutionRenamer.py
โโโ SolutionUpgrade.py
๐๐๐
๐ ๏ธ๐ ๏ธ๐ ๏ธ
Task Menu | Description |
---|---|
Zero to Hero | Clean โ Conan โ Configure โ Build |
Clean | Removes the entire build folder |
Conan | Builds Conan dependencies |
Configure | Configures CMake |
Build | Builds the project |
Collect Licenses | Gathers licenses from CPM dependencies |
Install Artefacts | Installs to /Build/Installed/ |
Release Artefacts | Tarballs to /Build/Artefacts/ |
Conan graph.html | Create html output of dependencies |
Lint C/C++ | C/C++ files diagnostics |
Format C/C++ | Formatting for C/C++ files |
Format CMake | Formatting for CMake files |
Special Task Menu | Description |
---|---|
Permutate All Tasks | Executes all task scenarios (testing purpose) |
- F5: Start debugging.
- F7: Build native debug configuration.
- Shift + F7: Task Menu
- Shift + Ctrl + S: Special Task Menu
- Ctrl + Alt + M: Format all CMake files.
- Ctrl + Alt + F: Format all C++ files.
- Ctrl + Alt + L: Lint all C++ files.
- Ctrl + Shift + Alt + B: Run ShellCheck on bash scripts.
๐งฎ
Of course, the recommended approach is to control the project workflow using the recommended method through tasks and menus in VSCode.
For completeness and troubleshooting, I also present the command line commands here, which can be used at any time as needed.
Remove: Build/Library/default/Debug
Remove: Build/Standalone/default/Debug
conan install "/home/tomas/dev/cpp/projects/MarkWareVCMake" --output-folder="Build/Library/default/Debug" --build=missing --profile=default --settings=build_type=Debug -o *:shared=False
conan install "/home/tomas/dev/cpp/projects/MarkWareVCMake" --output-folder="Build/Standalone/default/Debug" --build=missing --profile=default --settings=build_type=Debug -o *:shared=False
source "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Library/default/Debug/conanbuild.sh" && cmake -S "." -B "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Library/default/Debug" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Install/default/Debug"
cmake -S "." -B "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Library/default/Debug" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Install/default/Debug"
source "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Standalone/default/Debug/conanbuild.sh" && cmake -S "./Standalone" -B "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Standalone/default/Debug" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Install/default/Debug"
cmake -S "./Standalone" -B "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Standalone/default/Debug" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Install/default/Debug"
cmake --build "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Library/default/Debug" -j 16
cmake --build "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Standalone/default/Debug" -j 16
cmake --build "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Library/default/Debug" --target write-licenses -j 16
cmake --build "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Standalone/default/Debug" --target write-licenses -j 16
cmake --build "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Library/default/Debug" --target install -j 16
cmake --build "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Standalone/default/Debug" --target install -j 16
Remove: Build/Library/x86_64-w64-mingw32/Release
Remove: Build/Standalone/x86_64-w64-mingw32/Release
conan install "/home/tomas/dev/cpp/projects/MarkWareVCMake" --output-folder="Build/Library/x86_64-w64-mingw32/Release" --build=missing --profile=x86_64-w64-mingw32 --settings=build_type=Release -o *:shared=False
conan install "/home/tomas/dev/cpp/projects/MarkWareVCMake" --output-folder="Build/Standalone/x86_64-w64-mingw32/Release" --build=missing --profile=x86_64-w64-mingw32 --settings=build_type=Release -o *:shared=False
source "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Library/x86_64-w64-mingw32/Release/conanbuild.sh" && cmake -S "." -B "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Library/x86_64-w64-mingw32/Release" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Install/x86_64-w64-mingw32/Release"
cmake -S "." -B "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Library/x86_64-w64-mingw32/Release" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Install/x86_64-w64-mingw32/Release"
source "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Standalone/x86_64-w64-mingw32/Release/conanbuild.sh" && cmake -S "./Standalone" -B "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Standalone/x86_64-w64-mingw32/Release" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Install/x86_64-w64-mingw32/Release"
cmake -S "./Standalone" -B "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Standalone/x86_64-w64-mingw32/Release" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Install/x86_64-w64-mingw32/Release"
cmake --build "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Library/x86_64-w64-mingw32/Release" -j 16
cmake --build "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Standalone/x86_64-w64-mingw32/Release" -j 16
cmake --build "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Library/x86_64-w64-mingw32/Release" --target write-licenses -j 16
cmake --build "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Standalone/x86_64-w64-mingw32/Release" --target write-licenses -j 16
cmake --build "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Library/x86_64-w64-mingw32/Release" --target install -j 16
cmake --build "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Standalone/x86_64-w64-mingw32/Release" --target install -j 16
Remove: Build/Library/aarch64-linux-gnu/MinSizeRel
Remove: Build/Standalone/aarch64-linux-gnu/MinSizeRel
conan install "/home/tomas/dev/cpp/projects/MarkWareVCMake" --output-folder="Build/Library/aarch64-linux-gnu/MinSizeRel" --build=missing --profile=aarch64-linux-gnu --settings=build_type=MinSizeRel -o *:shared=False
conan install "/home/tomas/dev/cpp/projects/MarkWareVCMake" --output-folder="Build/Standalone/aarch64-linux-gnu/MinSizeRel" --build=missing --profile=aarch64-linux-gnu --settings=build_type=MinSizeRel -o *:shared=False
source "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Library/aarch64-linux-gnu/MinSizeRel/conanbuild.sh" && cmake -S "." -B "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Library/aarch64-linux-gnu/MinSizeRel" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX="/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Install/aarch64-linux-gnu/MinSizeRel"
cmake -S "." -B "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Library/aarch64-linux-gnu/MinSizeRel" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX="/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Install/aarch64-linux-gnu/MinSizeRel"
source "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Standalone/aarch64-linux-gnu/MinSizeRel/conanbuild.sh" && cmake -S "./Standalone" -B "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Standalone/aarch64-linux-gnu/MinSizeRel" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX="/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Install/aarch64-linux-gnu/MinSizeRel"
cmake -S "./Standalone" -B "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Standalone/aarch64-linux-gnu/MinSizeRel" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX="/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Install/aarch64-linux-gnu/MinSizeRel"
cmake --build "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Library/aarch64-linux-gnu/MinSizeRel" -j 16
cmake --build "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Standalone/aarch64-linux-gnu/MinSizeRel" -j 16
cmake --build "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Library/aarch64-linux-gnu/MinSizeRel" --target write-licenses -j 16
cmake --build "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Standalone/aarch64-linux-gnu/MinSizeRel" --target write-licenses -j 16
cmake --build "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Library/aarch64-linux-gnu/MinSizeRel" --target install -j 16
cmake --build "/home/tomas/dev/cpp/projects/MarkWareVCMake/Build/Standalone/aarch64-linux-gnu/MinSizeRel" --target install -j 16
MarkWareVCMake | ModernCppStarter | cmake_template | |
---|---|---|---|
Minimal setup required | yes | yes | yes |
Supports best practices + Modern CMake | yes | yes | yes |
Stanadlone->Library concept | yes | yes | yes |
Highly Customizable | yes | yes | yes |
Github workflow with badges | yes | yes | not sure |
PackageProject.cmake | yes | author | no |
Dependency solution CPM.cmake integrated | yes | author | no |
CPM.license integrated | yes | author | no |
CPM.tools integrated | yes | author | no |
LintC, clang-format, cmake-format | VSCode Tasks + shortcuts + cli | only cli | no |
Solution Renamer | yes | no | no |
Dependency solution by Conan | yes, wrapped by tasks in VSCode | no | no |
CMake generators by Conan preconfigured | yes | no | no |
Cross-Compilation preconfigured | yes, require toolchain | no | no |
Cross-Compilation targets preconfigured | linux, windows, raspberry pi 4/5 | no | no |
VSCode CMake controller | yes | no | no |
VSCode Tasks via Menu and Shortcuts | yes | no | no |
Clean | Removes the entire build folder | no | no |
Conan | Builds Conan dependencies | no | no |
Configure | Configures CMake | only cli | only cli |
Build | Builds the project | only cli | only cli |
Collect Licenses | Gathers licenses from CPM dependencies | no | no |
Install Artefacts | Installs toย /Build/Installed/ | no | no |
Release Artefacts | Tarballs toย /Build/Artefacts/ | no | no |
Lint C/C++ | C/C++ files diagnostics | only cli | only cli |
Format C/C++ | Recursive formatting for C/C++ files | only cli | only cli |
Format CMake | Recursive formatting for CMake files | only cli | only cli |
Permutate All Tasks | Executes all task scenarios (testing) | no | no |
Loging runned commands | yes, to file | no | no |
C/C++ tests | not yet | yes | yes |
Doxygen | not yet | yes | no |
This template is licensed under MIT License.