build.html 7.84 KB
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>hueplusplus: Build and install</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">hueplusplus
   &#160;<span id="projectnumber">1.0.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Build and install </div>  </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#basic-install">Basic installation</a><ul><li class="level2"><a href="#clone">Clone from github</a></li>
<li class="level2"><a href="#build-cmake">Build with CMake</a></li>
<li class="level2"><a href="#import-cmake">Use in a CMake project</a></li>
<li class="level2"><a href="#import-other">Use in another project</a></li>
<li class="level2"><a href="#build-tests">Building tests</a></li>
<li class="level2"><a href="#build-examples">Building examples</a></li>
</ul>
</li>
</ul>
</div>
<div class="textblock"><h1><a class="anchor" id="basic-install"></a>
Basic installation</h1>
<h2><a class="anchor" id="clone"></a>
Clone from github</h2>
<p>To get the newest version of the hueplusplus library, clone it directly from <a href="https://github.com/enwi/hueplusplus">github</a>. The master branch contains the latest tested and stable version, while the development branch is more unstable. </p><div class="fragment"><div class="line">~ $ git clone https://github.com/enwi/hueplusplus.git</div></div><!-- fragment --><p> This creates a folder hueplusplus with the library sources.</p>
<p>When you want to update the library for a new version, use pull with rebase. </p><div class="fragment"><div class="line">~/hueplusplus $ git pull --rebase</div></div><!-- fragment --><h2><a class="anchor" id="build-cmake"></a>
Build with CMake</h2>
<p>To build the library, you need to use <a href="https://cmake.org">CMake</a> version 3.8 or higher. It is easiest to create a separate build directory where the build files are stored. </p><div class="fragment"><div class="line">~/hueplusplus $ mkdir build</div><div class="line">~/hueplusplus $ cd build</div><div class="line">~/hueplusplus/build $ cmake ..</div><div class="line">~/hueplusplus/build $ make</div></div><!-- fragment --><p>To install or uninstall the library use the make targets. </p><div class="fragment"><div class="line">~/hueplusplus/build $ make install</div><div class="line">~/hueplusplus/build $ make uninstall</div></div><!-- fragment --><h2><a class="anchor" id="import-cmake"></a>
Use in a CMake project</h2>
<p>If you have a project that already uses CMake you probably want to add the hueplusplus library directly in your cmake file. For that the best way is to use find_package(). </p><div class="fragment"><div class="line">find_package(hueplusplus REQUIRED)</div></div><!-- fragment --><p> But this will only work if the hueplusplus library is already installed. Instead, if you have the hueplusplus repository included in your project repository (as a submodule) or know where the folder lives you can do the following: </p><div class="fragment"><div class="line">find_package(hueplusplus QUIET)</div><div class="line">if(NOT hueplusplus_FOUND)</div><div class="line">    message(STATUS &quot;-- hueplusplus not found, building it&quot;)</div><div class="line">    add_subdirectory(&quot;${CMAKE_CURRENT_SOURCE_DIR}/&lt;path to directory&gt;/hueplusplus&quot; &quot;${CMAKE_CURRENT_BINARY_DIR}/hueplusplus&quot;)</div><div class="line">endif()</div></div><!-- fragment --><p> This will check if the hueplusplus library was found by find_package() and if not it will use the specified path to the library source and compile it during the build process.</p>
<p>The cmake project defines two library targets: <code>hueplusplusstatic</code> to link as a static library and <code>hueplusplusshared</code> to link as a shared library. </p><div class="fragment"><div class="line">target_link_libraries(&lt;executable&gt; PUBLIC hueplusplusstatic)</div></div><!-- fragment --><h2><a class="anchor" id="import-other"></a>
Use in another project</h2>
<p>When you are not using CMake, you have to install hueplusplus and change your build configuration to link to the compiled library. The header files in the include directory need to be added to the include path. How you do this depends on the build system.</p>
<h2><a class="anchor" id="build-tests"></a>
Building tests</h2>
<p>If you additionally want to run the tests use cmake with the option -Dhueplusplus_TESTS=ON. Testing is done with Google gtest and gmock. Note that you wont need to install gtest/gmock yourself, because cmake will automatically download them and include them during the build. The custom target <code>unittest</code> compiles and executes all tests. </p><div class="fragment"><div class="line">mkdir build</div><div class="line">cd build</div><div class="line">cmake .. -Dhueplusplus_TESTS=ON</div><div class="line">make unittest</div></div><!-- fragment --><p>If you also want to execute coverage tests you will need to install gcov and lcov yourself. To run the coverage test use </p><div class="fragment"><div class="line">make coveragetest</div></div><!-- fragment --><h2><a class="anchor" id="build-examples"></a>
Building examples</h2>
<p>There are some small <a class="el" href="dir_d28a4824dc47e487b107a5db32ef43c4.html">example programs</a> using this library in the examples folder. To build them, set <code>hueplusplus_EXAMPLES=ON</code>. The target <code>hueplusplus_examples</code> builds all examples into build/examples. </p><div class="fragment"><div class="line">mkdir build</div><div class="line">cd build</div><div class="line">cmake .. -Dhueplusplus_EXAMPLES=ON</div><div class="line">make hueplusplus_examples</div></div><!-- fragment --> </div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>