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 manualy:
- 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 alltalking_cppplaceholders 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).
- Activate the virtual environment:
source ./activate.sh(run this in each new shell session). - Build the project:
./build.sh [--release | --debug](default is--debug).
You'l need the--release/--debugflag only to change the build type, so call it once, and then just run./build.sh. - 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.
- Open
./talking_cpp.code-workspacein VS Code. - Run
./build.shonce to generate the CMake build folder. - From the Command Palette (
Ctrl+P) runCMake: Set Build Target
Choose the target to build (recomended:all). - From the Command Palette (
Ctrl+P) runCMake: Set Launch/Debug Target
Select current target:talking_cpp-clito run/debug the CLI.talking_cpp-teststo run/debug the unit-tests.
- With the selected target you can:
- Press
F7to build - Press
Ctrl+F5to run - Press
F5to debug
- Press
- Run
CMake: Reveal Test Explorerto run spesific tests. use theTestMate C++section.
-
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
talking_cpp(cd talking_cpp), the virtual environment will be activated automatically, making all tools in the venv available seamlessly. -



