This is a basic C++ template project for quickly starting new projects. It includes a basic file structure and CMake build configuration.
There are two ways to use this template: creating a new project from scratch and using the "Use this template" function in GitHub.
To create a new project from scratch using this template, first you need to install go-task
as described in Installing go-task
session.
Then simply run the following script in a new folder and start adding your own source files.
curl https://raw.githubusercontent.com/merlinvn/cpp-template/master/Taskfile.yml -o Taskfile.yml
go-task new
# or `go-task new:vcpkg` to include vcpkg submodule
The existing files can be used as a reference for how to structure your project and how to use CMake.
Another way to use the template is by clicking the "Use this template" button on the GitHub repository page. This will create a new repository based on the template, allowing you to quickly start a new project without the need to clone the repository and manually set up the files.
You can also choose to create the new repository in your personal account or in an organization where you have write access.
Before building the project, you will need to have the following packages installed on your system:
sudo apt-get install build-essential cmake pkg-config curl zip unzip tar
sudo dnf install gcc-c++ cmake pkgconfig curl zip unzip tar
sudo yum install gcc-c++ cmake pkgconfig curl zip unzip tar
sudo zypper install pattern devel_C_C++ cmake pkgconfig curl zip unzip tar
sudo pacman -S base-devel cmake pkg-config curl zip unzip tar cmake ninja
apk add build-base cmake ninja zip unzip curl git
(and export VCPKG_FORCE_SYSTEM_BINARIES=1)
In order to build the project using go-task
, you will need to have go-task installed on your system.
The simplest way to install go-task
is by using curl
:
sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
You can add an terminal aliases for your convinient:
alias t=go-task
For other ways to install go-task
please refer to go-task installation page
The project can be built using either go-task or CMake.
To build the project using go-task, you will need to have go-task installed on your system. Once go-task is installed, simply run the following command in the root directory of the project:
go-task build
The default generator is Ninja
, to generate Unix Makefiles
project, you can run
go-task build GENERATOR='"Unix Makefiles"'
Default build will build Release
. To build Debug
, run the following command:
go-task build:debug
# or
go-task build CONFIG=Debug
Other possible values for CONFIG
are RelWithDebInfo
and MinSizeRel
To build the project using CMake, run the following commands in the root directory of the project:
mkdir build
cd build
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_BUILD_TYPE=Release
make
To remove build
folder, run the following command:
go-task clean
#or
rm -rf build
rm -f compile_commands.json
- add .clang-format
- add .clang-tidy
- github actions??