BASIS  version 1.2.3 (revision 2104)
runmcc.m
Go to the documentation of this file.
00001 %% @file  runmcc.m
00002 %% @brief Used to invoke MATLAB Compiler in MATLAB mode.
00003 %%
00004 %% Copyright (c) 2011 University of Pennsylvania. All rights reserved.<br />
00005 %% See http://www.rad.upenn.edu/sbia/software/license.html or COPYING file.
00006 %%
00007 %% Contact: SBIA Group <sbia-software at uphs.upenn.edu>
00008 %%
00009 %% @ingroup CMakeHelpers
00010 
00011 %% @brief Invoke the MATLAB Compiler and optionally exit MATLAB when finished.
00012 %%
00013 %% Invokes the MATLAB Compiler with the arguments given by varargin. See the
00014 %% documentation of the MATLAB Compiler mcc for a summary of the arguments.
00015 %% Further, when the option -q is given, this function quits the MATLAB
00016 %% interpreter when the MATLAB Compiler is finished.
00017 %%
00018 %% @param [in] varargin Arguments to MATLAB Compiler and option -q if
00019 %%                      MATLAB interpreter should be quit when finished.
00020 %%
00021 %% @returns Nothing.
00022 %%
00023 %% @ingroup CMakeHelpers
00024 
00025 function runmcc (varargin)
00026 % runmcc (varargin)  Invokes the MATLAB Compiler with the arguments
00027 %                    given by varargin. See the documentation of mcc
00028 %                    for a summary of the arguments. Further, when the
00029 %                    option -q is given, this function quits the MATLAB
00030 %                    interpreter on return.
00031 %
00032 % Contact: SBIA Group <sbia-software at uphs.upenn.edu>
00033 
00034 % parse arguments and append create mcc command
00035 cmd = 'mcc';
00036 q   = 0;
00037 
00038 for k = 1:size (varargin, 2)
00039   if (strcmp(varargin{k}, '-q'))
00040     q = 1;
00041   else
00042     cmd = [cmd ' ' varargin{k}];
00043   end
00044 end
00045 
00046 % execute mcc
00047 try
00048   eval (cmd);
00049 catch exception
00050   % do nothing, the output of the CMake command has to be
00051   % parsed for occurrences of 'Error' messages to detect
00052   % a failure during the build step with mcc
00053 end
00054 
00055 % quit MATLAB interpreter
00056 if (q)
00057   quit;
00058 end
00059