How to programmatically enable external mode in Simulink Coder

Use the following command to programmatically enable external mode in the Simulink Coder configuration for the currently open Simulink model

cs = getActiveConfigSet(gcs)
set_param(cs, "ExtMode", "on")