| |
| <!DOCTYPE html> |
| |
| <html lang="en"> |
| <head> |
| <meta charset="utf-8" /> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| <title>get_filename_component — CMake 3.23.1 Documentation</title> |
| |
| <link rel="stylesheet" type="text/css" href="../_static/pygments.css" /> |
| <link rel="stylesheet" type="text/css" href="../_static/cmake.css" /> |
| |
| <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script> |
| <script src="../_static/jquery.js"></script> |
| <script src="../_static/underscore.js"></script> |
| <script 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="get_property" href="get_property.html" /> |
| <link rel="prev" title="get_directory_property" href="get_directory_property.html" /> |
| |
| |
| </head><body> |
| |
| <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="get_property.html" title="get_property" |
| accesskey="N">next</a> |</li> |
| <li class="right" > |
| <a href="get_directory_property.html" title="get_directory_property" |
| 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.23.1 Documentation</a> » |
| </li> |
| |
| <li class="nav-item nav-item-1"><a href="../manual/cmake-commands.7.html" accesskey="U">cmake-commands(7)</a> »</li> |
| <li class="nav-item nav-item-this"><a href="">get_filename_component</a></li> |
| </ul> |
| </div> |
| |
| <div class="document"> |
| <div class="documentwrapper"> |
| <div class="bodywrapper"> |
| <div class="body" role="main"> |
| |
| <div class="section" id="get-filename-component"> |
| <span id="command:get_filename_component"></span><h1>get_filename_component<a class="headerlink" href="#get-filename-component" title="Permalink to this headline">ΒΆ</a></h1> |
| <p>Get a specific component of a full filename.</p> |
| <div class="versionchanged"> |
| <p><span class="versionmodified changed">Changed in version 3.20: </span>This command been superseded by <span class="target" id="index-0-command:cmake_path"></span><a class="reference internal" href="cmake_path.html#command:cmake_path" title="cmake_path"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">cmake_path()</span></code></a> command, except |
| <code class="docutils literal notranslate"><span class="pre">REALPATH</span></code> now offered by <a class="reference internal" href="file.html#real-path"><span class="std std-ref">file(REAL_PATH)</span></a> command and |
| <code class="docutils literal notranslate"><span class="pre">PROGRAM</span></code> now available in <span class="target" id="index-0-command:separate_arguments"></span><a class="reference internal" href="separate_arguments.html#command:separate_arguments" title="separate_arguments"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">separate_arguments(PROGRAM)</span></code></a> command.</p> |
| </div> |
| <div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">get_filename_component(</span><span class="nv"><var></span><span class="w"> </span><span class="nv"><FileName></span><span class="w"> </span><span class="nv"><mode></span><span class="w"> </span><span class="p">[</span><span class="no">CACHE</span><span class="p">]</span><span class="nf">)</span><span class="w"></span> |
| </pre></div> |
| </div> |
| <p>Sets <code class="docutils literal notranslate"><span class="pre"><var></span></code> to a component of <code class="docutils literal notranslate"><span class="pre"><FileName></span></code>, where <code class="docutils literal notranslate"><span class="pre"><mode></span></code> is one of:</p> |
| <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>DIRECTORY = Directory without file name |
| NAME = File name without directory |
| EXT = File name longest extension (.b.c from d/a.b.c) |
| NAME_WE = File name with neither the directory nor the longest extension |
| LAST_EXT = File name last extension (.c from d/a.b.c) |
| NAME_WLE = File name with neither the directory nor the last extension |
| PATH = Legacy alias for DIRECTORY (use for CMake <= 2.8.11) |
| </pre></div> |
| </div> |
| <div class="versionadded"> |
| <p><span class="versionmodified added">New in version 3.14: </span>Added the <code class="docutils literal notranslate"><span class="pre">LAST_EXT</span></code> and <code class="docutils literal notranslate"><span class="pre">NAME_WLE</span></code> modes.</p> |
| </div> |
| <p>Paths are returned with forward slashes and have no trailing slashes. |
| If the optional <code class="docutils literal notranslate"><span class="pre">CACHE</span></code> argument is specified, the result variable is |
| added to the cache.</p> |
| <div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">get_filename_component(</span><span class="nv"><var></span><span class="w"> </span><span class="nv"><FileName></span><span class="w"> </span><span class="nv"><mode></span><span class="w"> </span><span class="p">[</span><span class="no">BASE_DIR</span><span class="w"> </span><span class="nv"><dir></span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="no">CACHE</span><span class="p">]</span><span class="nf">)</span><span class="w"></span> |
| </pre></div> |
| </div> |
| <div class="versionadded"> |
| <p><span class="versionmodified added">New in version 3.4.</span></p> |
| </div> |
| <p>Sets <code class="docutils literal notranslate"><span class="pre"><var></span></code> to the absolute path of <code class="docutils literal notranslate"><span class="pre"><FileName></span></code>, where <code class="docutils literal notranslate"><span class="pre"><mode></span></code> is one |
| of:</p> |
| <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>ABSOLUTE = Full path to file |
| REALPATH = Full path to existing file with symlinks resolved |
| </pre></div> |
| </div> |
| <p>If the provided <code class="docutils literal notranslate"><span class="pre"><FileName></span></code> is a relative path, it is evaluated relative |
| to the given base directory <code class="docutils literal notranslate"><span class="pre"><dir></span></code>. If no base directory is |
| provided, the default base directory will be |
| <span class="target" id="index-0-variable:CMAKE_CURRENT_SOURCE_DIR"></span><a class="reference internal" href="../variable/CMAKE_CURRENT_SOURCE_DIR.html#variable:CMAKE_CURRENT_SOURCE_DIR" title="CMAKE_CURRENT_SOURCE_DIR"><code class="xref cmake cmake-variable docutils literal notranslate"><span class="pre">CMAKE_CURRENT_SOURCE_DIR</span></code></a>.</p> |
| <p>Paths are returned with forward slashes and have no trailing slashes. If the |
| optional <code class="docutils literal notranslate"><span class="pre">CACHE</span></code> argument is specified, the result variable is added to the |
| cache.</p> |
| <div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">get_filename_component(</span><span class="nv"><var></span><span class="w"> </span><span class="nv"><FileName></span><span class="w"> </span><span class="no">PROGRAM</span><span class="w"> </span><span class="p">[</span><span class="no">PROGRAM_ARGS</span><span class="w"> </span><span class="nv"><arg_var></span><span class="p">]</span><span class="w"> </span><span class="p">[</span><span class="no">CACHE</span><span class="p">]</span><span class="nf">)</span><span class="w"></span> |
| </pre></div> |
| </div> |
| <p>The program in <code class="docutils literal notranslate"><span class="pre"><FileName></span></code> will be found in the system search path or |
| left as a full path. If <code class="docutils literal notranslate"><span class="pre">PROGRAM_ARGS</span></code> is present with <code class="docutils literal notranslate"><span class="pre">PROGRAM</span></code>, then |
| any command-line arguments present in the <code class="docutils literal notranslate"><span class="pre"><FileName></span></code> string are split |
| from the program name and stored in <code class="docutils literal notranslate"><span class="pre"><arg_var></span></code>. This is used to |
| separate a program name from its arguments in a command line string.</p> |
| </div> |
| |
| |
| <div class="clearer"></div> |
| </div> |
| </div> |
| </div> |
| <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> |
| <div class="sphinxsidebarwrapper"> |
| <h4>Previous topic</h4> |
| <p class="topless"><a href="get_directory_property.html" |
| title="previous chapter">get_directory_property</a></p> |
| <h4>Next topic</h4> |
| <p class="topless"><a href="get_property.html" |
| title="next chapter">get_property</a></p> |
| <div role="note" aria-label="source link"> |
| <h3>This Page</h3> |
| <ul class="this-page-menu"> |
| <li><a href="../_sources/command/get_filename_component.rst.txt" |
| rel="nofollow">Show Source</a></li> |
| </ul> |
| </div> |
| <div id="searchbox" style="display: none" role="search"> |
| <h3 id="searchlabel">Quick search</h3> |
| <div class="searchformwrapper"> |
| <form class="search" action="../search.html" method="get"> |
| <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/> |
| <input type="submit" value="Go" /> |
| </form> |
| </div> |
| </div> |
| <script>$('#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="get_property.html" title="get_property" |
| >next</a> |</li> |
| <li class="right" > |
| <a href="get_directory_property.html" title="get_directory_property" |
| >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.23.1 Documentation</a> » |
| </li> |
| |
| <li class="nav-item nav-item-1"><a href="../manual/cmake-commands.7.html" >cmake-commands(7)</a> »</li> |
| <li class="nav-item nav-item-this"><a href="">get_filename_component</a></li> |
| </ul> |
| </div> |
| |
| <div class="footer" role="contentinfo"> |
| © Copyright 2000-2022 Kitware, Inc. and Contributors. |
| Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2. |
| </div> |
| </body> |
| </html> |