Skip to content

cppmf/ModernSharedLibTemplate

Repository files navigation

ModernSharedLibTemplate

This is a template for static and shared library which give a good starter point for new C++ project. It has been designed to use Modern CMake practices in mind, and should be a good starting point for both people willing to learn it and those who want to update their own project.

Ubuntu MacOS Windows

codecov Quality Gate Status Coverage Maintainability Rating

Features

Todo

Usage

All source code can be found in the following directories :

  • include\mlt :
    • Replace the mlt directory according to the PROJECT_ID defined in CMakeLists.txt
    • Add your own source code.
  • src :
    • Add your own source code.

then add you files to CMakeLists_files.cmake.

Build as static lib

Use the following commands to build as a static library.

cmake -S . -B build/static -DBUILD_SHARED_LIBS=NO -DMLT_PACKAGE=YES -DCMAKE_INSTALL_PREFIX=install
cmake --build build/static --target install

Build as shared lib

Use the following commands to build as a shared library.

cmake -S . -B build/shared -DBUILD_SHARED_LIBS=YES -DMLT_PACKAGE=YES -DCMAKE_INSTALL_PREFIX=install
cmake --build build/shared --target install

Build and run test suite

Use the following commands to run the test suite.

cmake -S test -B build/test
cmake --build build/test
cmake --build build/test --target test

# for more details, run:
./build/test/ModernSharedLibTemplateTest

Build the documentation

Use the following commands to manually build the documentation.

cmake -S doc -B build/doc
cmake --build build/doc --target GenerateDocs

Related projects

CppMfLibTemplate got inspired from the following :