Project to help use Munit with CMake projects easily.
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")
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)
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)
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
.
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.
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
.