CMake Integration

Build Options

These options control how mu::tiny itself is built. Pass -D<OPTION>=<value> on the command line or configure them in a CMake presets file.

MUTINY_USE_STD_CPP_LIB

Boolean, default ON. Build mu::tiny with the C++ standard library. Set to OFF for bare-metal or freestanding targets where no <std> headers are available.

MUTINY_USE_STD_STRING

Boolean, default ON. Use std::string internally instead of mu::tiny’s own String class. Requires MUTINY_USE_STD_CPP_LIB.

MUTINY_EXAMPLES

Boolean. Build the example programs under examples/. Defaults to ON when mu::tiny is the top-level CMake project, OFF when consumed via FetchContent or add_subdirectory().

MUTINY_BUILD_TESTING

Boolean. Build mu::tiny’s own test suite. Defaults to ON at the top level, OFF when consumed. Relevant only for mu::tiny developers.

Package Variables

These variables are set by find_package(mutiny) and are available to consuming projects immediately after that call.

MUTINY_MODULE_PATH

Path to the directory containing Mutiny.cmake. find_package(mutiny) also appends this directory to CMAKE_MODULE_PATH so that include(mutiny) works without any extra setup.

CTest Integration Module

Provides CTest integration for the mutiny unit-testing framework.

include(mu.tiny)

After including this module the mutiny_discover_tests() command is available. It attaches a post-build step to a test executable that enumerates its tests and registers each one as an individual CTest test, giving fine-grained pass/fail reporting without requiring a CMake re-run when tests are added or removed.

Cache Variables

The following cache variables control default behaviour globally. Each may be overridden per target through the matching keyword argument of mutiny_discover_tests().

MUTINY_TESTS_DETAILED

Boolean option. When ON, each discovered test case is run as its own CTest invocation instead of sharing a single test-executable run. Default: OFF.

MUTINY_JUNIT_REPORT

Boolean option. When ON, each discovered test invocation receives a unique -pjunit=<target>.<group> argument so the executable emits a JUnit-format XML report named <target>.<group>.xml in the test’s working directory. One file is produced per CTest test, avoiding collisions when tests run in parallel. Default: OFF.

MUTINY_EXTRA_ARGS

Semicolon-separated list of extra command-line arguments forwarded to each discovered test invocation. Default: -v.

Commands

mutiny_discover_tests

Automatically register CTest tests by querying the compiled test executable:

mutiny_discover_tests(target
                      [DETAILED <bool>]
                      [EXTRA_ARGS <arg>...])

mutiny_discover_tests() adds a post-build command on target that runs the executable to list its test groups and names, then writes a generated .cmake file. CTest includes that file at test time to register each case individually. The function is a no-op when BUILD_TESTING is OFF.

target

Name of an executable target built by the current project. A FATAL_ERROR is raised if the target does not exist or is not an executable.

DETAILED <bool>

Override MUTINY_TESTS_DETAILED for this target.

EXTRA_ARGS <arg>...

Override MUTINY_EXTRA_ARGS for this target.

Cross-compilation: when CMAKE_CROSSCOMPILING is set, the target must have a CROSSCOMPILING_EMULATOR defined; if absent, discovery is skipped with a warning.