Skip to content

Project to help use Munit with CMake projects easily.

License

Notifications You must be signed in to change notification settings

krxecs/Munit.cmake

Repository files navigation

Munit.cmake

standard-readme compliant

Project to help use Munit with CMake projects easily.

Table of Contents

Install

Using CPM.cmake

After adding CPM.cmake, add the following line to the project's CMakeLists.txt after calling project(...).

include(cmake/CPM.cmake)
CPMAddPackage("gh:krxecs/Munit.cmake#origin/main")

Using FetchContent

You can also include this project using FetchContent:

include(FetchContent)
FetchContent_Declare(Munit.cmake
  GIT_REPOSITORY https://github.com/krxecs/Munit.cmake
  GIT_TAG origin/main
  CONFIGURE_COMMAND ""
  BUILD_COMMAND ""
)
FetchContent_Populate(Munit.cmake)

Usage

First, install the project. Then, before calling any module for this project, call munit_cmake_init:

munit_cmake_init()

Then, include DownloadMunit.cmake (or DownloadMunitCPM.cmake) to download Munit:

include(DownloadMunit)  # or include(DownloadMunitCPM.cmake)

Link all your test targets with munit target & register their tests with munit_discover_tests:

add_executable(test_exe test.c)
target_link_libraries(test_exe
  munit
  # Other targets
)
munit_discover_tests(test_exe)

API

There is only one major function you need to use, munit_discover_tests. The function call along with all its parameters are:

munit_discover_tests(target
                     [NO_FORK]
                     [SHOW_STDERR]
                     [FATAL_FAILURES]
                     [SINGLE]
                     [ITERATIONS n]
                     [WORKING_DIRECTORY dir]
                     [SEED s]
                     [LOG_VISIBLE level]
                     [LOG_FATAL level]
                     [TEST_PREFIX prefix]
                     [TEST_SUFFIX suffix]
                     [EXTRA_ARGS arg1...]
                     [PARAMS arg1...]
)

The meaning of these options can be found in the file Munit.cmake.

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as below, without any additional terms or conditions.

License

Licensed under the BSD Zero Clause License. See LICENSE file in the project root, or https://opensource.org/licenses/0BSD for full license information.

The SPDX license identifier for this project is 0BSD.

About

Project to help use Munit with CMake projects easily.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages