Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h2>What works:</h2> <ul> <li><p><a href="https://cmake.org/cmake/help/latest/variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY.html" rel="nofollow noreferrer">Remove dependency of "install" target to "all" target</a> (once, in the main CMakeLists.txt): </p> <p><code>set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true)</code></p></li> <li><p>Set to OPTIONAL installation of all targets you do not want to always build: </p> <p><code>install(TARGETS &lt;&lt;targetname&gt;&gt; DESTINATION . OPTIONAL)</code></p></li> <li><p>Build the targets you want to install</p> <p><code>ninja -j7 &lt;&lt;list of targets&gt;&gt;</code>, or more generally:</p> <p><code>&lt;&lt;your builder&gt;&gt; &lt;&lt;your options&gt;&gt; &lt;&lt;list of targets&gt;&gt;</code></p> <p>This will build all the targets listed <strong>and their dependencies</strong></p></li> <li><p>Call the installer <code>ninja install</code>. This will install all the libraries you have built, those you mentioned explicitly and those to which they depended. This solves the problem of <strong>installing a specific target together with its dependencies!</strong></p></li> <li><p>To concatenate the commands, both on Unix and Windows you can use</p> <p><code>ninja -j7 &lt;&lt;list of targets&gt;&gt; &amp;&amp; ninja install</code></p></li> <li><p>Note that, at least for ninja, you cannot simply prepend "install" to the list of targets, as the target "install" does not depend anymore on any target and ninja in parallelizing the job will run install while you are still building your targets. A replacement to the old <code>ninja -j7 install</code> is </p> <p><code>ninja -j7 &amp;&amp; ninja install</code>.</p> <p>The target "all" is still available (and it is still the default target).</p></li> <li><p>If you need to create a list of targets you want to build together, you can define a <a href="https://cmake.org/cmake/help/latest/command/add_custom_target.html" rel="nofollow noreferrer">custom target</a>:</p> <p><code>add_custom_target(&lt;&lt;collective target name&gt;&gt; DEPENDS &lt;&lt;list of targets&gt;&gt;)</code></p> <p>This will not be included in the target all. Adding also a COMMAND would also allow to create an install target for as many as target as we want, for example <code>ninja -j7 install_D</code>, but I think now we are beyond the scope of this question.</p></li> </ul> <h2>Further considerations:</h2> <ul> <li><p>(Note, July 2018: This might be outdated) If you use RUNTIME DESTINATION, LIBRARY DESTINATION etc., most likely because of a CMake bug the OPTIONAL keyword should be put exactly in the position indicated below: </p> <p><code>install(TARGETS &lt;&lt;targetname&gt;&gt; OPTIONAL RUNTIME DESTINATION &lt;&lt;some dir&gt;&gt; LIBRARY DESTINATION &lt;&lt;some (other) dir&gt;&gt;)</code></p> <p>This contradicts what written in the <a href="https://cmake.org/cmake/help/latest/command/install.html" rel="nofollow noreferrer">documentation</a>, and I will proceed to report it as a bug to the CMake developers.</p></li> <li><p>Using <code>EXCLUDE_FROM_ALL</code> in combination with <code>INSTALL</code> + <code>OPTIONAL</code> is <a href="https://cmake.org/cmake/help/latest/prop_tgt/EXCLUDE_FROM_ALL.html" rel="nofollow noreferrer">a bad idea</a> </p> <blockquote> <p>Installing a target with EXCLUDE_FROM_ALL set to true has undefined behavior.</p> </blockquote> <p>(and cmake tries to warn you when it parses the code)</p></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload