-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_system.html
182 lines (163 loc) · 13.8 KB
/
build_system.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Build System — Lightmetrica Version 3 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<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>
<script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
<script src="https://unpkg.com/@jupyter-widgets/html-manager@^0.20.0/dist/embed-amd.js"></script>
<script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Component" href="component.html" />
<link rel="prev" title="Extending framework" href="extending_framework.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> Lightmetrica Version 3
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul>
<li class="toctree-l1"><a class="reference internal" href="intro.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Guide</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="build.html">Build</a></li>
<li class="toctree-l1"><a class="reference internal" href="managing_experiment.html">Managing experiments</a></li>
<li class="toctree-l1"><a class="reference internal" href="basic_rendering.html">Basic rendering</a></li>
<li class="toctree-l1"><a class="reference internal" href="extending_framework.html">Extending framework</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Advanced Topics</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">Build System</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#modern-cmake">Modern CMake</a></li>
<li class="toctree-l2"><a class="reference internal" href="#dependency-management">Dependency management</a></li>
<li class="toctree-l2"><a class="reference internal" href="#supporting-add-submodule">Supporting add_submodule</a></li>
<li class="toctree-l2"><a class="reference internal" href="#id1">Dependency management</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="component.html">Component</a></li>
<li class="toctree-l1"><a class="reference internal" href="python_binding.html">Python binding</a></li>
<li class="toctree-l1"><a class="reference internal" href="path_sampling.html">Path sampling</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Examples and tests</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="test.html">Tests in Lightmetrica</a></li>
<li class="toctree-l1"><a class="reference internal" href="example.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="functest.html">Functional tests</a></li>
<li class="toctree-l1"><a class="reference internal" href="perftest.html">Performance tests</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">References</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="component_ref.html">Built-in component reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="api_ref.html">API reference</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Lightmetrica Version 3</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home"></a> »</li>
<li>Build System</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/build_system.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<style>
/* CSS overrides for sphinx_rtd_theme */
/* 24px margin */
.nbinput.nblast.container,
.nboutput.nblast.container {
margin-bottom: 19px; /* padding has already 5px */
}
/* ... except between code cells! */
.nblast.container + .nbinput.container {
margin-top: -19px;
}
.admonition > p:before {
margin-right: 4px; /* make room for the exclamation icon */
}
/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */
.math {
text-align: unset;
}
</style>
<div class="section" id="build-system">
<h1>Build System<a class="headerlink" href="#build-system" title="Permalink to this headline"></a></h1>
<p>This section descripts design choices about the build system of Lightmetrica Version 3.</p>
<div class="section" id="modern-cmake">
<h2>Modern CMake<a class="headerlink" href="#modern-cmake" title="Permalink to this headline"></a></h2>
<p>The build system of Lighmetrica is organized by CMake scripts. In Lightmetrica Version 3, we refactored the scripts with modern design patterns. The updates include: target-based configuration, handling of the transitive dependencies (<code class="docutils literal notranslate"><span class="pre">PUBLIC</span></code>/<code class="docutils literal notranslate"><span class="pre">PRIVATE</span></code> targets), <code class="docutils literal notranslate"><span class="pre">INTERFACE</span></code> target for header-only dependencies, exported targets along with installation, and a preference to the Config mode package finding.</p>
</div>
<div class="section" id="dependency-management">
<h2>Dependency management<a class="headerlink" href="#dependency-management" title="Permalink to this headline"></a></h2>
<p>CMake can find external package with find_package command. This command finds the package based on the two different modes: Module mode and Config mode. To explain the difference, let’s assume we have an application <code class="docutils literal notranslate"><span class="pre">A</span></code> and its dependent library <code class="docutils literal notranslate"><span class="pre">B</span></code>. In Module mode, the application <code class="docutils literal notranslate"><span class="pre">A</span></code> finds the library <code class="docutils literal notranslate"><span class="pre">B</span></code> using <code class="docutils literal notranslate"><span class="pre">Find*.cmake</span></code> file (find-module). CMake distribution contains <code class="docutils literal notranslate"><span class="pre">Find*.cmake</span></code> files for famous libraries (e.g., boost) yet in most cases the developer of the application needs to provide the file. On the other hand, in Config mode, the application <code class="docutils literal notranslate"><span class="pre">A</span></code> finds the library <code class="docutils literal notranslate"><span class="pre">B</span></code> based on <code class="docutils literal notranslate"><span class="pre">*Config.cmake</span></code> file distributed along with the library. To support Config mode, the library needs to generate and install <code class="docutils literal notranslate"><span class="pre">*Config.cmake</span></code> file in the specific relative location in the installation directory. In other words, the difference between two modes is that in Module mode the application is responsible for finding the library, on the other hand in Config mode, the library is responsible for being found by the application.</p>
<p>In the previous versions of the framework, we used Module mode packages to find dependent libraries. We found, however, that using Module mode complicates the build process if the library is used as a library of other application because the application also needs to resolve the transitive dependencies of the library. For instance, this can happen in our case, e.g., when an experiment written in C++ (e.g., interactive visualization) wants to reference Lightmetrica as a dependent library. This means the library needs to distribute find-modules of the transitive dependencies as well as the module for the library itself. As a result, the developer of the application always needs to prepare for find-modules of the all dependencies including transitive dependencies.</p>
<p>In this version, on the contrary, we decided to use Config mode packages which can faithfully handle the transitive dependencies. Also, since Config mode packages are distributed along with the library distribution, the user does not need to prepare for the find-modules. To use Config mode packages throughout the build chain, we choose the dependencies which supports to export <code class="docutils literal notranslate"><span class="pre">*Config.cmake</span></code> files. If not supported, we patched the libraries.</p>
</div>
<div class="section" id="supporting-add-submodule">
<h2>Supporting add_submodule<a class="headerlink" href="#supporting-add-submodule" title="Permalink to this headline"></a></h2>
<p>On a small modification, Lightmetrica Version 3 can inject the library into the user application using either find_package command or <code class="docutils literal notranslate"><span class="pre">add_submodule</span></code> command. The latter approach is especially useful when you want to develop both experimental code and the framework managed in the different repository in the same time.</p>
</div>
<div class="section" id="id1">
<h2>Dependency management<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h2>
<p>In the previous versions, all library dependencies must be installed by a developer using pre-built binaries or platform-dependent package manager or libraries built from the sources. As a result, the installation of the dependencies differs in accordance with the platform. For instance, we provided a pre-built binaries for Windows environment but in Linux environment the developer needs to build the libraries from the source.</p>
<p>In this version, on the other hand, the dependencies can be installed via <a class="reference external" href="https://docs.conda.io/en/latest/">conda package manager</a> irrespective to the platform. Conda is a package manager and environment management system being mainly used in the Python community. Although conda is mainly used to distribute Python packages, it is in fact a language-agnostic package manager. For instance, we can introduce C++ libraries such as boost with conda. Combined with config-mode packages of CMake, the installed libraries can be easily integrated into the application configured with CMake. In this version, we could successfully export the all the necessary library dependencies to conda. This means the build-time dependencies can only be installed with one conda command. The actual dependencies are listed in <a class="reference external" href="https://github.com/lightmetrica/lightmetrica-v3/blob/master/environment.yml">environment.yml</a>.</p>
<p>Also, conda can manage its own separated environments where you can manage different sets of the conda packages. It is useful when we want to combine different versions of the library in the same machine. For instance, two different versions of the framework might depend on the different versions of the library. In this case, it is not feasible to maintain both versions in the system-wide package manager, but separating the environment can manage two different versions simultaneously. It is especially important in research context since this situation often happens for instance when we need to maintain different experiments written for the different projects against the different versions of the framework.</p>
</div>
</div>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="extending_framework.html" class="btn btn-neutral float-left" title="Extending framework" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="component.html" class="btn btn-neutral float-right" title="Component" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>© Copyright 2019, Hisanari Otsu.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>