1
0

create_test_sourcelist.rst 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. create_test_sourcelist
  2. ----------------------
  3. Create a test driver program that links together many small tests into a
  4. single executable. This is useful when building static executables with
  5. large libraries to shrink the total required size.
  6. .. signature::
  7. create_test_sourcelist(<sourceListName> <driverName> <test>... <options>...)
  8. :target: original
  9. Generate a test driver source file from a list of individual test sources
  10. and provide a combined list of sources that can be built as an executable.
  11. The options are:
  12. ``<sourceListName>``
  13. The name of a variable in which to store the list of source files needed
  14. to build the test driver. The list will contain the ``<test>...`` sources
  15. and the generated ``<driverName>`` source.
  16. .. versionchanged:: 3.29
  17. The test driver source is listed by absolute path in the build tree.
  18. Previously it was listed only as ``<driverName>``.
  19. ``<driverName>``
  20. Name of the test driver source file to be generated into the build tree.
  21. The source file will contain a ``main()`` program entry point that
  22. dispatches to whatever test is named on the command line.
  23. ``<test>...``
  24. Test source files to be added to the driver binary. Each test source
  25. file must have a function in it that is the same name as the file with the
  26. extension removed. For example, a ``foo.cxx`` test source might contain:
  27. .. code-block:: c++
  28. int foo(int argc, char** argv)
  29. ``EXTRA_INCLUDE <header>``
  30. Specify a header file to ``#include`` in the generated test driver source.
  31. ``FUNCTION <function>``
  32. Specify a function to be called with pointers to ``argc`` and ``argv``.
  33. The function may be provided in the ``EXTRA_INCLUDE`` header:
  34. .. code-block:: c++
  35. void function(int* pargc, char*** pargv)
  36. This can be used to add extra command line processing to each test.
  37. Additionally, some CMake variables affect test driver generation:
  38. .. variable:: CMAKE_TESTDRIVER_BEFORE_TESTMAIN
  39. Code to be placed directly before calling each test's function.
  40. .. variable:: CMAKE_TESTDRIVER_AFTER_TESTMAIN
  41. Code to be placed directly after the call to each test's function.