1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
5 <title>Building LLVM with CMake</title>
6 <link rel="stylesheet" href="llvm.css" type="text/css">
9 <div class="doc_title">
10 Building LLVM with CMake
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>
19 <li><a href="#freccmake">Frequently-used CMake variables</a></li>
20 <li><a href="#llvmvars">LLVM-specific variables</a></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>
27 <div class="doc_author">
28 <p>Written by <a href="mailto:ofv@wanadoo.es">Óscar Fuentes</a></p>
31 <!-- *********************************************************************** -->
32 <div class="doc_section">
33 <a name="intro">Introduction</a>
35 <!-- *********************************************************************** -->
37 <div class="doc_text">
39 <p><a href="http://www.cmake.org/">CMake</a> is a cross-platform
40 build-generator tool. CMake does not build the project, it generates
41 the files needed by your build tool (GNU make, Visual Studio, etc) for
44 <p>If you are really anxious
47 <!-- *********************************************************************** -->
48 <div class="doc_section">
49 <a name="quickstart">Quick start</a>
51 <!-- *********************************************************************** -->
53 <div class="doc_text">
55 <p> We use here the command-line, non-interactive CMake interface </p>
59 <li><p><a href=http://www.cmake.org/cmake/resources/software.html>Download</a>
60 and install CMake. Version 2.6.2 is the minimum required.</p>
62 <li><p>Open a shell. Your development tools must be reachable from this
63 shell through the PATH environment variable.</p>
65 <li><p>Create a directory for containing the build. It is not
66 supported to build LLVM on the source directory. cd to this
68 <div class="doc_code">
69 <p><tt>mkdir mybuilddir</tt></p>
70 <p><tt>cd mybuilddir</tt></p>
73 <li><p>Execute this command on the shell
74 replacing <i>path/to/llvm/source/root</i> with the path to the
75 root of your LLVM source tree:</p>
76 <div class="doc_code">
77 <p><tt>cmake path/to/llvm/source/root</tt></p>
80 <p>CMake will detect your development environment, perform a
81 series of test and generate the files required for building
82 LLVM. CMake will use default values for all build
83 parameters. See the <a href="#options">Options and variables</a>
84 section for fine-tuning your build</p>
86 <p>This can fail if CMake can't detect your toolset, or if it
87 thinks that the environment is not sane enough. On this case
88 make sure that the toolset that you intend to use is the only
89 one reachable from the shell and that the shell itself is the
90 correct one for you development environment. CMake will refuse
91 to build MinGW makefiles if you have a POSIX shell reachable
92 through the PATH environment variable, for instance. You can
93 force CMake to use a given build tool, see
94 the <a href="#usage">Usage</a> section.</p>
100 <!-- *********************************************************************** -->
101 <div class="doc_section">
102 <a name="usage">Basic CMake usage</a>
104 <!-- *********************************************************************** -->
106 <div class="doc_text">
112 <!-- *********************************************************************** -->
113 <div class="doc_section">
114 <a name="options">Options and variables</a>
116 <!-- *********************************************************************** -->
118 <div class="doc_text">
120 <p>Variables customize how the build will be generated. Options are
121 boolean variables, with possible values ON/OFF. Options and
122 variables are defined on the CMake command line like this:</p>
124 <div class="doc_code">
125 <p><tt>cmake -DVARIABLE=value path/to/llvm/source</tt></p>
128 <p>You can set a variable after the initial CMake invocation for
129 changing its value. You can also undefine a variable:</p>
131 <div class="doc_code">
132 <p><tt>cmake -UVARIABLE path/to/llvm/source</tt></p>
135 <p>Variables are stored on the CMake cache. This is a file
136 named <it>CMakeCache.txt</it> on the root of the build
137 directory. Do not hand-edit it.</p>
139 <p>Variables are listed here appending its type after a colon. It is
140 correct to write the variable and the type on the CMake command
143 <div class="doc_code">
144 <p><tt>cmake -DVARIABLE:TYPE=value path/to/llvm/source</tt></p>
149 <!-- ======================================================================= -->
150 <div class="doc_subsection">
151 <a name="freccmake">Frequently-used CMake variables</a>
154 <div class="doc_text">
156 <p>Here are listed some of the CMake variables that are used often,
157 along with a brief explanation and LLVM-specific notes. For full
158 documentation, check the CMake docs or execute <i>cmake
159 --help-variable VARIABLE_NAME</i>.
162 <dt><b>CMAKE_BUILD_TYPE</b>:STRING</dt>
164 <dd>Sets the build type for <i>make</i> based generators. Possible
165 values are Release, Debug, RelWithDebInfo and MiniSizeRel. On
166 systems like Visual Studio the user sets the build type with the IDE
169 <dt><b>CMAKE_INSTALL_PREFIX</b>:PATH</dt>
170 <dd>Path where LLVM will be installed if "make install" is invoked
171 or the "INSTALL" target is built.</dd>
173 <dt><b>BUILD_SHARED_LIBS</b>:BOOL</dt>
174 <dd>Flag indicating is shared libraries will be built. Its default
175 value is OFF. Shared libraries are not supported on Windows and
176 not recommended in the other OSes.</dd>
181 <!-- ======================================================================= -->
182 <div class="doc_subsection">
183 <a name="llvmvars">LLVM-specific variables</a>
186 <div class="doc_text">
189 <dt><b>LLVM_TARGETS_TO_BUILD</b>:STRING</dt>
190 <dd>Semicolon-separated list of targets to build, or <i>all</i> for
191 building all targets. Case-sensitive. For Visual C++ defaults
192 to <i>X86</i>. On the other cases defaults to <i>all</i>. Example:
193 <i>-DLLVM_TARGETS_TO_BUILD="X86;PowerPC;Alpha"</i>.</dd>
195 <dt><b>LLVM_ENABLE_THREADS</b>:BOOL</dt>
196 <dd>Build with threads support, if available. Defaults to ON.</dd>
198 <dt><b>LLVM_ENABLE_PIC</b>:BOOL</dt>
199 <dd>Add the <i>-fPIC</i> flag to the compiler command-line, if the
200 compiler supports this flag. Some systems, like Windows, does not
201 need this flag. Defaults to OFF.</dd>
203 <dt><b>LLVM_BUILD_32_BITS</b>:BOOL</dt>
204 <dd>Build 32-bits executables and libraries on 64-bits systems. This
205 option is available only on some 64-bits unix systems. Defaults to
208 <dt><b>LLVM_PLO_FLAGS</b>:STRING</dt>
209 <dd>Extra flags for creating partially linked objects. Visual C++
210 does not use this.</dd>
212 <dt><b>LLVM_TABLEGEN</b>:STRING</dt>
213 <dd>Full path to a native TableGen executable (usually
214 named <i>tblgen</i>). This is intented for cross-compiling: if the
215 user sets this variable, no native TableGen will be created.</dd>
220 <!-- *********************************************************************** -->
221 <div class="doc_section">
222 <a name="testing">Executing the test suite</a>
224 <!-- *********************************************************************** -->
226 <div class="doc_text">
232 <!-- *********************************************************************** -->
233 <div class="doc_section">
234 <a name="cross">Cross compiling</a>
236 <!-- *********************************************************************** -->
238 <div class="doc_text">
244 <!-- *********************************************************************** -->
245 <div class="doc_section">
246 <a name="embedding">Embedding LLVM in your project</a>
248 <!-- *********************************************************************** -->
250 <div class="doc_text">
256 <!-- *********************************************************************** -->
260 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
261 src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
262 <a href="http://validator.w3.org/check/referer"><img
263 src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
265 <a href="mailto:ofv@wanadoo.es">Óscar Fuentes</a><br>
266 <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br>
267 Last modified: $Date: 2008-10-27 00:59:36 +0100 (Mon, 27 Oct 2008) $