To share build configuration settings between multiple projects or between the project and command-line workflow, you can export settings to and import settings from a code generation configuration object.
This functionality is not supported in MATLAB® Online™.
You can export project file settings to a code configuration object by using the MATLAB Coder™ app or at the command line. The type of the configuration object depends on the project file settings.
Project File Settings in MATLAB Coder App | Code Configuration Object |
Build type is MEX. | coder.MexCodeConfig |
Build type is static library, dynamically linked library, or executable. One of the following conditions is true:
| coder.CodeConfig |
Build type is static library, dynamically linked library, or executable. You have Embedded Coder. On the All Settings tab,
Use Embedded Coder features is set to
| coder.EmbeddedCodeConfig |
You can then either import these settings into another project or use
the configuration object with the codegen
function -config
option to generate code at
the command line.
In the MATLAB Coder app:
To open the Generate dialog box, on the
Generate Code page, click the
Generate arrow .
Set Build type to Source
Code
, Static Library
,
Dynamic Library)
, or
Executable
(depending on your
requirements).
Click More Settings.
Click Import/Export Settings.
In the Variable name field, specify a name for the configuration object.
Click Export to Variable.
MATLAB Coder saves the project settings information in a configuration object with the specified name in the base workspace.
At the MATLAB command line, use the -toconfig
option with the
coder
command to export the code
configuration settings stored in a MATLAB
Coder project file to a code configuration object. For example, executing
this command returns a code configuration object cfg
corresponding
to
myProject.prj
.
cfg = coder('-toconfig','myProject.prj')
To import the settings saved in a code generation configuration object stored in the base workspace:
To open the Generate dialog box, on the
Generate Code page, click the
Generate arrow .
Set Build type to Source
Code
, Static Library
,
Dynamic Library
, or
Executable
(depending on your
requirements).
Click More Settings.
Click Import/Export Settings.
In the Variable name field, specify the name of the configuration object.
Click Import from Variable.