create_test_sourcelist.rst 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. ``<driverName>``
  17. Name of the test driver source file to be generated into the build tree.
  18. The source file will contain a ``main()`` program entry point that
  19. dispatches to whatever test is named on the command line.
  20. ``<test>...``
  21. Test source files to be added to the driver binary. Each test source
  22. file must have a function in it that is the same name as the file with the
  23. extension removed. For example, a ``foo.cxx`` test source might contain:
  24. .. code-block:: c++
  25. int foo(int argc, char** argv)
  26. ``EXTRA_INCLUDE <header>``
  27. Specify a header file to ``#include`` in the generated test driver source.
  28. ``FUNCTION <function>``
  29. Specify a function to be called with pointers to ``argc`` and ``argv``.
  30. The function may be provided in the ``EXTRA_INCLUDE`` header:
  31. .. code-block:: c++
  32. void function(int* pargc, char*** pargv)
  33. This can be used to add extra command line processing to each test.
  34. Additionally, some CMake variables affect test driver generation:
  35. .. variable:: CMAKE_TESTDRIVER_BEFORE_TESTMAIN
  36. Code to be placed directly before calling each test's function.
  37. .. variable:: CMAKE_TESTDRIVER_AFTER_TESTMAIN
  38. Code to be placed directly after the call to each test's function.