Git Product home page Git Product logo

cpp-cmake-template's Introduction

main

cpp-cmake-template

Template for a multi platform CMake C++ project that includes:

  • VSCode files
  • Github Actions
  • Test suite using CTest
  • Dockerfile
  • ccache (object files caching)
  • clang-format (running automatically as pre-commit git hook)

Requirements:

  • CMake
  • Clang
  • LLDB
  • clang-format
  • ccache (optional)
  • VSCode 'CodeLLDB' extension (optional)
  • Visual Studio, MSVC compiler (Windows only)

Set up project:

./ProjectFolder/scripts/build_cmake_debug.sh

or execute VSCode task build_cmake_debug.

Build and Debug:

./ProjectFolder/scripts/build_debug.sh

or execute VSCode task build_debug.

Followed by:

lldb ./build/Debug/bin/cpp-cmake-template

or launch VSCode DEBUG configuration.

Run tests:

./ProjectFolder/scripts/run_tests.sh

or execute VSCode task run_tests.

Run tests in a Docker container:

docker compose down --volumes --rmi all
docker compose up

Build release:

./ProjectFolder/scripts/create_release.sh

or execute VSCode task create_release.

Windows:

Use .ps1 scripts in ProjectFolder/scripts/windows folder
or same VSCode tasks, as listed above.

Notes:

  • To add new files:
    • create a new folder in ProjectFolder/src
    • add *.cpp and *.h files into it.
    • Remember to re-run build_cmake_debug
  • To add new tests:
    • add new test_*.cpp files in ProjectFolder/test.
    • Remember to re-run build_cmake_debug

Possible future improvements:

  • Fix Windows built files path
  • Static checker (BASH and cpp)
  • E2E tests (other than just building, also running the binary to see if there are any run-time errors)
  • CMake install

cpp-cmake-template's People

Contributors

mortinger91 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.