This section describes how to configure a custom embedded target to support compiler optimization level control. Without the described modifications, you cannot use model configuration parameter Compiler optimization level to control the compiler optimization level for building generated code. For more information about compiler optimization level control, see Compiler optimization level.
The requirements for supporting compiler optimization level control are as follows:
The target must be derived from the GRT target or the ERT target.
The system target file must declare compiler optimization level control compliance, as described in Declaring Compiler Optimization Level Control Compliance.
The target makefile must honor the setting for model configuration parameter Compiler optimization level, as described in Providing Compiler Optimization Level Control Support in the Target Makefile.
For an example that shows how to configure custom target optional features, see Customize System Target Files.
To declare compiler optimization level control compliance for your target, you must
implement a callback function that sets the
and then install the callback function in the
SelectCallback field of the
rtwgensettings structure in your system target file. The callback
function is triggered whenever the user selects the target in the System Target File
Browser. For example, the following system target file code installs a
SelectCallback function named
rtwgensettings.SelectCallback = 'custom_select_callback_handler(hDlg,hSrc)';
The arguments to the
hSrc) are handles to private data used by the
callback API functions. These handles are restricted to use in system target file callback
functions. They should be passed in without alteration.
Your callback function should set the
CompOptLevelCompliant flag as
slConfigUISetVal(hDlg,hSrc,'CompOptLevelCompliant','on'); slConfigUISetEnabled(hDlg,hSrc,'CompOptLevelCompliant',false); hSrc.refreshDialog;
CompOptLevelCompliant target configuration parameter is set
on, the Compiler optimization level parameter is
displayed in the Code Generation pane of the Configuration Parameters
dialog box for your model.
As part of supporting compiler optimization level control for your target, you must modify the target makefile to honor the setting for model configuration parameter Compiler optimization level. Use a GRT or ERT target provided by MathWorks as a model for making the modifications.