A modern and cross-platform template for C++ projects using only header-only dependencies.
To use this project, you must have the following tools installed and available in your system PATH
:
- Git
- GCC on Linux, Clang on MacOS, and MSVC on Windows
Compiler | Version |
---|---|
GCC | 7.0 |
Clang | 5.0 |
MSVC | 19.11 (Visual Studio 2017 version 15.3) |
-
Clone this repository
git clone https://github.com/tGstep/Cpp-Modern-Header-Only.git cd Cpp-Modern-Header-Only
-
Install required tools
From the root directory, run the platform-specific script:- On Linux/macOS:
./scripts/install_tools.sh
- On Windows:
.\scripts\install_tools.ps1
- On Linux/macOS:
-
Add dependencies
Modify thedeps.json
file to include the header-only libraries you need. Example:[ { "name": "example_dep", "repo": "https://github.com/user/example_dep", "includes": "include" } ]
-
Fetch dependencies
This will clone the GitHub repos intoexternal/
.- On Linux/macOS:
./scripts/fetch_dependencies.sh
- On Windows:
.\scripts\fetch_dependencies.ps1
- On Linux/macOS:
-
Generate build files using Premake and Ninja
premake5 ninja
-
Build the project
ninja -C build
A search helper that find libraries is provided.
- On Linux/macOS:
./scripts/fetch_dependencies.sh example_dep
- On Windows:
.\scripts\fetch_dependencies.ps1 example_dep
You will be prompted to add the found library to deps.json
automatically.
.
├── .github/
│ └── workflows/
│ └── build.yml # GitHub Actions build
├── build/ # Ninja build output
├── external/ # Cloned header-only libraries
├── scripts/ # Automation scripts
│ ├── install_tools.sh # Install premake, ninja and premake-ninja module (Linux/macOS)
│ ├── install_tools.ps1 # Install premake, ninja and premake-ninja module (Windows)
│ ├── fetch_dependencies.sh # Search and install helper (Linux/macOS)
│ └── fetch_dependencies.ps1 # Search and install helper (Windows)
├── src/
│ └── main.cpp # Sample source
├── deps.json # Dependency list
├── premake5.lua # Project configuration
├── README.md # This file
└── premake-ninja/ # Cloned premake-ninja backend