Main Content

pstest_add_profiling_runtime

(CMake) Create target for compiling a custom run-time library for code profiling

Since R2025a

Description

This function in the Polyspace® Test™ CMake package creates a target for compiling a custom run-time library for code profiling.

pstest_add_profiling_runtime(target CONFIG_HEADER_FILE file [library_type]) creates a target target for a custom version of the profiling run-time library.

example

Examples

collapse all

This example shows how to use a configuration header file to create a target for a custom profiling run-time library.

In your source folder, define the macros in the header file psprofile_config.h. For instance, this header file configures the library for executing the test executable on a 32-bit environment.

#ifndef PSPROFILE_CONFIG_H
#define PSPROFILE_CONFIG_H

#define PSPROFILE_SENDING_TYPE                  1
#define PSPROFILE_WORKING_BUFFER_SIZE       65536
#define PSPROFILE_HOST_EXECUTION                1 //Execution is on host
#define PSPROFILE_PROFILING_COUNTER_WIDTH      32 //32bit host

//Using the default timing functions
#define PSPROFILE_SAVE_DATETIME         psprofile_save_datetime 
#define PSPROFILE_GET_START_DATETIME    psprofile_getdatetime_start
#define PSPROFILE_GET_STOP_DATETIME     psprofile_getdatetime_stop

#endif

In your CMakeLists.txt file in the source folder, create a target for a shared profiling run-time library named myruntime.

pstest_add_profiling_runtime(myruntime CONFIG_HEADER_FILE psprofile_config.h SHARED)

Suppose that the target for the complied source code is mycode. When adding instrumentation to this target by using pstest_instrument_target, specify the profiling runtime as myruntime.

pstest_instrument_target(mycode COVERAGE LEVEL mcdc RUNTIME myruntime)

Input Arguments

collapse all

Name of target for custom profiling runtime, specified as a string. When instrumenting your code for a specified profiling type by using pstest_instrument_target, you provide this custom profiling run-time library target as an optional argument.

Example: myruntime

Name of a configuration header file that defines the required macros for profiling. See Create Library for Code Profiling Using Self-Managed Builds.

Example: psprofile_config.h

Specify whether to compile a static or a shared run-time library for profiling. If you do not specify this option, CMake uses the value of the BUILD_SHARED_LIBS variable to determine whether to build a static or shared library.

Version History

Introduced in R2025a