1 Star 0 Fork 0

mobangjack / memory

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
md_doc_installation.html 8.04 KB
一键复制 编辑 原始数据 按行查看 历史
Jonathan Müller 提交于 2020-05-05 17:04 . Update documentation
<!-- HTML header for doxygen 1.8.16-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://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.18"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>memory: Installation</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="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">memory
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div id="main-nav">
<ul class="sm sm-dox" id="main-menu">
<li><a href="index.html">Main Page</a></li>
<li><a href="md_doc_tutorial.html">Tutorial</a></li>
<li><a href="namespacefoonathan_1_1memory.html">Index</a></li>
<li><a href="files.html">Files</a></li>
</ul>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.18 -->
</div><!-- top -->
<div class="PageDoc"><div class="header">
<div class="headertitle">
<div class="title">Installation </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>This library can either be used <a href="www.cmake.org">CMake</a>'s <code>add_subdirectory()</code> command or installed globally.</p>
<h1><a class="anchor" id="autotoc_md55"></a>
Requirements</h1>
<ul>
<li>git</li>
<li>CMake version 3.1 or higher</li>
<li>GCC 4.9 or higher, or clang 3.5 or higher or Visual Studio 14 or higher</li>
</ul>
<h1><a class="anchor" id="autotoc_md56"></a>
As subdirectory of your project</h1>
<h2><a class="anchor" id="autotoc_md57"></a>
1. Fetching</h2>
<p>It is recommended to setup a <a href="http://git-scm.com/docs/git-submodule">git submodule</a> inside your project. Simply run:</p>
<ol type="1">
<li><code>git submodule add <a href="https://github.com/foonathan/memory">https://github.com/foonathan/memory</a> ext/memory</code>. This will clone the latest commit into a local directory <code>ext/memory</code> and registers it as a submodule.</li>
<li><code>git submodule update --init --recursive</code>. This will fetches the latest commits from all submodules <code>memory</code> itself is using.</li>
</ol>
<p>If you later want to update your local copy to the latest version, simply run: <code>git submodule update --recursive --remote</code>.</p>
<h2><a class="anchor" id="autotoc_md58"></a>
2. CMake Setup</h2>
<p>I am assuming that there is a local copy of the library source files under the path <code>ext/memory</code>.</p>
<p>In your <code>CMakeLists.txt</code> place a call to <code>add_subdirectory(ext/memory)</code>. This will make all targets of <code>memory</code> available inside your CMakeLists.txt. If you want to configure the library, add <code>set(option value CACHE INTERNAL "" FORCE)</code> before the <code>add_subdirectory()</code> command. See <a href="md_doc_options.html">options</a> for a list of all configuration options and CMake variables.</p>
<p>Now the targets is available and to use the library in your application, call to <code>target_link_libraries(target foonathan_memory)</code>. This will also setups the include search path of the compiler, as well as other required flags.</p>
<h2><a class="anchor" id="autotoc_md59"></a>
3. Code Usage</h2>
<p>In your code you simply need to include the appropriate headers and you are good to got. Everything is under the subdirectory <code>foonathan/memory</code> so write <code>#include &lt;foonathan/memory/heap_allocator.hpp&gt;</code> to use the <a class="el" href="group__allocator.html#ga22bca7a15392be2aa9be773d838ec4f4">heap_allocator</a>.</p>
<h1><a class="anchor" id="autotoc_md60"></a>
Installing the library</h1>
<p>Download or clone the source for the library version you want to install. You can build the library inside the source directory, it will not be needed after the installation.</p>
<p>For each build type, run <code>cmake -DCMAKE_BUILD_TYPE="buildtype" -DFOONATHAN_MEMORY_BUILD_EXAMPLES=OFF -DFOONATHAN_MEMORY_BUILD_TESTS=OFF .</code> with possible other <a href="md_doc_options.html">options</a> to configure, then simply <code>cmake --build . -- install</code> to build and install the library. This will install the header files under <code>${CMAKE_INSTALL_PREFIX}/include/foonathan_memory-${major}.${minor}</code>, the tools under <code>${CMAKE_INSTALL_PREFIX}/bin</code> and the build artifacts under <code>${CMAKE_INSTALL_PREFIX}/lib/foonathan_memory-${major}.${minor}</code>. By default, <code>${CMAKE_INSTALL_PREFIX}</code> is <code>/usr/local</code> under UNIX and <code>C:/Program Files</code> under Windows, installation may require <code>sudo</code>/administrative privileges.</p>
<p>It is recommended that you install the library for the <code>Debug</code>, <code>RelWithDebInfo</code> and <code>Release</code> build types. Each build type allows different CMake configurations and compiler flags, you can also create your own.</p>
<h1><a class="anchor" id="autotoc_md61"></a>
Using an installed library (CMake)</h1>
<p>After you've installed the library, all you need to call is <code>find_package(foonathan_memory major.minor REQUIRED)</code> to find it. This will look for a library installation of a compatible version and the same build type as your project, i.e. if you compile under build type <code>Debug</code>, it will also match the <code>Debug</code> library. This <em>should</em> work without your help, otherwise it will tell you what to do.</p>
<p>A <code>0.x</code> version requires an exact match in the call to <code>find_package()</code>, otherwise a library with same major version and a higher minor version is also compatible. If you want only exact version matches add the <code>EXACT</code> flag to <code>find_package()</code>.</p>
<p>If a right library version/configuration cannot be found, this is an error due to the <code>REQUIRED</code>. If this is not what you want, leave it out and do conditionals based on the CMake variable <code>foonathan_memory_FOUND</code>. In the source code, all targets linking to the library have the macro <code>FOONATHAN_MEMORY</code> defined automatically, as <code>FOONATHAN_MEMORY_VERSION_MAJOR/MINOR</code>. Use conditional compilation with them.</p>
<p>After that you can link to the library by calling <code>target_link_libraries(your_target PUBLIC foonathan_memory)</code>. This setups everything needed.</p>
<p>Then simply include the headers, everything is under the subdirectory <code>foonathan/memory</code> so write <code>#include &lt;foonathan/memory/heap_allocator.hpp&gt;</code> to use the <a class="el" href="group__allocator.html#ga22bca7a15392be2aa9be773d838ec4f4">heap_allocator</a>.</p>
<h1><a class="anchor" id="autotoc_md62"></a>
Using an installed library (other buildsystems)</h1>
<p>To use the library with other build-systems, add <code>${CMAKE_INSTALL_PREFIX}/include/foonathan_memory-${major}.${minor}</code> and <code>${CMAKE_INSTALL_PREFIX}/lib/foonathan_memory-${major}.${minor}/${CMAKE_BUILD_TYPE}</code> to your include directories path. Link to the library file in <code>${CMAKE_INSTALL_PREFIX}/lib/foonathan_memory-${major}.${minor}/${CMAKE_BUILD_TYPE}</code> and enable the right C++ standard for your configuration.</p>
<p>You should also globally define the <code>FOONATHAN_MEMORY</code> macro as <code>1</code> and the <code>FOONATHAN_MEMORY_VERSION_MAJOR/MINOR</code> macros as the corresponding values. </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
<!-- HTML footer for doxygen 1.8.16-->
<!-- 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.18
</small></address>
</body>
</html>
1
https://gitee.com/mobangjack/memory.git
git@gitee.com:mobangjack/memory.git
mobangjack
memory
memory
gh-pages

搜索帮助