blob: 1dbbba02096518612aa4e0b08c178db89fbc45f7 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Step 8: Adding Support for a Testing Dashboard &mdash; 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="Step 9: Selecting Static or Shared Libraries" href="Selecting%20Static%20or%20Shared%20Libraries.html" />
<link rel="prev" title="Step 7: Packaging an Installer" href="Packaging%20an%20Installer.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="Selecting%20Static%20or%20Shared%20Libraries.html" title="Step 9: Selecting Static or Shared Libraries"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="Packaging%20an%20Installer.html" title="Step 7: Packaging an Installer"
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> &#187;
</li>
<li>
<a href="../../index.html">3.23.1 Documentation</a> &#187;
</li>
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">CMake Tutorial</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Step 8: Adding Support for a Testing Dashboard</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="step-8-adding-support-for-a-testing-dashboard">
<span id="guide:tutorial/Adding Support for a Testing Dashboard"></span><h1>Step 8: Adding Support for a Testing Dashboard<a class="headerlink" href="#step-8-adding-support-for-a-testing-dashboard" title="Permalink to this headline"></a></h1>
<p>Adding support for submitting our test results to a dashboard is simple. We
already defined a number of tests for our project in
<a class="reference internal" href="Installing%20and%20Testing.html#tutorial-testing-support"><span class="std std-ref">Testing Support</span></a>. Now we just have to run
those tests and submit them to a dashboard. To include support for dashboards
we include the <span class="target" id="index-0-module:CTest"></span><a class="reference internal" href="../../module/CTest.html#module:CTest" title="CTest"><code class="xref cmake cmake-module docutils literal notranslate"><span class="pre">CTest</span></code></a> module in our top-level <code class="docutils literal notranslate"><span class="pre">CMakeLists.txt</span></code>.</p>
<p>Replace:</p>
<div class="literal-block-wrapper docutils container" id="cmakelists-txt-enable-testing-remove">
<div class="code-block-caption"><span class="caption-text">CMakeLists.txt</span><a class="headerlink" href="#cmakelists-txt-enable-testing-remove" title="Permalink to this code"></a></div>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="c"># enable testing</span>
<span class="nf">enable_testing()</span><span class="w"></span>
</pre></div>
</div>
</div>
<p>With:</p>
<div class="literal-block-wrapper docutils container" id="cmakelists-txt-include-ctest">
<div class="code-block-caption"><span class="caption-text">CMakeLists.txt</span><a class="headerlink" href="#cmakelists-txt-include-ctest" title="Permalink to this code"></a></div>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="c"># enable dashboard scripting</span>
<span class="nf">include(</span><span class="nb">CTest</span><span class="nf">)</span><span class="w"></span>
</pre></div>
</div>
</div>
<p>The <span class="target" id="index-1-module:CTest"></span><a class="reference internal" href="../../module/CTest.html#module:CTest" title="CTest"><code class="xref cmake cmake-module docutils literal notranslate"><span class="pre">CTest</span></code></a> module will automatically call <code class="docutils literal notranslate"><span class="pre">enable_testing()</span></code>, so we
can remove it from our CMake files.</p>
<p>We will also need to acquire a <code class="docutils literal notranslate"><span class="pre">CTestConfig.cmake</span></code> file to be placed in the
top-level directory where we can specify information to CTest about the
project. It contains:</p>
<ul class="simple">
<li><p>The project name</p></li>
<li><p>The project &quot;Nightly&quot; start time</p>
<ul>
<li><p>The time when a 24 hour &quot;day&quot; starts for this project.</p></li>
</ul>
</li>
<li><p>The URL of the CDash instance where the submission's generated documents
will be sent</p></li>
</ul>
<p>One has been provided for you in this directory. It would normally be
downloaded from the <code class="docutils literal notranslate"><span class="pre">Settings</span></code> page of the project on the CDash
instance that will host and display the test results. Once downloaded from
CDash, the file should not be modified locally.</p>
<div class="literal-block-wrapper docutils container" id="ctestconfig-cmake">
<div class="code-block-caption"><span class="caption-text">CTestConfig.cmake</span><a class="headerlink" href="#ctestconfig-cmake" title="Permalink to this code"></a></div>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">set(</span><span class="no">CTEST_PROJECT_NAME</span><span class="w"> </span><span class="s">&quot;CMakeTutorial&quot;</span><span class="nf">)</span><span class="w"></span>
<span class="nf">set(</span><span class="no">CTEST_NIGHTLY_START_TIME</span><span class="w"> </span><span class="s">&quot;00:00:00 EST&quot;</span><span class="nf">)</span><span class="w"></span>
<span class="nf">set(</span><span class="no">CTEST_DROP_METHOD</span><span class="w"> </span><span class="s">&quot;http&quot;</span><span class="nf">)</span><span class="w"></span>
<span class="nf">set(</span><span class="no">CTEST_DROP_SITE</span><span class="w"> </span><span class="s">&quot;my.cdash.org&quot;</span><span class="nf">)</span><span class="w"></span>
<span class="nf">set(</span><span class="no">CTEST_DROP_LOCATION</span><span class="w"> </span><span class="s">&quot;/submit.php?project=CMakeTutorial&quot;</span><span class="nf">)</span><span class="w"></span>
<span class="nf">set(</span><span class="no">CTEST_DROP_SITE_CDASH</span><span class="w"> </span><span class="no">TRUE</span><span class="nf">)</span><span class="w"></span>
</pre></div>
</div>
</div>
<p>The <span class="target" id="index-0-manual:ctest(1)"></span><a class="reference internal" href="../../manual/ctest.1.html#manual:ctest(1)" title="ctest(1)"><code class="xref cmake cmake-manual docutils literal notranslate"><span class="pre">ctest</span></code></a> executable will read in this file when it runs.
To create a simple dashboard you can run the <span class="target" id="index-0-manual:cmake(1)"></span><a class="reference internal" href="../../manual/cmake.1.html#manual:cmake(1)" title="cmake(1)"><code class="xref cmake cmake-manual docutils literal notranslate"><span class="pre">cmake</span></code></a>
executable or the <span class="target" id="index-0-manual:cmake-gui(1)"></span><a class="reference internal" href="../../manual/cmake-gui.1.html#manual:cmake-gui(1)" title="cmake-gui(1)"><code class="xref cmake cmake-manual docutils literal notranslate"><span class="pre">cmake-gui</span></code></a> to configure the project,
but do not build it yet. Instead, change directory to the binary tree, and then
run:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">ctest [-VV] -D Experimental</span>
</pre></div>
</div>
<p>Remember, for multi-config generators (e.g. Visual Studio), the configuration
type must be specified:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">ctest [-VV] -C Debug -D Experimental</span>
</pre></div>
</div>
<p>Or, from an IDE, build the <code class="docutils literal notranslate"><span class="pre">Experimental</span></code> target.</p>
<p>The <span class="target" id="index-1-manual:ctest(1)"></span><a class="reference internal" href="../../manual/ctest.1.html#manual:ctest(1)" title="ctest(1)"><code class="xref cmake cmake-manual docutils literal notranslate"><span class="pre">ctest</span></code></a> executable will build and test the project and
submit the results to Kitware's public dashboard:
<a class="reference external" href="https://my.cdash.org/index.php?project=CMakeTutorial">https://my.cdash.org/index.php?project=CMakeTutorial</a>.</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="Packaging%20an%20Installer.html"
title="previous chapter">Step 7: Packaging an Installer</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="Selecting%20Static%20or%20Shared%20Libraries.html"
title="next chapter">Step 9: Selecting Static or Shared Libraries</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../../_sources/guide/tutorial/Adding Support for a Testing Dashboard.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="Selecting%20Static%20or%20Shared%20Libraries.html" title="Step 9: Selecting Static or Shared Libraries"
>next</a> |</li>
<li class="right" >
<a href="Packaging%20an%20Installer.html" title="Step 7: Packaging an Installer"
>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> &#187;
</li>
<li>
<a href="../../index.html">3.23.1 Documentation</a> &#187;
</li>
<li class="nav-item nav-item-1"><a href="index.html" >CMake Tutorial</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Step 8: Adding Support for a Testing Dashboard</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2000-2022 Kitware, Inc. and Contributors.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
</div>
</body>
</html>