Skip to content

mmalenic/cmake-toolbelt

Repository files navigation

Logo
MIT licensed Build status

cmake-toolbelt

A small collection of CMake build code which adds some missing functionality and reduces repetitive build configurations.

This repository contains a C23 #embed replacement, functions for better dependency management, utilities for defining required args and enums, and combinator functions for check_ commands.

Usage

To use this library, you can use CMake’s FetchContent to import the project. All library commands are available after including with a toolbelt_ prefix:

include(FetchContent)

# Fetch content from this repo.
FetchContent_Declare(
     toolbelt
     GIT_REPOSITORY https://github.com/mmalenic/cmake-toolbelt
     GIT_TAG v0.3.0
)
FetchContent_MakeAvailable(toolbelt)

# Allow cmake to find the src directory.
list(APPEND CMAKE_MODULE_PATH "${toolbelt_SOURCE_DIR}/src")
include(toolbelt)

Alternatively, copy and paste the code in the src directory and include the library using include(toolbelt).

Why does this project exist?

The motivation behind this project is to define a common set of CMake functions that I use for a variety of C++ projects.

There are countless CMake “helper”-style libraries. See a list of some of the here. This project does not aim to replace these, however it does contain some code which existing libraries lack, such as interactions with the CMake check_ commands.

Development

This project contains a set of unit tests for the toolbelt commands. These can be run using pytest and poetry. After initializing the poetry project, run the tests using pytest:

pytest

The documentation for this project (including this README) is made using sphinx, and published to github pages. To generate documentation, run the following in the docs directory to create a static page:

make html

Run the following to update this README.md:

make readme

Contributions are welcome. Feel free to open any pull requests or issues.

Licence

This project is licensed under the MIT licence.