Tip: To quickly create a new project, run (uses
gh):# put your project name here: (export project=<project name here> && gh repo create $project --private --clone --template shaulnv/cpp-starter-kit && cd $project && ./init.sh)
Or, do it manually:
- Use this template to create a new repository for your project.
- Clone your repository locally.
- In the project root, run
./init.sh. This script will replace allstarterkitplaceholders with your project name, commits the changes, and prepare your project for development.
This project uses Conan and CMake. It includes:
- Library - Core logic implementation (./src).
- CLI - Command-line interface for your library (./cli).
- Tests - Test suite using doctest (./tests).
A software project should adhere to have distinct high-level components. This is why we have a Library part and a CLI part. The Library should consist of pure logic as much as possible. The CLI is (more) platform-specific, as Linux, Windows, and Mac support it, while HTML/Android/iOS does not.
In that spirit, the project should aim to be cross-platform. When supporting different platforms, it becomes clearer to distinguish between logical components and platform-specific components. The roject currently supports both native (Linux) and WebAssembly (via Node.js, with HTML support planned for the future) platforms.
- Install dependencies:
- Development Environment:
./setup.sh. - Build Environment: only
curland aC++ compiler(./build.shwill install the rest).
- Development Environment:
- Activate the virtual environment:
source ./activate.sh(run this in each new shell session). - Build the project:
./build.sh [--clean] [--release | --debug] [--profile=native|wasm|clang-tidy]NOTE: Flags are cached, so you can give them only when changing them.
Defaults are:--debug,--profile=native. - Run the CLI:
./run.sh [-h]. - Run tests:
./test.sh. - Dependencies:
The conanfile.py is the high level build script.
To add 3rd party C++ packages, set it in the 'requires' attribute.
After you add them there, you can use them inCMakeLists.txtfiles with standard find_package.
You can see an example of the fmt library, in: conanfile.py, CMakeLists.txt, and then in code.
NOTE: Run
>CMake ...means to run the commandCMake: ...from the VSCode's Command Palette (Ctrl+Shift+P)
- Open
./starterkit.code-workspacein VS Code. - Run
./build.shonce to generate the CMake build folder.NOTE: if you have issues with the next step, try refreshing VSCode:
>Developer: Reload Window - Choose what to run/debug:
>CMake: Select Configure PresetChoose theconan-releaseorconan-debugpreset.>CMake: Set Build TargetChoose the target to build (recommended:all).>CMake: Set Launch/Debug TargetSelect the current target:starterkit-clito run/debug theCLI.starterkit-teststo run/debug theunit-tests.
- With the selected target you can:
- Press
F7to build - Press
Ctrl+F5to run - Press
F5to debug
- Press
- Run
>CMake: Reveal Test Explorerto run specific tests. use theTestMate C++section.
- Open the project in VS Code.
- Run
>Dev Container: Open workspace in container.
This will start a container with the project opened, with all the dependencies installed.
First time may take some time (Docker's image build will take about 2 minutes).
You can use it to develop the project without the need to install the dependencies on your machine.
- You can use GitHub Codespaces to develop the project.
- Just go to your GitHub repo and click on the
Codebutton.

-
direnvSupport: The repository includes a.envrcfile fordirenvintegration. To enable it:-
Install
direnv:apt install direnv
-
Add the hook to your
.bashrcfile:# Enable direnv (place after rvm, git-prompt, or similar extensions) eval "$(direnv hook bash)" export DIRENV_LOG_FORMAT="" # Suppress direnv output
-
Run
direnv allow /path/to/projectonce, to enabledirenv.
Now, upon navigating to
starterkit(cd starterkit), the virtual environment will be activated automatically, making all tools in the venv available seamlessly. -



