Help: Modernize create_test_sourcelist documentation

This commit is contained in:
Brad King
2024-02-22 09:13:50 -05:00
parent 2f91902f08
commit c21f0eb30b

View File

@@ -1,29 +1,57 @@
create_test_sourcelist create_test_sourcelist
---------------------- ----------------------
Create a test driver and source list for building test programs. Create a test driver program that links together many small tests into a
single executable. This is useful when building static executables with
large libraries to shrink the total required size.
.. code-block:: cmake .. signature::
create_test_sourcelist(<sourceListName> <driverName> <test>... <options>...)
:target: original
create_test_sourcelist(<sourceListName> <driverName> Generate a test driver source file from a list of individual test sources
<tests> ... and provide a combined list of sources that can be built as an executable.
[EXTRA_INCLUDE <include>]
[FUNCTION <function>])
A test driver is a program that links together many small tests into a single The options are:
executable. This is useful when building static executables with large
libraries to shrink the total required size. The list of source files needed ``<sourceListName>``
to build the test driver will be in ``sourceListName``. ``driverName`` is the The name of a variable in which to store the list of source files needed
name of the test driver program. The rest of the arguments consist of a list to build the test driver. The list will contain the ``<test>...`` sources
of test source files and can be semicolon separated. Each test source file and the generated ``<driverName>`` source.
should have a function in it that is the same name as the file with no
extension (``foo.cxx`` should have ``int foo(int, char*[]);``). ``driverName`` ``<driverName>``
will be able to call each of the tests by name on the command line. If Name of the test driver source file to be generated into the build tree.
``EXTRA_INCLUDE`` is specified, then the next argument is included into the The source file will contain a ``main()`` program entry point that
generated file. If ``FUNCTION`` is specified, then the next argument is taken dispatches to whatever test is named on the command line.
as a function name that is passed pointers to ``argc`` and ``argv``. This can
be used to add extra command line processing to each test. The ``<test>...``
``CMAKE_TESTDRIVER_BEFORE_TESTMAIN`` cmake variable can be set to have code Test source files to be added to the driver binary. Each test source
that will be placed directly before calling the test ``main`` function. file must have a function in it that is the same name as the file with the
``CMAKE_TESTDRIVER_AFTER_TESTMAIN`` can be set to have code that will be extension removed. For example, a ``foo.cxx`` test source might contain:
placed directly after the call to the test ``main`` function.
.. code-block:: c++
int foo(int argc, char** argv)
``EXTRA_INCLUDE <header>``
Specify a header file to ``#include`` in the generated test driver source.
``FUNCTION <function>``
Specify a function to be called with pointers to ``argc`` and ``argv``.
The function may be provided in the ``EXTRA_INCLUDE`` header:
.. code-block:: c++
void function(int* pargc, char*** pargv)
This can be used to add extra command line processing to each test.
Additionally, some CMake variables affect test driver generation:
.. variable:: CMAKE_TESTDRIVER_BEFORE_TESTMAIN
Code to be placed directly before calling each test's function.
.. variable:: CMAKE_TESTDRIVER_AFTER_TESTMAIN
Code to be placed directly after the call to each test's function.