| |
| <!DOCTYPE html> |
| |
| <html lang="en"> |
| <head> |
| <meta charset="utf-8" /> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| <title>CPACK_CUSTOM_INSTALL_VARIABLES — 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="CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION" href="CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.html" /> |
| <link rel="prev" title="CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY" href="CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY.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="CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.html" title="CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION" |
| accesskey="N">next</a> |</li> |
| <li class="right" > |
| <a href="CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY.html" title="CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY" |
| 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-variables.7.html" accesskey="U">cmake-variables(7)</a> »</li> |
| <li class="nav-item nav-item-this"><a href="">CPACK_CUSTOM_INSTALL_VARIABLES</a></li> |
| </ul> |
| </div> |
| |
| <div class="document"> |
| <div class="documentwrapper"> |
| <div class="bodywrapper"> |
| <div class="body" role="main"> |
| |
| <div class="section" id="cpack-custom-install-variables"> |
| <span id="variable:CPACK_CUSTOM_INSTALL_VARIABLES"></span><h1>CPACK_CUSTOM_INSTALL_VARIABLES<a class="headerlink" href="#cpack-custom-install-variables" title="Permalink to this headline">¶</a></h1> |
| <div class="versionadded"> |
| <p><span class="versionmodified added">New in version 3.21.</span></p> |
| </div> |
| <p>CPack variables (set via e.g. <code class="docutils literal notranslate"><span class="pre">cpack</span> <span class="pre">-D</span></code>, <code class="docutils literal notranslate"><span class="pre">CPackConfig.cmake</span></code> or |
| <span class="target" id="index-0-variable:CPACK_PROJECT_CONFIG_FILE"></span><a class="reference internal" href="../module/CPack.html#variable:CPACK_PROJECT_CONFIG_FILE" title="CPACK_PROJECT_CONFIG_FILE"><code class="xref cmake cmake-variable docutils literal notranslate"><span class="pre">CPACK_PROJECT_CONFIG_FILE</span></code></a> scripts) are not directly visible in |
| installation scripts. Instead, one can pass a list of <code class="docutils literal notranslate"><span class="pre">varName=value</span></code> |
| pairs in the <code class="docutils literal notranslate"><span class="pre">CPACK_CUSTOM_INSTALL_VARIABLES</span></code> variable. At install time, |
| each list item will result in a variable of the specified name (<code class="docutils literal notranslate"><span class="pre">varName</span></code>) |
| being set to the given <code class="docutils literal notranslate"><span class="pre">value</span></code>. The <code class="docutils literal notranslate"><span class="pre">=</span></code> can be omitted for an empty |
| <code class="docutils literal notranslate"><span class="pre">value</span></code>.</p> |
| <p><code class="docutils literal notranslate"><span class="pre">CPACK_CUSTOM_INSTALL_VARIABLES</span></code> allows the packaging installation to be |
| influenced by the user or driving script at CPack runtime without having to |
| regenerate the install scripts.</p> |
| <div class="section" id="example"> |
| <h2>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2> |
| <div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">install(</span><span class="no">FILES</span><span class="w"> </span><span class="nb">large.txt</span><span class="w"> </span><span class="no">DESTINATION</span><span class="w"> </span><span class="nb">data</span><span class="nf">)</span><span class="w"></span> |
| |
| <span class="nf">install(</span><span class="no">CODE</span><span class="w"> </span><span class="p">[[</span><span class="w"></span> |
| <span class="w"> </span><span class="nf">if(</span><span class="no">ENABLE_COMPRESSION</span><span class="nf">)</span><span class="w"></span> |
| <span class="w"> </span><span class="c"># "run-compressor" is a fictional tool that produces</span> |
| <span class="w"> </span><span class="c"># large.txt.xz from large.txt and then removes the input file</span> |
| <span class="w"> </span><span class="nf">execute_process(</span><span class="no">COMMAND</span><span class="w"> </span><span class="nb">run-compressor</span><span class="w"> </span><span class="o">$ENV{</span><span class="nt">DESTDIR</span><span class="o">}${</span><span class="nt">CMAKE_INSTALL_PREFIX</span><span class="o">}</span><span class="na">/large.txt</span><span class="nf">)</span><span class="w"></span> |
| <span class="w"> </span><span class="nf">endif()</span><span class="w"></span> |
| <span class="p">]]</span><span class="nf">)</span><span class="w"></span> |
| </pre></div> |
| </div> |
| <p>With the above example snippet, <span class="target" id="index-0-manual:cpack(1)"></span><a class="reference internal" href="../manual/cpack.1.html#manual:cpack(1)" title="cpack(1)"><code class="xref cmake cmake-manual docutils literal notranslate"><span class="pre">cpack</span></code></a> will by default |
| run the installation script with <code class="docutils literal notranslate"><span class="pre">ENABLE_COMPRESSION</span></code> unset, resulting in |
| a package containing the uncompressed <code class="docutils literal notranslate"><span class="pre">large.txt</span></code>. This can be overridden |
| when invoking <span class="target" id="index-1-manual:cpack(1)"></span><a class="reference internal" href="../manual/cpack.1.html#manual:cpack(1)" title="cpack(1)"><code class="xref cmake cmake-manual docutils literal notranslate"><span class="pre">cpack</span></code></a> like so:</p> |
| <div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>cpack -D <span class="s2">"CPACK_CUSTOM_INSTALL_VARIABLES=ENABLE_COMPRESSION=TRUE"</span> |
| </pre></div> |
| </div> |
| <p>The installation script will then run with <code class="docutils literal notranslate"><span class="pre">ENABLE_COMPRESSION</span></code> set to |
| <code class="docutils literal notranslate"><span class="pre">TRUE</span></code>, resulting in a package containing the compressed <code class="docutils literal notranslate"><span class="pre">large.txt.xz</span></code> |
| instead.</p> |
| </div> |
| </div> |
| |
| |
| <div class="clearer"></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="#">CPACK_CUSTOM_INSTALL_VARIABLES</a><ul> |
| <li><a class="reference internal" href="#example">Example</a></li> |
| </ul> |
| </li> |
| </ul> |
| |
| <h4>Previous topic</h4> |
| <p class="topless"><a href="CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY.html" |
| title="previous chapter">CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY</a></p> |
| <h4>Next topic</h4> |
| <p class="topless"><a href="CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.html" |
| title="next chapter">CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION</a></p> |
| <div role="note" aria-label="source link"> |
| <h3>This Page</h3> |
| <ul class="this-page-menu"> |
| <li><a href="../_sources/variable/CPACK_CUSTOM_INSTALL_VARIABLES.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="CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.html" title="CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION" |
| >next</a> |</li> |
| <li class="right" > |
| <a href="CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY.html" title="CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY" |
| >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-variables.7.html" >cmake-variables(7)</a> »</li> |
| <li class="nav-item nav-item-this"><a href="">CPACK_CUSTOM_INSTALL_VARIABLES</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> |