Skip to content
/ cmake-template Public template

A template for building c++ project with cmake.

License

Notifications You must be signed in to change notification settings

Y-jiji/cmake-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CMake Template

A template for c++ projects with cmake.

This is a template that I personally used for single artifact projects.

This template automates source file and dependency management.

Get Started

You can build a project with the following commands:

cmake -S . -B build 
cmake --build build -j

Run Unit Tests

You can also run unit tests for your library.

ctest --test-dir build

Find Source Files

This template builds one library and multiple executables.

AutoBuild(
    LIB_DIR "lib" SHARED   # Where to search for library source and headers
    BIN_DIR "bin"          # Where to search for executable source
)

Fetch Dependencies

You can declare a dependency https://github.com/nlohmann/json with package name nlohmann_json.

The PRIVATE flag will make the dependency private. You can also use PUBLIC flag.

The FLAGS feeds into the process that runs CMAKE INSTALL.

Git(
    SITE    "https://github.com"
    USER    "nlohmann"
    REPO    "json"
    PACK    "nlohmann_json"
    BRANCH  "v3.11.3"
    PIPELINE "CMAKE INSTALL" FLAGS "-DJSON_BuildTests=OFF" PRIVATE
)

Unit Tests

By default, any file with suffix .test.cpp will be excluded from the library source.

Instead, they will be included as unit tests for the library.

About

A template for building c++ project with cmake.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published