MATLAB: Create Visual Studio Solution File in Release Mode with Simulink Coder

simulink coder

I am generating a Visual C/C++ solution from Simulink Coder with "grt.tlc". By default, Simulink Coder always generate a Visual C/C++ solution in Debug Mode. However, I would like the solution file to be generated for Release mode (<https://msdn.microsoft.com/en-us/library/wx0123s5.aspx>). At the moment, I have to manually convert from Debug to Release mode, which requires a lot of copy/paste inside the Visual Studio project file in order to provide the desired options for Release mode. Therefore, I have the following questions:
1. Is there any way to generate Visual Studio project in Release Mode?
2. Is it possible to customize the "RTW.MSVCBuild" so that I can adjust the code as per my needs, i.e. customizing Release Mode options, relative paths instead of absolute ones?

Best Answer

Unfortunately, the ability to configure Simulink Coder to generate a Visual Studio solution in Release Mode is currently unavailable, and it is not possible to customize the p-coded "RTW.MSVCBuild" file.
As a workaround, the best option would be to customize the build process using the "STF_rtw_make_hook" file to configure the options you would like for your Visual Studio solution. This is a MATLAB file that implements a function to execute certain target-specific actions at various points during the code generation and build process. How to configure the hooks at various stages is described here:
For reference, MATLAB opens Visual Studio instance via COM in order to create a Visual Studio solution. Therefore, you can use a similar approach for your custom options. You can customize the build process to launch a new Visual Studio instance via COM at the end of the build, which configures your project with the desired options. In this case, you would likely use the "after_make" or "exit" hook.