Overview of Polyspace Test CMake Package
CMake is a third-party, open source tool for build process management that allows you to specify the build instructions for your code base in a platform and toolchain independent CMake language. When using CMake, you:
Create a
CMakeLists.txtfile that contains the build instructions in the CMake language.Invoke the
cmakecommand that uses theCMakeLists.txtfile to generate standard build files. These include makefile and Ninja, as well as Microsoft® Visual Studio® and Xcode project builds.
To learn more about CMake, see the CMake Tutorial.
Polyspace® Test™ includes a CMake package that supplements the standard CMake API with additional variables, targets, and functions. You can use this package to manage testing and profiling workflows including:
Instrumenting source code for profiling
Linking source and test targets to the
pstunittarget to create an executableConverting test and code profiling results to standard Polyspace Test formats
Generating XML and HTML reports from test and code profiling results
Prerequisites and Supported Testing Frameworks
To use the Polyspace
Test CMake package (pstest package), you must have CMake version 13.0.0 or higher.
The pstest CMake package supports tests authored using:
Polyspace Test xUnit API
GoogleTest framework
pstest Targets
Suppose that you author tests using the Polyspace
Test xUnit API. In your CMakeLists.txt file, once you define a target for your test executable, you must link this target against the Polyspace
Test C or C++ target. To simplify this workflow, the Polyspace
Test CMake package includes these two targets:
pstest::pstest_cpstest::pstest_cpp
For example, suppose that your C++ test executable is named testRunner. To link this executable against your source library sourceLib and the Polyspace
Test C++ target, include this command in your CMakeLists.txt file:
target_link_libraries(testRunner sourceLib pstest::pstest_cpp)pstest Functions
When authoring your CMakeLists.txt file, you can use these functions in addition to the standard CMake API.
| Function | Description |
|---|---|
Create target for compiling a custom run-time library for code profiling | |
Instrument a target for profiling | |
Create target for converting test or code profiling results to standard Polyspace Test format | |
Create target for generating XML and HTML reports from test or code profiling results |
pstest Variables
To reference individual files and folders in polyspaceroot/polyspace/pstest/pstunit in your CMakeLists.txt file, use these variables. Here, polyspaceroot is the Polyspace
Test installation folder, for example /usr/local/Polyspace/R2025a.
| Variable | Description |
|---|---|
pstest_INCLUDE_DIRS | Absolute path to the |
pstest_SRC_C | Absolute path to the |
pstest_SRC_CXX | Absolute path to the |
See Also
pstest_add_profiling_runtime | pstest_instrument_target | pstest_add_convert_target | pstest_add_report_target