| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| |
| |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| |
| <title>FindMatlab — CMake 3.8.2 Documentation</title> |
| |
| |
| <link rel="stylesheet" href="../_static/cmake.css" type="text/css" /> |
| <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> |
| |
| <script type="text/javascript"> |
| var DOCUMENTATION_OPTIONS = { |
| URL_ROOT: '../', |
| VERSION: '3.8.2', |
| COLLAPSE_INDEX: false, |
| FILE_SUFFIX: '.html', |
| HAS_SOURCE: true, |
| SOURCELINK_SUFFIX: '.txt' |
| }; |
| </script> |
| <script type="text/javascript" src="../_static/jquery.js"></script> |
| <script type="text/javascript" src="../_static/underscore.js"></script> |
| <script type="text/javascript" src="../_static/doctools.js"></script> |
| <link rel="shortcut icon" href="../_static/cmake-favicon.ico"/> |
| <link rel="index" title="Index" href="../genindex.html" /> |
| <link rel="search" title="Search" href="../search.html" /> |
| <link rel="next" title="FindMFC" href="FindMFC.html" /> |
| <link rel="prev" title="FindLua" href="FindLua.html" /> |
| </head> |
| <body role="document"> |
| <div class="related" role="navigation" aria-label="related navigation"> |
| <h3>Navigation</h3> |
| <ul> |
| <li class="right" style="margin-right: 10px"> |
| <a href="../genindex.html" title="General Index" |
| accesskey="I">index</a></li> |
| <li class="right" > |
| <a href="FindMFC.html" title="FindMFC" |
| accesskey="N">next</a> |</li> |
| <li class="right" > |
| <a href="FindLua.html" title="FindLua" |
| accesskey="P">previous</a> |</li> |
| <li> |
| <img src="../_static/cmake-logo-16.png" alt="" |
| style="vertical-align: middle; margin-top: -2px" /> |
| </li> |
| <li> |
| <a href="https://cmake.org/">CMake</a> » |
| </li> |
| <li> |
| <a href="../index.html">3.8.2 Documentation</a> » |
| </li> |
| |
| <li class="nav-item nav-item-1"><a href="../manual/cmake-modules.7.html" accesskey="U">cmake-modules(7)</a> »</li> |
| </ul> |
| </div> |
| |
| <div class="document"> |
| <div class="documentwrapper"> |
| <div class="bodywrapper"> |
| <div class="body" role="main"> |
| |
| <div class="section" id="findmatlab"> |
| <span id="module:FindMatlab"></span><h1>FindMatlab<a class="headerlink" href="#findmatlab" title="Permalink to this headline">¶</a></h1> |
| <p>Finds Matlab installations and provides Matlab tools and libraries to cmake.</p> |
| <p>This package first intention is to find the libraries associated with Matlab |
| in order to be able to build Matlab extensions (mex files). It can also be |
| used:</p> |
| <ul class="simple"> |
| <li>run specific commands in Matlab</li> |
| <li>declare Matlab unit test</li> |
| <li>retrieve various information from Matlab (mex extensions, versions and |
| release queries, ...)</li> |
| </ul> |
| <p>The module supports the following components:</p> |
| <ul class="simple"> |
| <li><code class="docutils literal"><span class="pre">MX_LIBRARY</span></code>, <code class="docutils literal"><span class="pre">ENG_LIBRARY</span></code> and <code class="docutils literal"><span class="pre">MAT_LIBRARY</span></code>: respectively the MX, |
| ENG and MAT libraries of Matlab</li> |
| <li><code class="docutils literal"><span class="pre">MAIN_PROGRAM</span></code> the Matlab binary program.</li> |
| <li><code class="docutils literal"><span class="pre">MEX_COMPILER</span></code> the MEX compiler.</li> |
| <li><code class="docutils literal"><span class="pre">SIMULINK</span></code> the Simulink environment.</li> |
| </ul> |
| <div class="admonition note"> |
| <p class="first admonition-title">Note</p> |
| <p class="last">The version given to the <span class="target" id="index-0-command:find_package"></span><a class="reference internal" href="../command/find_package.html#command:find_package" title="find_package"><code class="xref cmake cmake-command docutils literal"><span class="pre">find_package()</span></code></a> directive is the Matlab |
| <strong>version</strong>, which should not be confused with the Matlab <em>release</em> name |
| (eg. <cite>R2014</cite>). |
| The <span class="target" id="index-0-command:matlab_get_version_from_release_name"></span><a class="reference internal" href="#command:matlab_get_version_from_release_name" title="matlab_get_version_from_release_name"><code class="xref cmake cmake-command docutils literal"><span class="pre">matlab_get_version_from_release_name()</span></code></a> and |
| <span class="target" id="index-0-command:matlab_get_release_name_from_version"></span><a class="reference internal" href="#command:matlab_get_release_name_from_version" title="matlab_get_release_name_from_version"><code class="xref cmake cmake-command docutils literal"><span class="pre">matlab_get_release_name_from_version()</span></code></a> allow a mapping |
| from the release name to the version.</p> |
| </div> |
| <p>The variable <span class="target" id="index-0-variable:Matlab_ROOT_DIR"></span><a class="reference internal" href="#variable:Matlab_ROOT_DIR" title="Matlab_ROOT_DIR"><code class="xref cmake cmake-variable docutils literal"><span class="pre">Matlab_ROOT_DIR</span></code></a> may be specified in order to give |
| the path of the desired Matlab version. Otherwise, the behaviour is platform |
| specific:</p> |
| <ul class="simple"> |
| <li>Windows: The installed versions of Matlab are retrieved from the |
| Windows registry</li> |
| <li>OS X: The installed versions of Matlab are given by the MATLAB |
| paths in <code class="docutils literal"><span class="pre">/Application</span></code>. If no such application is found, it falls back |
| to the one that might be accessible from the PATH.</li> |
| <li>Unix: The desired Matlab should be accessible from the PATH.</li> |
| </ul> |
| <p>Additional information is provided when <span class="target" id="index-0-variable:MATLAB_FIND_DEBUG"></span><a class="reference internal" href="#variable:MATLAB_FIND_DEBUG" title="MATLAB_FIND_DEBUG"><code class="xref cmake cmake-variable docutils literal"><span class="pre">MATLAB_FIND_DEBUG</span></code></a> is set. |
| When a Matlab binary is found automatically and the <code class="docutils literal"><span class="pre">MATLAB_VERSION</span></code> |
| is not given, the version is queried from Matlab directly. |
| On Windows, it can make a window running Matlab appear.</p> |
| <p>The mapping of the release names and the version of Matlab is performed by |
| defining pairs (name, version). The variable |
| <span class="target" id="index-0-variable:MATLAB_ADDITIONAL_VERSIONS"></span><a class="reference internal" href="#variable:MATLAB_ADDITIONAL_VERSIONS" title="MATLAB_ADDITIONAL_VERSIONS"><code class="xref cmake cmake-variable docutils literal"><span class="pre">MATLAB_ADDITIONAL_VERSIONS</span></code></a> may be provided before the call to |
| the <span class="target" id="index-1-command:find_package"></span><a class="reference internal" href="../command/find_package.html#command:find_package" title="find_package"><code class="xref cmake cmake-command docutils literal"><span class="pre">find_package()</span></code></a> in order to handle additional versions.</p> |
| <p>A Matlab scripts can be added to the set of tests using the |
| <span class="target" id="index-0-command:matlab_add_unit_test"></span><a class="reference internal" href="#command:matlab_add_unit_test" title="matlab_add_unit_test"><code class="xref cmake cmake-command docutils literal"><span class="pre">matlab_add_unit_test()</span></code></a>. By default, the Matlab unit test framework |
| will be used (>= 2013a) to run this script, but regular <code class="docutils literal"><span class="pre">.m</span></code> files |
| returning an exit code can be used as well (0 indicating a success).</p> |
| <div class="section" id="module-input-variables"> |
| <h2>Module Input Variables<a class="headerlink" href="#module-input-variables" title="Permalink to this headline">¶</a></h2> |
| <p>Users or projects may set the following variables to configure the module |
| behaviour:</p> |
| <dl class="docutils"> |
| <dt><span class="target" id="index-1-variable:Matlab_ROOT_DIR"></span><a class="reference internal" href="#variable:Matlab_ROOT_DIR" title="Matlab_ROOT_DIR"><code class="xref cmake cmake-variable docutils literal"><span class="pre">Matlab_ROOT_DIR</span></code></a></dt> |
| <dd>the root of the Matlab installation.</dd> |
| <dt><span class="target" id="index-1-variable:MATLAB_FIND_DEBUG"></span><a class="reference internal" href="#variable:MATLAB_FIND_DEBUG" title="MATLAB_FIND_DEBUG"><code class="xref cmake cmake-variable docutils literal"><span class="pre">MATLAB_FIND_DEBUG</span></code></a></dt> |
| <dd>outputs debug information</dd> |
| <dt><span class="target" id="index-1-variable:MATLAB_ADDITIONAL_VERSIONS"></span><a class="reference internal" href="#variable:MATLAB_ADDITIONAL_VERSIONS" title="MATLAB_ADDITIONAL_VERSIONS"><code class="xref cmake cmake-variable docutils literal"><span class="pre">MATLAB_ADDITIONAL_VERSIONS</span></code></a></dt> |
| <dd>additional versions of Matlab for the automatic retrieval of the installed |
| versions.</dd> |
| </dl> |
| </div> |
| <div class="section" id="variables-defined-by-the-module"> |
| <h2>Variables defined by the module<a class="headerlink" href="#variables-defined-by-the-module" title="Permalink to this headline">¶</a></h2> |
| <div class="section" id="result-variables"> |
| <h3>Result variables<a class="headerlink" href="#result-variables" title="Permalink to this headline">¶</a></h3> |
| <dl class="docutils"> |
| <dt><code class="docutils literal"><span class="pre">Matlab_FOUND</span></code></dt> |
| <dd><code class="docutils literal"><span class="pre">TRUE</span></code> if the Matlab installation is found, <code class="docutils literal"><span class="pre">FALSE</span></code> |
| otherwise. All variable below are defined if Matlab is found.</dd> |
| <dt><code class="docutils literal"><span class="pre">Matlab_ROOT_DIR</span></code></dt> |
| <dd>the final root of the Matlab installation determined by the FindMatlab |
| module.</dd> |
| <dt><code class="docutils literal"><span class="pre">Matlab_MAIN_PROGRAM</span></code></dt> |
| <dd>the Matlab binary program. Available only if the component <code class="docutils literal"><span class="pre">MAIN_PROGRAM</span></code> |
| is given in the <span class="target" id="index-2-command:find_package"></span><a class="reference internal" href="../command/find_package.html#command:find_package" title="find_package"><code class="xref cmake cmake-command docutils literal"><span class="pre">find_package()</span></code></a> directive.</dd> |
| <dt><code class="docutils literal"><span class="pre">Matlab_INCLUDE_DIRS</span></code></dt> |
| <dd>the path of the Matlab libraries headers</dd> |
| <dt><code class="docutils literal"><span class="pre">Matlab_MEX_LIBRARY</span></code></dt> |
| <dd>library for mex, always available.</dd> |
| <dt><code class="docutils literal"><span class="pre">Matlab_MX_LIBRARY</span></code></dt> |
| <dd>mx library of Matlab (arrays). Available only if the component |
| <code class="docutils literal"><span class="pre">MX_LIBRARY</span></code> has been requested.</dd> |
| <dt><code class="docutils literal"><span class="pre">Matlab_ENG_LIBRARY</span></code></dt> |
| <dd>Matlab engine library. Available only if the component <code class="docutils literal"><span class="pre">ENG_LIBRARY</span></code> |
| is requested.</dd> |
| <dt><code class="docutils literal"><span class="pre">Matlab_MAT_LIBRARY</span></code></dt> |
| <dd>Matlab matrix library. Available only if the component <code class="docutils literal"><span class="pre">MAT_LIBRARY</span></code> |
| is requested.</dd> |
| <dt><code class="docutils literal"><span class="pre">Matlab_LIBRARIES</span></code></dt> |
| <dd>the whole set of libraries of Matlab</dd> |
| <dt><code class="docutils literal"><span class="pre">Matlab_MEX_COMPILER</span></code></dt> |
| <dd>the mex compiler of Matlab. Currently not used. |
| Available only if the component <code class="docutils literal"><span class="pre">MEX_COMPILER</span></code> is asked</dd> |
| </dl> |
| </div> |
| <div class="section" id="cached-variables"> |
| <h3>Cached variables<a class="headerlink" href="#cached-variables" title="Permalink to this headline">¶</a></h3> |
| <dl class="docutils"> |
| <dt><code class="docutils literal"><span class="pre">Matlab_MEX_EXTENSION</span></code></dt> |
| <dd>the extension of the mex files for the current platform (given by Matlab).</dd> |
| <dt><code class="docutils literal"><span class="pre">Matlab_ROOT_DIR</span></code></dt> |
| <dd>the location of the root of the Matlab installation found. If this value |
| is changed by the user, the result variables are recomputed.</dd> |
| </dl> |
| </div> |
| </div> |
| <div class="section" id="provided-macros"> |
| <h2>Provided macros<a class="headerlink" href="#provided-macros" title="Permalink to this headline">¶</a></h2> |
| <dl class="docutils"> |
| <dt><span class="target" id="index-1-command:matlab_get_version_from_release_name"></span><a class="reference internal" href="#command:matlab_get_version_from_release_name" title="matlab_get_version_from_release_name"><code class="xref cmake cmake-command docutils literal"><span class="pre">matlab_get_version_from_release_name()</span></code></a></dt> |
| <dd>returns the version from the release name</dd> |
| <dt><span class="target" id="index-1-command:matlab_get_release_name_from_version"></span><a class="reference internal" href="#command:matlab_get_release_name_from_version" title="matlab_get_release_name_from_version"><code class="xref cmake cmake-command docutils literal"><span class="pre">matlab_get_release_name_from_version()</span></code></a></dt> |
| <dd>returns the release name from the Matlab version</dd> |
| </dl> |
| </div> |
| <div class="section" id="provided-functions"> |
| <h2>Provided functions<a class="headerlink" href="#provided-functions" title="Permalink to this headline">¶</a></h2> |
| <dl class="docutils"> |
| <dt><span class="target" id="index-0-command:matlab_add_mex"></span><a class="reference internal" href="#command:matlab_add_mex" title="matlab_add_mex"><code class="xref cmake cmake-command docutils literal"><span class="pre">matlab_add_mex()</span></code></a></dt> |
| <dd>adds a target compiling a MEX file.</dd> |
| <dt><span class="target" id="index-1-command:matlab_add_unit_test"></span><a class="reference internal" href="#command:matlab_add_unit_test" title="matlab_add_unit_test"><code class="xref cmake cmake-command docutils literal"><span class="pre">matlab_add_unit_test()</span></code></a></dt> |
| <dd>adds a Matlab unit test file as a test to the project.</dd> |
| <dt><span class="target" id="index-0-command:matlab_extract_all_installed_versions_from_registry"></span><a class="reference internal" href="#command:matlab_extract_all_installed_versions_from_registry" title="matlab_extract_all_installed_versions_from_registry"><code class="xref cmake cmake-command docutils literal"><span class="pre">matlab_extract_all_installed_versions_from_registry()</span></code></a></dt> |
| <dd>parses the registry for all Matlab versions. Available on Windows only. |
| The part of the registry parsed is dependent on the host processor</dd> |
| <dt><span class="target" id="index-0-command:matlab_get_all_valid_matlab_roots_from_registry"></span><a class="reference internal" href="#command:matlab_get_all_valid_matlab_roots_from_registry" title="matlab_get_all_valid_matlab_roots_from_registry"><code class="xref cmake cmake-command docutils literal"><span class="pre">matlab_get_all_valid_matlab_roots_from_registry()</span></code></a></dt> |
| <dd>returns all the possible Matlab paths, according to a previously |
| given list. Only the existing/accessible paths are kept. This is mainly |
| useful for the searching all possible Matlab installation.</dd> |
| <dt><span class="target" id="index-0-command:matlab_get_mex_suffix"></span><a class="reference internal" href="#command:matlab_get_mex_suffix" title="matlab_get_mex_suffix"><code class="xref cmake cmake-command docutils literal"><span class="pre">matlab_get_mex_suffix()</span></code></a></dt> |
| <dd>returns the suffix to be used for the mex files |
| (platform/architecture dependent)</dd> |
| <dt><span class="target" id="index-0-command:matlab_get_version_from_matlab_run"></span><a class="reference internal" href="#command:matlab_get_version_from_matlab_run" title="matlab_get_version_from_matlab_run"><code class="xref cmake cmake-command docutils literal"><span class="pre">matlab_get_version_from_matlab_run()</span></code></a></dt> |
| <dd>returns the version of Matlab, given the full directory of the Matlab |
| program.</dd> |
| </dl> |
| </div> |
| <div class="section" id="known-issues"> |
| <h2>Known issues<a class="headerlink" href="#known-issues" title="Permalink to this headline">¶</a></h2> |
| <dl class="docutils"> |
| <dt><strong>Symbol clash in a MEX target</strong></dt> |
| <dd><p class="first">By default, every symbols inside a MEX |
| file defined with the command <span class="target" id="index-1-command:matlab_add_mex"></span><a class="reference internal" href="#command:matlab_add_mex" title="matlab_add_mex"><code class="xref cmake cmake-command docutils literal"><span class="pre">matlab_add_mex()</span></code></a> have hidden |
| visibility, except for the entry point. This is the default behaviour of |
| the MEX compiler, which lowers the risk of symbol collision between the |
| libraries shipped with Matlab, and the libraries to which the MEX file is |
| linking to. This is also the default on Windows platforms.</p> |
| <p class="last">However, this is not sufficient in certain case, where for instance your |
| MEX file is linking against libraries that are already loaded by Matlab, |
| even if those libraries have different SONAMES. |
| A possible solution is to hide the symbols of the libraries to which the |
| MEX target is linking to. This can be achieved in GNU GCC compilers with |
| the linker option <code class="docutils literal"><span class="pre">-Wl,--exclude-libs,ALL</span></code>.</p> |
| </dd> |
| <dt><strong>Tests using GPU resources</strong></dt> |
| <dd>in case your MEX file is using the GPU and |
| in order to be able to run unit tests on this MEX file, the GPU resources |
| should be properly released by Matlab. A possible solution is to make |
| Matlab aware of the use of the GPU resources in the session, which can be |
| performed by a command such as <code class="docutils literal"><span class="pre">D</span> <span class="pre">=</span> <span class="pre">gpuDevice()</span></code> at the beginning of |
| the test script (or via a fixture).</dd> |
| </dl> |
| </div> |
| <div class="section" id="reference"> |
| <h2>Reference<a class="headerlink" href="#reference" title="Permalink to this headline">¶</a></h2> |
| <dl class="variable"> |
| <dt id="variable:Matlab_ROOT_DIR"> |
| <code class="descname">Matlab_ROOT_DIR</code><a class="headerlink" href="#variable:Matlab_ROOT_DIR" title="Permalink to this definition">¶</a></dt> |
| <dd><p>The root folder of the Matlab installation. If set before the call to |
| <span class="target" id="index-3-command:find_package"></span><a class="reference internal" href="../command/find_package.html#command:find_package" title="find_package"><code class="xref cmake cmake-command docutils literal"><span class="pre">find_package()</span></code></a>, the module will look for the components in that |
| path. If not set, then an automatic search of Matlab |
| will be performed. If set, it should point to a valid version of Matlab.</p> |
| </dd></dl> |
| |
| <dl class="variable"> |
| <dt id="variable:MATLAB_FIND_DEBUG"> |
| <code class="descname">MATLAB_FIND_DEBUG</code><a class="headerlink" href="#variable:MATLAB_FIND_DEBUG" title="Permalink to this definition">¶</a></dt> |
| <dd><p>If set, the lookup of Matlab and the intermediate configuration steps are |
| outputted to the console.</p> |
| </dd></dl> |
| |
| <dl class="variable"> |
| <dt id="variable:MATLAB_ADDITIONAL_VERSIONS"> |
| <code class="descname">MATLAB_ADDITIONAL_VERSIONS</code><a class="headerlink" href="#variable:MATLAB_ADDITIONAL_VERSIONS" title="Permalink to this definition">¶</a></dt> |
| <dd><p>If set, specifies additional versions of Matlab that may be looked for. |
| The variable should be a list of strings, organised by pairs of release |
| name and versions, such as follows:</p> |
| <div class="highlight-default"><div class="highlight"><pre><span></span><span class="nb">set</span><span class="p">(</span><span class="n">MATLAB_ADDITIONAL_VERSIONS</span> |
| <span class="s2">"release_name1=corresponding_version1"</span> |
| <span class="s2">"release_name2=corresponding_version2"</span> |
| <span class="o">...</span> |
| <span class="p">)</span> |
| </pre></div> |
| </div> |
| <p>Example:</p> |
| <div class="highlight-default"><div class="highlight"><pre><span></span><span class="nb">set</span><span class="p">(</span><span class="n">MATLAB_ADDITIONAL_VERSIONS</span> |
| <span class="s2">"R2013b=8.2"</span> |
| <span class="s2">"R2013a=8.1"</span> |
| <span class="s2">"R2012b=8.0"</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| <p>The order of entries in this list matters when several versions of |
| Matlab are installed. The priority is set according to the ordering in |
| this list.</p> |
| </dd></dl> |
| |
| <dl class="command"> |
| <dt id="command:matlab_get_version_from_release_name"> |
| <code class="descname">matlab_get_version_from_release_name</code><a class="headerlink" href="#command:matlab_get_version_from_release_name" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Returns the version of Matlab (17.58) from a release name (R2017k)</p> |
| </dd></dl> |
| |
| <dl class="command"> |
| <dt id="command:matlab_get_release_name_from_version"> |
| <code class="descname">matlab_get_release_name_from_version</code><a class="headerlink" href="#command:matlab_get_release_name_from_version" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Returns the release name (R2017k) from the version of Matlab (17.58)</p> |
| </dd></dl> |
| |
| <dl class="command"> |
| <dt id="command:matlab_extract_all_installed_versions_from_registry"> |
| <code class="descname">matlab_extract_all_installed_versions_from_registry</code><a class="headerlink" href="#command:matlab_extract_all_installed_versions_from_registry" title="Permalink to this definition">¶</a></dt> |
| <dd><p>This function parses the registry and founds the Matlab versions that are |
| installed. The found versions are returned in <cite>matlab_versions</cite>. |
| Set <cite>win64</cite> to <cite>TRUE</cite> if the 64 bit version of Matlab should be looked for |
| The returned list contains all versions under |
| <code class="docutils literal"><span class="pre">HKLM\\SOFTWARE\\Mathworks\\MATLAB</span></code> or an empty list in case an error |
| occurred (or nothing found).</p> |
| <div class="admonition note"> |
| <p class="first admonition-title">Note</p> |
| <p class="last">Only the versions are provided. No check is made over the existence of the |
| installation referenced in the registry,</p> |
| </div> |
| </dd></dl> |
| |
| <dl class="command"> |
| <dt id="command:matlab_get_all_valid_matlab_roots_from_registry"> |
| <code class="descname">matlab_get_all_valid_matlab_roots_from_registry</code><a class="headerlink" href="#command:matlab_get_all_valid_matlab_roots_from_registry" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Populates the Matlab root with valid versions of Matlab. |
| The returned matlab_roots is organized in pairs |
| <code class="docutils literal"><span class="pre">(version_number,matlab_root_path)</span></code>.</p> |
| <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">matlab_get_all_valid_matlab_roots_from_registry</span><span class="p">(</span> |
| <span class="n">matlab_versions</span> |
| <span class="n">matlab_roots</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| <dl class="docutils"> |
| <dt><code class="docutils literal"><span class="pre">matlab_versions</span></code></dt> |
| <dd>the versions of each of the Matlab installations</dd> |
| <dt><code class="docutils literal"><span class="pre">matlab_roots</span></code></dt> |
| <dd>the location of each of the Matlab installations</dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="command"> |
| <dt id="command:matlab_get_mex_suffix"> |
| <code class="descname">matlab_get_mex_suffix</code><a class="headerlink" href="#command:matlab_get_mex_suffix" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Returns the extension of the mex files (the suffixes). |
| This function should not be called before the appropriate Matlab root has |
| been found.</p> |
| <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">matlab_get_mex_suffix</span><span class="p">(</span> |
| <span class="n">matlab_root</span> |
| <span class="n">mex_suffix</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| <dl class="docutils"> |
| <dt><code class="docutils literal"><span class="pre">matlab_root</span></code></dt> |
| <dd>the root of the Matlab installation</dd> |
| <dt><code class="docutils literal"><span class="pre">mex_suffix</span></code></dt> |
| <dd>the variable name in which the suffix will be returned.</dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="command"> |
| <dt id="command:matlab_get_version_from_matlab_run"> |
| <code class="descname">matlab_get_version_from_matlab_run</code><a class="headerlink" href="#command:matlab_get_version_from_matlab_run" title="Permalink to this definition">¶</a></dt> |
| <dd><p>This function runs Matlab program specified on arguments and extracts its |
| version.</p> |
| <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">matlab_get_version_from_matlab_run</span><span class="p">(</span> |
| <span class="n">matlab_binary_path</span> |
| <span class="n">matlab_list_versions</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| <dl class="docutils"> |
| <dt><code class="docutils literal"><span class="pre">matlab_binary_path</span></code></dt> |
| <dd>the location of the <cite>matlab</cite> binary executable</dd> |
| <dt><code class="docutils literal"><span class="pre">matlab_list_versions</span></code></dt> |
| <dd>the version extracted from Matlab</dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="command"> |
| <dt id="command:matlab_add_unit_test"> |
| <code class="descname">matlab_add_unit_test</code><a class="headerlink" href="#command:matlab_add_unit_test" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Adds a Matlab unit test to the test set of cmake/ctest. |
| This command requires the component <code class="docutils literal"><span class="pre">MAIN_PROGRAM</span></code>. |
| The unit test uses the Matlab unittest framework (default, available |
| starting Matlab 2013b+) except if the option <code class="docutils literal"><span class="pre">NO_UNITTEST_FRAMEWORK</span></code> |
| is given.</p> |
| <p>The function expects one Matlab test script file to be given. |
| In the case <code class="docutils literal"><span class="pre">NO_UNITTEST_FRAMEWORK</span></code> is given, the unittest script file |
| should contain the script to be run, plus an exit command with the exit |
| value. This exit value will be passed to the ctest framework (0 success, |
| non 0 failure). Additional arguments accepted by <span class="target" id="index-0-command:add_test"></span><a class="reference internal" href="../command/add_test.html#command:add_test" title="add_test"><code class="xref cmake cmake-command docutils literal"><span class="pre">add_test()</span></code></a> can be |
| passed through <code class="docutils literal"><span class="pre">TEST_ARGS</span></code> (eg. <code class="docutils literal"><span class="pre">CONFIGURATION</span> <span class="pre"><config></span> <span class="pre">...</span></code>).</p> |
| <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">matlab_add_unit_test</span><span class="p">(</span> |
| <span class="n">NAME</span> <span class="o"><</span><span class="n">name</span><span class="o">></span> |
| <span class="n">UNITTEST_FILE</span> <span class="n">matlab_file_containing_unittest</span><span class="o">.</span><span class="n">m</span> |
| <span class="p">[</span><span class="n">CUSTOM_MATLAB_COMMAND</span> <span class="n">matlab_command_to_run_as_test</span><span class="p">]</span> |
| <span class="p">[</span><span class="n">UNITTEST_PRECOMMAND</span> <span class="n">matlab_command_to_run</span><span class="p">]</span> |
| <span class="p">[</span><span class="n">TIMEOUT</span> <span class="n">timeout</span><span class="p">]</span> |
| <span class="p">[</span><span class="n">ADDITIONAL_PATH</span> <span class="n">path1</span> <span class="p">[</span><span class="n">path2</span> <span class="o">...</span><span class="p">]]</span> |
| <span class="p">[</span><span class="n">MATLAB_ADDITIONAL_STARTUP_OPTIONS</span> <span class="n">option1</span> <span class="p">[</span><span class="n">option2</span> <span class="o">...</span><span class="p">]]</span> |
| <span class="p">[</span><span class="n">TEST_ARGS</span> <span class="n">arg1</span> <span class="p">[</span><span class="n">arg2</span> <span class="o">...</span><span class="p">]]</span> |
| <span class="p">[</span><span class="n">NO_UNITTEST_FRAMEWORK</span><span class="p">]</span> |
| <span class="p">)</span> |
| </pre></div> |
| </div> |
| <p>The function arguments are:</p> |
| <dl class="docutils"> |
| <dt><code class="docutils literal"><span class="pre">NAME</span></code></dt> |
| <dd>name of the unittest in ctest.</dd> |
| <dt><code class="docutils literal"><span class="pre">UNITTEST_FILE</span></code></dt> |
| <dd>the matlab unittest file. Its path will be automatically |
| added to the Matlab path.</dd> |
| <dt><code class="docutils literal"><span class="pre">CUSTOM_MATLAB_COMMAND</span></code></dt> |
| <dd>Matlab script command to run as the test. |
| If this is not set, then the following is run: |
| <code class="docutils literal"><span class="pre">runtests('matlab_file_name'),</span> <span class="pre">exit(max([ans(1,:).Failed]))</span></code> |
| where <code class="docutils literal"><span class="pre">matlab_file_name</span></code> is the <code class="docutils literal"><span class="pre">UNITTEST_FILE</span></code> without the extension.</dd> |
| <dt><code class="docutils literal"><span class="pre">UNITTEST_PRECOMMAND</span></code></dt> |
| <dd>Matlab script command to be ran before the file |
| containing the test (eg. GPU device initialisation based on CMake |
| variables).</dd> |
| <dt><code class="docutils literal"><span class="pre">TIMEOUT</span></code></dt> |
| <dd>the test timeout in seconds. Defaults to 180 seconds as the |
| Matlab unit test may hang.</dd> |
| <dt><code class="docutils literal"><span class="pre">ADDITIONAL_PATH</span></code></dt> |
| <dd>a list of paths to add to the Matlab path prior to |
| running the unit test.</dd> |
| <dt><code class="docutils literal"><span class="pre">MATLAB_ADDITIONAL_STARTUP_OPTIONS</span></code></dt> |
| <dd>a list of additional option in order |
| to run Matlab from the command line. |
| <code class="docutils literal"><span class="pre">-nosplash</span> <span class="pre">-nodesktop</span> <span class="pre">-nodisplay</span></code> are always added.</dd> |
| <dt><code class="docutils literal"><span class="pre">TEST_ARGS</span></code></dt> |
| <dd>Additional options provided to the add_test command. These |
| options are added to the default options (eg. “CONFIGURATIONS Release”)</dd> |
| <dt><code class="docutils literal"><span class="pre">NO_UNITTEST_FRAMEWORK</span></code></dt> |
| <dd>when set, indicates that the test should not |
| use the unittest framework of Matlab (available for versions >= R2013a).</dd> |
| <dt><code class="docutils literal"><span class="pre">WORKING_DIRECTORY</span></code></dt> |
| <dd>This will be the working directory for the test. If specified it will |
| also be the output directory used for the log file of the test run. |
| If not specifed the temporary directory <code class="docutils literal"><span class="pre">${CMAKE_BINARY_DIR}/Matlab</span></code> will |
| be used as the working directory and the log location.</dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="command"> |
| <dt id="command:matlab_add_mex"> |
| <code class="descname">matlab_add_mex</code><a class="headerlink" href="#command:matlab_add_mex" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Adds a Matlab MEX target. |
| This commands compiles the given sources with the current tool-chain in |
| order to produce a MEX file. The final name of the produced output may be |
| specified, as well as additional link libraries, and a documentation entry |
| for the MEX file. Remaining arguments of the call are passed to the |
| <span class="target" id="index-0-command:add_library"></span><a class="reference internal" href="../command/add_library.html#command:add_library" title="add_library"><code class="xref cmake cmake-command docutils literal"><span class="pre">add_library()</span></code></a> or <span class="target" id="index-0-command:add_executable"></span><a class="reference internal" href="../command/add_executable.html#command:add_executable" title="add_executable"><code class="xref cmake cmake-command docutils literal"><span class="pre">add_executable()</span></code></a> command.</p> |
| <div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">matlab_add_mex</span><span class="p">(</span> |
| <span class="n">NAME</span> <span class="o"><</span><span class="n">name</span><span class="o">></span> |
| <span class="p">[</span><span class="n">EXECUTABLE</span> <span class="o">|</span> <span class="n">MODULE</span> <span class="o">|</span> <span class="n">SHARED</span><span class="p">]</span> |
| <span class="n">SRC</span> <span class="n">src1</span> <span class="p">[</span><span class="n">src2</span> <span class="o">...</span><span class="p">]</span> |
| <span class="p">[</span><span class="n">OUTPUT_NAME</span> <span class="n">output_name</span><span class="p">]</span> |
| <span class="p">[</span><span class="n">DOCUMENTATION</span> <span class="n">file</span><span class="o">.</span><span class="n">txt</span><span class="p">]</span> |
| <span class="p">[</span><span class="n">LINK_TO</span> <span class="n">target1</span> <span class="n">target2</span> <span class="o">...</span><span class="p">]</span> |
| <span class="p">[</span><span class="o">...</span><span class="p">]</span> |
| <span class="p">)</span> |
| </pre></div> |
| </div> |
| <dl class="docutils"> |
| <dt><code class="docutils literal"><span class="pre">NAME</span></code></dt> |
| <dd>name of the target.</dd> |
| <dt><code class="docutils literal"><span class="pre">SRC</span></code></dt> |
| <dd>list of source files.</dd> |
| <dt><code class="docutils literal"><span class="pre">LINK_TO</span></code></dt> |
| <dd>a list of additional link dependencies. The target links to <code class="docutils literal"><span class="pre">libmex</span></code> |
| by default. If <code class="docutils literal"><span class="pre">Matlab_MX_LIBRARY</span></code> is defined, it also |
| links to <code class="docutils literal"><span class="pre">libmx</span></code>.</dd> |
| <dt><code class="docutils literal"><span class="pre">OUTPUT_NAME</span></code></dt> |
| <dd>if given, overrides the default name. The default name is |
| the name of the target without any prefix and |
| with <code class="docutils literal"><span class="pre">Matlab_MEX_EXTENSION</span></code> suffix.</dd> |
| <dt><code class="docutils literal"><span class="pre">DOCUMENTATION</span></code></dt> |
| <dd>if given, the file <code class="docutils literal"><span class="pre">file.txt</span></code> will be considered as |
| being the documentation file for the MEX file. This file is copied into |
| the same folder without any processing, with the same name as the final |
| mex file, and with extension <cite>.m</cite>. In that case, typing <code class="docutils literal"><span class="pre">help</span> <span class="pre"><name></span></code> |
| in Matlab prints the documentation contained in this file.</dd> |
| <dt><code class="docutils literal"><span class="pre">MODULE</span></code> or <code class="docutils literal"><span class="pre">SHARED</span></code> may be given to specify the type of library to be</dt> |
| <dd>created. <code class="docutils literal"><span class="pre">EXECUTABLE</span></code> may be given to create an executable instead of |
| a library. If no type is given explicitly, the type is <code class="docutils literal"><span class="pre">SHARED</span></code>.</dd> |
| </dl> |
| <p>The documentation file is not processed and should be in the following |
| format:</p> |
| <div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">%</span> <span class="n">This</span> <span class="ow">is</span> <span class="n">the</span> <span class="n">documentation</span> |
| <span class="n">function</span> <span class="n">ret</span> <span class="o">=</span> <span class="n">mex_target_output_name</span><span class="p">(</span><span class="n">input1</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| </div> |
| </div> |
| |
| |
| </div> |
| </div> |
| </div> |
| <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> |
| <div class="sphinxsidebarwrapper"> |
| <h3><a href="../index.html">Table Of Contents</a></h3> |
| <ul> |
| <li><a class="reference internal" href="#">FindMatlab</a><ul> |
| <li><a class="reference internal" href="#module-input-variables">Module Input Variables</a></li> |
| <li><a class="reference internal" href="#variables-defined-by-the-module">Variables defined by the module</a><ul> |
| <li><a class="reference internal" href="#result-variables">Result variables</a></li> |
| <li><a class="reference internal" href="#cached-variables">Cached variables</a></li> |
| </ul> |
| </li> |
| <li><a class="reference internal" href="#provided-macros">Provided macros</a></li> |
| <li><a class="reference internal" href="#provided-functions">Provided functions</a></li> |
| <li><a class="reference internal" href="#known-issues">Known issues</a></li> |
| <li><a class="reference internal" href="#reference">Reference</a></li> |
| </ul> |
| </li> |
| </ul> |
| |
| <h4>Previous topic</h4> |
| <p class="topless"><a href="FindLua.html" |
| title="previous chapter">FindLua</a></p> |
| <h4>Next topic</h4> |
| <p class="topless"><a href="FindMFC.html" |
| title="next chapter">FindMFC</a></p> |
| <div role="note" aria-label="source link"> |
| <h3>This Page</h3> |
| <ul class="this-page-menu"> |
| <li><a href="../_sources/module/FindMatlab.rst.txt" |
| rel="nofollow">Show Source</a></li> |
| </ul> |
| </div> |
| <div id="searchbox" style="display: none" role="search"> |
| <h3>Quick search</h3> |
| <form class="search" action="../search.html" method="get"> |
| <div><input type="text" name="q" /></div> |
| <div><input type="submit" value="Go" /></div> |
| <input type="hidden" name="check_keywords" value="yes" /> |
| <input type="hidden" name="area" value="default" /> |
| </form> |
| </div> |
| <script type="text/javascript">$('#searchbox').show(0);</script> |
| </div> |
| </div> |
| <div class="clearer"></div> |
| </div> |
| <div class="related" role="navigation" aria-label="related navigation"> |
| <h3>Navigation</h3> |
| <ul> |
| <li class="right" style="margin-right: 10px"> |
| <a href="../genindex.html" title="General Index" |
| >index</a></li> |
| <li class="right" > |
| <a href="FindMFC.html" title="FindMFC" |
| >next</a> |</li> |
| <li class="right" > |
| <a href="FindLua.html" title="FindLua" |
| >previous</a> |</li> |
| <li> |
| <img src="../_static/cmake-logo-16.png" alt="" |
| style="vertical-align: middle; margin-top: -2px" /> |
| </li> |
| <li> |
| <a href="https://cmake.org/">CMake</a> » |
| </li> |
| <li> |
| <a href="../index.html">3.8.2 Documentation</a> » |
| </li> |
| |
| <li class="nav-item nav-item-1"><a href="../manual/cmake-modules.7.html" >cmake-modules(7)</a> »</li> |
| </ul> |
| </div> |
| <div class="footer" role="contentinfo"> |
| © Copyright 2000-2017 Kitware, Inc. and Contributors. |
| Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.5.2. |
| </div> |
| </body> |
| </html> |