Skip to content

Repository files navigation

C++ Project Starter Kit

Getting Started

Initial Setup

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:

  1. Use this template to create a new repository for your project.
  2. Clone your repository locally.
  3. In the project root, run ./init.sh.
    This script will replace all talking_cpp placeholders with your project name, commits the changes, and prepare your project for development.

Project Structure

This project uses Conan and CMake. It includes:

  1. Library - Core logic implementation (./src).
  2. CLI - Command-line interface for your library (./cli).
  3. Tests - Test suite using doctest (./tests).

Build & Dev

  1. Activate the virtual environment: source ./activate.sh (run this in each new shell session).
  2. Build the project: ./build.sh [--release | --debug] (default is --debug).
    You'l need the --release/--debug flag only to change the build type, so call it once, and then just run ./build.sh.
  3. Run tests: ./test.sh.
  4. 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 in CMakeLists.txt files with standard find_package.
    You can see an example of the fmt library, in: conanfile.py, CMakeLists.txt, and then in code.

VS Code Integration

  1. Open ./talking_cpp.code-workspace in VS Code.
  2. Run ./build.sh once to generate the CMake build folder.
  3. From the Command Palette (Ctrl+P) run CMake: Set Build Target
    Choose the target to build (recomended: all).
  4. From the Command Palette (Ctrl+P) run CMake: Set Launch/Debug Target
    Select current target:
    • talking_cpp-cli to run/debug the CLI.
    • talking_cpp-tests to run/debug the unit-tests.
  5. With the selected target you can:
    1. Press F7 to build
    2. Press Ctrl+F5 to run
    3. Press F5 to debug
  6. Run CMake: Reveal Test Explorer to run spesific tests. use the TestMate C++ section.
    • Start/Stop continues test watch on each build (the eye icon icon):
      start/stop continues test watch
    • Go to talking_cpp-test.cpp, hover ovet the green Play/Play to the left of each test:
      run/debug a test case
    • Some shortcuts:
      • Ctrl+; Ctrl+C: Debug test at cursor
      • Ctrl+; Ctrl+F: Debug tests in current file

Small Features

  1. direnv Support: The repository includes a .envrc file for direnv integration.
    To enable it:

    1. Install direnv:

      apt install direnv
    2. Add the hook to your .bashrc file:

      # Enable direnv (place after rvm, git-prompt, or similar extensions)
      eval "$(direnv hook bash)"  
      export DIRENV_LOG_FORMAT=""  # Suppress direnv output
    3. Run direnv allow /path/to/project once, to enable direnv.

    Now, upon navigating to talking_cpp (cd talking_cpp), the virtual environment will be activated automatically, making all tools in the venv available seamlessly.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages