Skip to content

silwalanish/cpp-starter-kit

Repository files navigation

cpp-starter-kit

A simple attempt at making building c++ projects easier.

Features

  • Uses conan.io to manage dependencies.
  • Uses make as build system.
  • Uses gtest for unit tests.

Usage

Creating a new project

  • Clone the repository.
  • Update the name and description of the project in the file ProjectInfo.mk.

Alternatively,

  • Run the create-cpp-project script.
$ bash <(curl -s https://raw.githubusercontent.com/silwalanish/cpp-starter-kit/main/create-cpp-project.sh) -n ${PROJECT_NAME} -p ${PROJECT_PATH}

Configurations

  • Add any build parameters in BuildOptions.mk.
  • Add dependencies in conanfile.py.

setup

Install dependencies

$ make setup

compile

Run to compile the project.

$ make compile

build

Run to link and build the executable. Will create a executable name as {EXECUTABLE_NAME} set in BuildOptions.mk.

$ make build

Or just

$ make

run

Run to execute the project.

$ make run

test

Runs the unit tests.

$ make test

clean

Run to clean compile artifacts.

$ make clean

Project Structure

\
|--> includes
|--> libs
|--> src
|--> vendor

includes

  • Contains the header files for external dependencies.
includes
|--> Dependency1 
|--> Dependency2
.
.
.
|--> DependencyN

Note: Use conan to install dependencies if possible.

libs

  • Stores the static build of library of external dependencies
libs
|--> Debug
     |-> Linux
         |-> x86
             |-> Dependency1.lib
             |-> Dependency2.lib
         |-> x64
             |-> Dependency1.lib
             |-> Dependency2.lib
     |-> Win
         ...
     |-> MacOs
         ...
|--> Release
     |-> Linux
         ...
     |-> Win
         ...
     |-> MacOs
         ...

Note: Use conan to install dependencies if possible.

src

  • Source files for the project.

How to install a dependency?

Avaliable as conan package?

  • If available as a conan package, add the package in conanfile.py.

Header Only?

  • Add the headers in the includes directory.

Prebuilt binary and headers available?

  • Add headers to includes directory.
  • Add prebuilt binaries to libs directory.
  • Update CCFLAGS/CFLAGS in BuildOptions.mk to link the library.

Need to build manually?

  • Build the dependency following the instruction for the dependency.
  • Copy the binaries to libs directory.
  • Update CCFLAGS/CFLAGS in BuildOptions.mk to link the library.
  • Copy the headers to includes directory.

About

A Makefile to compile, link and build c++ project.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published