| |
| <!DOCTYPE html> |
| |
| <html lang="en"> |
| <head> |
| <meta charset="utf-8" /> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| <title>CMP0125 — 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="CMP0124" href="CMP0124.html" /> |
| <link rel="prev" title="CMP0126" href="CMP0126.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="CMP0124.html" title="CMP0124" |
| accesskey="N">next</a> |</li> |
| <li class="right" > |
| <a href="CMP0126.html" title="CMP0126" |
| 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-policies.7.html" accesskey="U">cmake-policies(7)</a> »</li> |
| <li class="nav-item nav-item-this"><a href="">CMP0125</a></li> |
| </ul> |
| </div> |
| |
| <div class="document"> |
| <div class="documentwrapper"> |
| <div class="bodywrapper"> |
| <div class="body" role="main"> |
| |
| <div class="section" id="cmp0125"> |
| <span id="policy:CMP0125"></span><h1>CMP0125<a class="headerlink" href="#cmp0125" title="Permalink to this headline">ΒΆ</a></h1> |
| <div class="versionadded"> |
| <p><span class="versionmodified added">New in version 3.21.</span></p> |
| </div> |
| <p>The <span class="target" id="index-0-command:find_file"></span><a class="reference internal" href="../command/find_file.html#command:find_file" title="find_file"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">find_file()</span></code></a>, <span class="target" id="index-0-command:find_path"></span><a class="reference internal" href="../command/find_path.html#command:find_path" title="find_path"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">find_path()</span></code></a>, <span class="target" id="index-0-command:find_library"></span><a class="reference internal" href="../command/find_library.html#command:find_library" title="find_library"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">find_library()</span></code></a> and |
| <span class="target" id="index-0-command:find_program"></span><a class="reference internal" href="../command/find_program.html#command:find_program" title="find_program"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">find_program()</span></code></a> commands cache their result in the variable specified |
| by their first argument. Prior to CMake 3.21, if a cache variable of that |
| name already existed before the call but the cache variable had no type, any |
| non-cache variable of the same name would be discarded and the cache variable |
| was always used (see also <span class="target" id="index-0-policy:CMP0126"></span><a class="reference internal" href="CMP0126.html#policy:CMP0126" title="CMP0126"><code class="xref cmake cmake-policy docutils literal notranslate"><span class="pre">CMP0126</span></code></a> for a different but similar |
| behavior). This contradicts the convention that a non-cache variable should |
| take precedence over a cache variable of the same name. Such a situation can |
| arise if a user sets a cache variable on the command line without specifying |
| a type, such as <code class="docutils literal notranslate"><span class="pre">cmake</span> <span class="pre">-DMYVAR=blah</span> <span class="pre">...</span></code> instead of |
| <code class="docutils literal notranslate"><span class="pre">cmake</span> <span class="pre">-DMYVAR:FILEPATH=blah</span></code>.</p> |
| <p>Related to the above, if a cache variable of the specified name already exists |
| and it <em>does</em> have a type, the various <code class="docutils literal notranslate"><span class="pre">find_...()</span></code> commands would return |
| that value unchanged. In particular, if it contained a relative path, it |
| would not be converted to an absolute path in this situation.</p> |
| <p>When policy <code class="docutils literal notranslate"><span class="pre">CMP0125</span></code> is set to <code class="docutils literal notranslate"><span class="pre">OLD</span></code> or is unset, the behavior is as |
| described above. When it is set to <code class="docutils literal notranslate"><span class="pre">NEW</span></code>, the behavior is as follows:</p> |
| <ul class="simple"> |
| <li><p>If a non-cache variable of the specified name exists when the <code class="docutils literal notranslate"><span class="pre">find_...()</span></code> |
| command is called, its value will be used regardless of whether a cache |
| variable of the same name already exists or not. A cache variable will not |
| be created in this case if no such cache variable existed before. |
| If a cache variable of the specified name did already exist, the cache will |
| be updated to match the non-cache variable.</p></li> |
| <li><p>The various <code class="docutils literal notranslate"><span class="pre">find...()</span></code> commands will always provide an absolute path in |
| the result variable, except where a relative path provided by a cache or |
| non-cache variable cannot be resolved to an existing path.</p></li> |
| </ul> |
| <p>This policy was introduced in CMake version 3.21. Use the |
| <span class="target" id="index-0-command:cmake_policy"></span><a class="reference internal" href="../command/cmake_policy.html#command:cmake_policy" title="cmake_policy"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">cmake_policy()</span></code></a> command to set it to <code class="docutils literal notranslate"><span class="pre">OLD</span></code> or <code class="docutils literal notranslate"><span class="pre">NEW</span></code> explicitly. |
| Unlike many policies, CMake version 3.23.1 does <em>not</em> warn when the policy |
| is not set and simply uses <code class="docutils literal notranslate"><span class="pre">OLD</span></code> behavior.</p> |
| <div class="admonition note"> |
| <p class="admonition-title">Note</p> |
| <p>The <code class="docutils literal notranslate"><span class="pre">OLD</span></code> behavior of a policy is |
| <span class="target" id="index-0-manual:cmake-policies(7)"></span><a class="reference internal" href="../manual/cmake-policies.7.html#manual:cmake-policies(7)" title="cmake-policies(7)"><code class="xref cmake cmake-manual docutils literal notranslate"><span class="pre">deprecated</span> <span class="pre">by</span> <span class="pre">definition</span></code></a> |
| and may be removed in a future version of CMake.</p> |
| </div> |
| </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="CMP0126.html" |
| title="previous chapter">CMP0126</a></p> |
| <h4>Next topic</h4> |
| <p class="topless"><a href="CMP0124.html" |
| title="next chapter">CMP0124</a></p> |
| <div role="note" aria-label="source link"> |
| <h3>This Page</h3> |
| <ul class="this-page-menu"> |
| <li><a href="../_sources/policy/CMP0125.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="CMP0124.html" title="CMP0124" |
| >next</a> |</li> |
| <li class="right" > |
| <a href="CMP0126.html" title="CMP0126" |
| >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-policies.7.html" >cmake-policies(7)</a> »</li> |
| <li class="nav-item nav-item-this"><a href="">CMP0125</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> |