Enable loop bb placement optimization.
[llvm/msp430.git] / docs / CMake.html
blob27ec88ec94788b253f5b07fa4551e9e29d9865fc
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4 <head>
5 <title>Building LLVM with CMake</title>
6 <link rel="stylesheet" href="llvm.css" type="text/css">
7 </head>
9 <div class="doc_title">
10 Building LLVM with CMake
11 </div>
13 <ul>
14 <li><a href="#intro">Introduction</a></li>
15 <li><a href="#quickstart">Quick start</a></li>
16 <li><a href="#usage">Basic CMake usage</a>
17 <li><a href="#options">Options and variables</a>
18 <ul>
19 <li><a href="#freccmake">Frequently-used CMake variables</a></li>
20 <li><a href="#llvmvars">LLVM-specific variables</a></li>
21 </ul></li>
22 <li><a href="#testing">Executing the test suite</a>
23 <li><a href="#cross">Cross compiling</a>
24 <li><a href="#embedding">Embedding LLVM in your project</a>
25 <li><a href="#specifics">Compiler/Platform specific topics</a>
26 <ul>
27 <li><a href="#msvc">Microsoft Visual C++</a></li>
28 </ul></li>
29 </ul>
31 <div class="doc_author">
32 <p>Written by <a href="mailto:ofv@wanadoo.es">Oscar Fuentes</a></p>
33 </div>
35 <!-- *********************************************************************** -->
36 <div class="doc_section">
37 <a name="intro">Introduction</a>
38 </div>
39 <!-- *********************************************************************** -->
41 <div class="doc_text">
43 <p><a href="http://www.cmake.org/">CMake</a> is a cross-platform
44 build-generator tool. CMake does not build the project, it generates
45 the files needed by your build tool (GNU make, Visual Studio, etc) for
46 building LLVM.</p>
48 <p>If you are really anxious about getting a functional LLVM build,
49 go to the <a href="#quickstart">Quick start</a> section. If you
50 are a CMake novice, start on <a href="#usage">Basic CMake
51 usage</a> and then go back to the <a href="#quickstart">Quick
52 start</a> once you know what you are
53 doing. The <a href="#options">Options and variables</a> section
54 is a reference for customizing your build. If you already have
55 experience with CMake, this is the recommended starting point.
56 </div>
58 <!-- *********************************************************************** -->
59 <div class="doc_section">
60 <a name="quickstart">Quick start</a>
61 </div>
62 <!-- *********************************************************************** -->
64 <div class="doc_text">
66 <p> We use here the command-line, non-interactive CMake interface </p>
68 <ol>
70 <li><p><a href=http://www.cmake.org/cmake/resources/software.html>Download</a>
71 and install CMake. Version 2.6.2 is the minimum required.</p>
73 <li><p>Open a shell. Your development tools must be reachable from this
74 shell through the PATH environment variable.</p>
76 <li><p>Create a directory for containing the build. It is not
77 supported to build LLVM on the source directory. cd to this
78 directory:</p>
79 <div class="doc_code">
80 <p><tt>mkdir mybuilddir</tt></p>
81 <p><tt>cd mybuilddir</tt></p>
82 </div>
84 <li><p>Execute this command on the shell
85 replacing <i>path/to/llvm/source/root</i> with the path to the
86 root of your LLVM source tree:</p>
87 <div class="doc_code">
88 <p><tt>cmake path/to/llvm/source/root</tt></p>
89 </div>
91 <p>CMake will detect your development environment, perform a
92 series of test and generate the files required for building
93 LLVM. CMake will use default values for all build
94 parameters. See the <a href="#options">Options and variables</a>
95 section for fine-tuning your build</p>
97 <p>This can fail if CMake can't detect your toolset, or if it
98 thinks that the environment is not sane enough. On this case
99 make sure that the toolset that you intend to use is the only
100 one reachable from the shell and that the shell itself is the
101 correct one for you development environment. CMake will refuse
102 to build MinGW makefiles if you have a POSIX shell reachable
103 through the PATH environment variable, for instance. You can
104 force CMake to use a given build tool, see
105 the <a href="#usage">Usage</a> section.</p>
107 </ol>
109 </div>
111 <!-- *********************************************************************** -->
112 <div class="doc_section">
113 <a name="usage">Basic CMake usage</a>
114 </div>
115 <!-- *********************************************************************** -->
117 <div class="doc_text">
119 <p>This section explains basic aspects of CMake, mostly for
120 explaining those options which you may need on your day-to-day
121 usage.</p>
123 <p>CMake comes with extensive documentation in the form of html
124 files and on the cmake executable itself. Execute <i>cmake
125 --help</i> for further help options.</p>
127 <p>CMake requires to know for which build tool it shall generate
128 files (GNU make, Visual Studio, Xcode, etc). If not specified on
129 the command line, it tries to guess it based on you
130 environment. Once identified the build tool, CMake uses the
131 corresponding <i>Generator</i> for creating files for your build
132 tool. You can explicitly specify the generator with the command
133 line option <i>-G "Name of the generator"</i>. For knowing the
134 available generators on your platform, execute</p>
136 <div class="doc_code">
137 <p><tt>cmake --help</tt></p>
138 </div>
140 <p>This will list the generator's names at the end of the help
141 text. Generator's names are case-sensitive. Example:</p>
143 <div class="doc_code">
144 <p><tt>cmake -G "Visual Studio 8 2005" path/to/llvm/source/root</tt></p>
145 </div>
147 <p>For a given development platform there can be more than one
148 adequate generator. If you use Visual Studio "NMake Makefiles"
149 is a generator you can use for building with NMake. By default,
150 CMake chooses the more specific generator supported by your
151 development environment. If you want an alternative generator,
152 you must tell this to CMake with the <i>-G</i> option.</p>
154 <p>TODO: explain variables and cache. Move explanation here from
155 #options section.</p>
157 </div>
159 <!-- *********************************************************************** -->
160 <div class="doc_section">
161 <a name="options">Options and variables</a>
162 </div>
163 <!-- *********************************************************************** -->
165 <div class="doc_text">
167 <p>Variables customize how the build will be generated. Options are
168 boolean variables, with possible values ON/OFF. Options and
169 variables are defined on the CMake command line like this:</p>
171 <div class="doc_code">
172 <p><tt>cmake -DVARIABLE=value path/to/llvm/source</tt></p>
173 </div>
175 <p>You can set a variable after the initial CMake invocation for
176 changing its value. You can also undefine a variable:</p>
178 <div class="doc_code">
179 <p><tt>cmake -UVARIABLE path/to/llvm/source</tt></p>
180 </div>
182 <p>Variables are stored on the CMake cache. This is a file
183 named <it>CMakeCache.txt</it> on the root of the build
184 directory. Do not hand-edit it.</p>
186 <p>Variables are listed here appending its type after a colon. It is
187 correct to write the variable and the type on the CMake command
188 line:</p>
190 <div class="doc_code">
191 <p><tt>cmake -DVARIABLE:TYPE=value path/to/llvm/source</tt></p>
192 </div>
194 </div>
196 <!-- ======================================================================= -->
197 <div class="doc_subsection">
198 <a name="freccmake">Frequently-used CMake variables</a>
199 </div>
201 <div class="doc_text">
203 <p>Here are listed some of the CMake variables that are used often,
204 along with a brief explanation and LLVM-specific notes. For full
205 documentation, check the CMake docs or execute <i>cmake
206 --help-variable VARIABLE_NAME</i>.</p>
208 <dl>
209 <dt><b>CMAKE_BUILD_TYPE</b>:STRING</dt>
211 <dd>Sets the build type for <i>make</i> based generators. Possible
212 values are Release, Debug, RelWithDebInfo and MiniSizeRel. On
213 systems like Visual Studio the user sets the build type with the IDE
214 settings.</dd>
216 <dt><b>CMAKE_INSTALL_PREFIX</b>:PATH</dt>
217 <dd>Path where LLVM will be installed if "make install" is invoked
218 or the "INSTALL" target is built.</dd>
220 <dt><b>CMAKE_C_FLAGS</b>:STRING</dt>
221 <dd>Extra flags to use when compiling C source files.</dd>
223 <dt><b>CMAKE_CXX_FLAGS</b>:STRING</dt>
224 <dd>Extra flags to use when compiling C++ source files.</dd>
226 <dt><b>BUILD_SHARED_LIBS</b>:BOOL</dt>
227 <dd>Flag indicating is shared libraries will be built. Its default
228 value is OFF. Shared libraries are not supported on Windows and
229 not recommended in the other OSes.</dd>
230 </dl>
232 </div>
234 <!-- ======================================================================= -->
235 <div class="doc_subsection">
236 <a name="llvmvars">LLVM-specific variables</a>
237 </div>
239 <div class="doc_text">
241 <dl>
242 <dt><b>LLVM_TARGETS_TO_BUILD</b>:STRING</dt>
243 <dd>Semicolon-separated list of targets to build, or <i>all</i> for
244 building all targets. Case-sensitive. For Visual C++ defaults
245 to <i>X86</i>. On the other cases defaults to <i>all</i>. Example:
246 <i>-DLLVM_TARGETS_TO_BUILD="X86;PowerPC;Alpha"</i>.</dd>
248 <dt><b>LLVM_ENABLE_THREADS</b>:BOOL</dt>
249 <dd>Build with threads support, if available. Defaults to ON.</dd>
251 <dt><b>LLVM_ENABLE_PIC</b>:BOOL</dt>
252 <dd>Add the <i>-fPIC</i> flag to the compiler command-line, if the
253 compiler supports this flag. Some systems, like Windows, does not
254 need this flag. Defaults to OFF.</dd>
256 <dt><b>LLVM_BUILD_32_BITS</b>:BOOL</dt>
257 <dd>Build 32-bits executables and libraries on 64-bits systems. This
258 option is available only on some 64-bits unix systems. Defaults to
259 OFF.</dd>
261 <dt><b>LLVM_PLO_FLAGS</b>:STRING</dt>
262 <dd>Extra flags for creating partially linked objects. Visual C++
263 does not use this.</dd>
265 <dt><b>LLVM_TABLEGEN</b>:STRING</dt>
266 <dd>Full path to a native TableGen executable (usually
267 named <i>tblgen</i>). This is intented for cross-compiling: if the
268 user sets this variable, no native TableGen will be created.</dd>
269 </dl>
271 </div>
273 <!-- *********************************************************************** -->
274 <div class="doc_section">
275 <a name="testing">Executing the test suite</a>
276 </div>
277 <!-- *********************************************************************** -->
279 <div class="doc_text">
281 <p>LLVM testing is not supported on Visual Studio.</p>
283 <p>TODO</p>
285 </div>
287 <!-- *********************************************************************** -->
288 <div class="doc_section">
289 <a name="cross">Cross compiling</a>
290 </div>
291 <!-- *********************************************************************** -->
293 <div class="doc_text">
295 <p>TODO</p>
297 </div>
299 <!-- *********************************************************************** -->
300 <div class="doc_section">
301 <a name="embedding">Embedding LLVM in your project</a>
302 </div>
303 <!-- *********************************************************************** -->
305 <div class="doc_text">
307 <p>TODO</p>
309 </div>
311 <!-- *********************************************************************** -->
313 <!-- *********************************************************************** -->
314 <div class="doc_section">
315 <a name="specifics">Compiler/Platform specific topics</a>
316 </div>
317 <!-- *********************************************************************** -->
319 <div class="doc_text">
321 <p>Notes for specific compilers and/or platforms.</p>
323 </div>
325 <!-- ======================================================================= -->
326 <div class="doc_subsection">
327 <a name="msvc">Microsoft Visual C++</a>
328 </div>
330 <div class="doc_text">
332 <p>For linking the JIT into your executable, add</p>
334 <div class="doc_code">
335 <p><tt>/INCLUDE:_X86TargetMachineModule</tt></p>
336 </div>
338 <p>to your linker options. This is required for adding the relevant
339 LLVM object code to the executable. Not doing this will result on
340 some methods returning NULL (<i>ExecutionEngine::create</i>, for
341 instance).</p>
343 </div>
345 <!-- *********************************************************************** -->
347 <hr>
348 <address>
349 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
350 src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
351 <a href="http://validator.w3.org/check/referer"><img
352 src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
354 <a href="mailto:ofv@wanadoo.es">Oscar Fuentes</a><br>
355 <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br>
356 Last modified: $Date: 2008-12-31 03:59:36 +0100 (Wed, 31 Dec 2008) $
357 </address>
359 </body>
360 </html>