BCMTest

bcm_mark_as_test

This marks the target as a test, so it will be built with the tests target. If BUILD_TESTING is set to off then the target will not be built as part of the all target.

bcm_test

This setups a test. By default, a test will be built and executed.

SOURCES <source-files>...

Source files to be compiled for the test.

CONTENT <content>

This a string that will be used to create a test to be compiled and/or ran.

NAME <name>

Name of the test.

ARGS <args>

This sets additional arguments to be passed to the test executable when it will be ran.

COMPILE_ONLY

This just compiles the test instead of running it. As such, a main function is not required.

WILL_FAIL

Specifies that the test will fail.

NO_TEST_LIBS

This won’t link in the libraries specified by bcm_test_link_libraries

bcm_test_header

This creates a test to test the include of a header.

NAME <name>

Name of the test.

HEADER <header-file>

The header to include.

STATIC

Rather than just test the include, using STATIC option will test the include across translation units. This helps check for incorrect include guards and duplicate symbols.

NO_TEST_LIBS

This won’t link in the libraries specified by bcm_test_link_libraries

bcm_add_test_subdirectory

This calls add_subdirectory if the ENABLE_TESTS property is true. The default value for the property is set by CMAKE_ENABLE_TESTS variable.