Share Build Configuration Settings
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™.
Export Settings
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. For example, if you export to the configuration object
cfg
, you can use this configuration object with the
-config
option of the codegen
command.
codegen -config cfg myfunction
Export Settings by Using the MATLAB Coder App
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)
, orExecutable
(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.
Export Settings at the Command Line
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')
Import Settings
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
, orExecutable
(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.