/usr/share/doc/llvm-3.5-doc/html/CMake.html is in llvm-3.5-doc 1:3.5-10.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | <!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/html; charset=utf-8" />
<title>Building LLVM with CMake — LLVM 3.5 documentation</title>
<link rel="stylesheet" href="_static/llvm-theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '3.5',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="LLVM 3.5 documentation" href="index.html" />
<link rel="next" title="How To Build On ARM" href="HowToBuildOnARM.html" />
<link rel="prev" title="LLVM Language Reference Manual" href="LangRef.html" />
<style type="text/css">
table.right { float: right; margin-left: 20px; }
table.right td { border: 1px solid #ccc; }
</style>
</head>
<body>
<div class="logo">
<a href="index.html">
<img src="_static/logo.png"
alt="LLVM Logo" width="250" height="88"/></a>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="HowToBuildOnARM.html" title="How To Build On ARM"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="LangRef.html" title="LLVM Language Reference Manual"
accesskey="P">previous</a> |</li>
<li><a href="http://llvm.org/">LLVM Home</a> | </li>
<li><a href="index.html">Documentation</a>»</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="body">
<div class="section" id="building-llvm-with-cmake">
<h1>Building LLVM with CMake<a class="headerlink" href="#building-llvm-with-cmake" title="Permalink to this headline">¶</a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#introduction" id="id6">Introduction</a></li>
<li><a class="reference internal" href="#quick-start" id="id7">Quick start</a></li>
<li><a class="reference internal" href="#usage" id="id8">Basic CMake usage</a></li>
<li><a class="reference internal" href="#options-and-variables" id="id9">Options and variables</a><ul>
<li><a class="reference internal" href="#frequently-used-cmake-variables" id="id10">Frequently-used CMake variables</a></li>
<li><a class="reference internal" href="#llvm-specific-variables" id="id11">LLVM-specific variables</a></li>
</ul>
</li>
<li><a class="reference internal" href="#executing-the-test-suite" id="id12">Executing the test suite</a></li>
<li><a class="reference internal" href="#cross-compiling" id="id13">Cross compiling</a></li>
<li><a class="reference internal" href="#embedding-llvm-in-your-project" id="id14">Embedding LLVM in your project</a><ul>
<li><a class="reference internal" href="#developing-llvm-passes-out-of-source" id="id15">Developing LLVM passes out of source</a></li>
</ul>
</li>
<li><a class="reference internal" href="#compiler-platform-specific-topics" id="id16">Compiler/Platform-specific topics</a><ul>
<li><a class="reference internal" href="#microsoft-visual-c" id="id17">Microsoft Visual C++</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="introduction">
<h2><a class="toc-backref" href="#id6">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p><a class="reference external" href="http://www.cmake.org/">CMake</a> is a cross-platform build-generator tool. CMake
does not build the project, it generates the files needed by your build tool
(GNU make, Visual Studio, etc) for building LLVM.</p>
<p>If you are really anxious about getting a functional LLVM build, go to the
<a class="reference internal" href="#quick-start">Quick start</a> section. If you are a CMake novice, start on <a class="reference internal" href="#basic-cmake-usage">Basic CMake usage</a>
and then go back to the <a class="reference internal" href="#quick-start">Quick start</a> once you know what you are doing. The
<a class="reference internal" href="#options-and-variables">Options and variables</a> section is a reference for customizing your build. If
you already have experience with CMake, this is the recommended starting point.</p>
</div>
<div class="section" id="quick-start">
<span id="id1"></span><h2><a class="toc-backref" href="#id7">Quick start</a><a class="headerlink" href="#quick-start" title="Permalink to this headline">¶</a></h2>
<p>We use here the command-line, non-interactive CMake interface.</p>
<ol class="arabic">
<li><p class="first"><a class="reference external" href="http://www.cmake.org/cmake/resources/software.html">Download</a> and install
CMake. Version 2.8 is the minimum required.</p>
</li>
<li><p class="first">Open a shell. Your development tools must be reachable from this shell
through the PATH environment variable.</p>
</li>
<li><p class="first">Create a directory for containing the build. It is not supported to build
LLVM on the source directory. cd to this directory:</p>
<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> mkdir mybuilddir
<span class="gp">$</span> <span class="nb">cd </span>mybuilddir
</pre></div>
</div>
</li>
<li><p class="first">Execute this command on the shell replacing <cite>path/to/llvm/source/root</cite> with
the path to the root of your LLVM source tree:</p>
<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> cmake path/to/llvm/source/root
</pre></div>
</div>
<p>CMake will detect your development environment, perform a series of test and
generate the files required for building LLVM. CMake will use default values
for all build parameters. See the <a class="reference internal" href="#options-and-variables">Options and variables</a> section for
fine-tuning your build</p>
<p>This can fail if CMake can’t detect your toolset, or if it thinks that the
environment is not sane enough. On this case make sure that the toolset that
you intend to use is the only one reachable from the shell and that the shell
itself is the correct one for you development environment. CMake will refuse
to build MinGW makefiles if you have a POSIX shell reachable through the PATH
environment variable, for instance. You can force CMake to use a given build
tool, see the <a class="reference internal" href="#usage">Usage</a> section.</p>
</li>
</ol>
</div>
<div class="section" id="usage">
<span id="basic-cmake-usage"></span><span id="id2"></span><h2><a class="toc-backref" href="#id8">Basic CMake usage</a><a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2>
<p>This section explains basic aspects of CMake, mostly for explaining those
options which you may need on your day-to-day usage.</p>
<p>CMake comes with extensive documentation in the form of html files and on the
cmake executable itself. Execute <tt class="docutils literal"><span class="pre">cmake</span> <span class="pre">--help</span></tt> for further help options.</p>
<p>CMake requires to know for which build tool it shall generate files (GNU make,
Visual Studio, Xcode, etc). If not specified on the command line, it tries to
guess it based on you environment. Once identified the build tool, CMake uses
the corresponding <em>Generator</em> for creating files for your build tool. You can
explicitly specify the generator with the command line option <tt class="docutils literal"><span class="pre">-G</span> <span class="pre">"Name</span> <span class="pre">of</span> <span class="pre">the</span>
<span class="pre">generator"</span></tt>. For knowing the available generators on your platform, execute</p>
<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> cmake --help
</pre></div>
</div>
<p>This will list the generator’s names at the end of the help text. Generator’s
names are case-sensitive. Example:</p>
<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> cmake -G <span class="s2">"Visual Studio 11"</span> path/to/llvm/source/root
</pre></div>
</div>
<p>For a given development platform there can be more than one adequate
generator. If you use Visual Studio “NMake Makefiles” is a generator you can use
for building with NMake. By default, CMake chooses the more specific generator
supported by your development environment. If you want an alternative generator,
you must tell this to CMake with the <tt class="docutils literal"><span class="pre">-G</span></tt> option.</p>
</div>
<div class="section" id="options-and-variables">
<span id="id3"></span><h2><a class="toc-backref" href="#id9">Options and variables</a><a class="headerlink" href="#options-and-variables" title="Permalink to this headline">¶</a></h2>
<p>Variables customize how the build will be generated. Options are boolean
variables, with possible values ON/OFF. Options and variables are defined on the
CMake command line like this:</p>
<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> cmake -DVARIABLE<span class="o">=</span>value path/to/llvm/source
</pre></div>
</div>
<p>You can set a variable after the initial CMake invocation for changing its
value. You can also undefine a variable:</p>
<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> cmake -UVARIABLE path/to/llvm/source
</pre></div>
</div>
<p>Variables are stored on the CMake cache. This is a file named <tt class="docutils literal"><span class="pre">CMakeCache.txt</span></tt>
on the root of the build directory. Do not hand-edit it.</p>
<p>Variables are listed here appending its type after a colon. It is correct to
write the variable and the type on the CMake command line:</p>
<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> cmake -DVARIABLE:TYPE<span class="o">=</span>value path/to/llvm/source
</pre></div>
</div>
<div class="section" id="frequently-used-cmake-variables">
<h3><a class="toc-backref" href="#id10">Frequently-used CMake variables</a><a class="headerlink" href="#frequently-used-cmake-variables" title="Permalink to this headline">¶</a></h3>
<p>Here are some of the CMake variables that are used often, along with a
brief explanation and LLVM-specific notes. For full documentation, check the
CMake docs or execute <tt class="docutils literal"><span class="pre">cmake</span> <span class="pre">--help-variable</span> <span class="pre">VARIABLE_NAME</span></tt>.</p>
<dl class="docutils">
<dt><strong>CMAKE_BUILD_TYPE</strong>:STRING</dt>
<dd>Sets the build type for <tt class="docutils literal"><span class="pre">make</span></tt> based generators. Possible values are
Release, Debug, RelWithDebInfo and MinSizeRel. On systems like Visual Studio
the user sets the build type with the IDE settings.</dd>
<dt><strong>CMAKE_INSTALL_PREFIX</strong>:PATH</dt>
<dd>Path where LLVM will be installed if “make install” is invoked or the
“INSTALL” target is built.</dd>
<dt><strong>LLVM_LIBDIR_SUFFIX</strong>:STRING</dt>
<dd>Extra suffix to append to the directory where libraries are to be
installed. On a 64-bit architecture, one could use <tt class="docutils literal"><span class="pre">-DLLVM_LIBDIR_SUFFIX=64</span></tt>
to install libraries to <tt class="docutils literal"><span class="pre">/usr/lib64</span></tt>.</dd>
<dt><strong>CMAKE_C_FLAGS</strong>:STRING</dt>
<dd>Extra flags to use when compiling C source files.</dd>
<dt><strong>CMAKE_CXX_FLAGS</strong>:STRING</dt>
<dd>Extra flags to use when compiling C++ source files.</dd>
<dt><strong>BUILD_SHARED_LIBS</strong>:BOOL</dt>
<dd>Flag indicating if shared libraries will be built. Its default value is
OFF. Shared libraries are not supported on Windows and not recommended on the
other OSes.</dd>
</dl>
</div>
<div class="section" id="llvm-specific-variables">
<span id="id4"></span><h3><a class="toc-backref" href="#id11">LLVM-specific variables</a><a class="headerlink" href="#llvm-specific-variables" title="Permalink to this headline">¶</a></h3>
<dl class="docutils">
<dt><strong>LLVM_TARGETS_TO_BUILD</strong>:STRING</dt>
<dd>Semicolon-separated list of targets to build, or <em>all</em> for building all
targets. Case-sensitive. Defaults to <em>all</em>. Example:
<tt class="docutils literal"><span class="pre">-DLLVM_TARGETS_TO_BUILD="X86;PowerPC"</span></tt>.</dd>
<dt><strong>LLVM_BUILD_TOOLS</strong>:BOOL</dt>
<dd>Build LLVM tools. Defaults to ON. Targets for building each tool are generated
in any case. You can build an tool separately by invoking its target. For
example, you can build <em>llvm-as</em> with a makefile-based system executing <em>make
llvm-as</em> on the root of your build directory.</dd>
<dt><strong>LLVM_INCLUDE_TOOLS</strong>:BOOL</dt>
<dd>Generate build targets for the LLVM tools. Defaults to ON. You can use that
option for disabling the generation of build targets for the LLVM tools.</dd>
<dt><strong>LLVM_BUILD_EXAMPLES</strong>:BOOL</dt>
<dd>Build LLVM examples. Defaults to OFF. Targets for building each example are
generated in any case. See documentation for <em>LLVM_BUILD_TOOLS</em> above for more
details.</dd>
<dt><strong>LLVM_INCLUDE_EXAMPLES</strong>:BOOL</dt>
<dd>Generate build targets for the LLVM examples. Defaults to ON. You can use that
option for disabling the generation of build targets for the LLVM examples.</dd>
<dt><strong>LLVM_BUILD_TESTS</strong>:BOOL</dt>
<dd>Build LLVM unit tests. Defaults to OFF. Targets for building each unit test
are generated in any case. You can build a specific unit test with the target
<em>UnitTestNameTests</em> (where at this time <em>UnitTestName</em> can be ADT, Analysis,
ExecutionEngine, JIT, Support, Transform, VMCore; see the subdirectories of
<em>unittests</em> for an updated list.) It is possible to build all unit tests with
the target <em>UnitTests</em>.</dd>
<dt><strong>LLVM_INCLUDE_TESTS</strong>:BOOL</dt>
<dd>Generate build targets for the LLVM unit tests. Defaults to ON. You can use
that option for disabling the generation of build targets for the LLVM unit
tests.</dd>
<dt><strong>LLVM_APPEND_VC_REV</strong>:BOOL</dt>
<dd>Append version control revision info (svn revision number or Git revision id)
to LLVM version string (stored in the PACKAGE_VERSION macro). For this to work
cmake must be invoked before the build. Defaults to OFF.</dd>
<dt><strong>LLVM_ENABLE_THREADS</strong>:BOOL</dt>
<dd>Build with threads support, if available. Defaults to ON.</dd>
<dt><strong>LLVM_ENABLE_CXX1Y</strong>:BOOL</dt>
<dd>Build in C++1y mode, if available. Defaults to OFF.</dd>
<dt><strong>LLVM_ENABLE_ASSERTIONS</strong>:BOOL</dt>
<dd>Enables code assertions. Defaults to OFF if and only if <tt class="docutils literal"><span class="pre">CMAKE_BUILD_TYPE</span></tt>
is <em>Release</em>.</dd>
<dt><strong>LLVM_ENABLE_EH</strong>:BOOL</dt>
<dd>Build LLVM with exception handling support. This is necessary if you wish to
link against LLVM libraries and make use of C++ exceptions in your own code
that need to propagate through LLVM code. Defaults to OFF.</dd>
<dt><strong>LLVM_ENABLE_PIC</strong>:BOOL</dt>
<dd>Add the <tt class="docutils literal"><span class="pre">-fPIC</span></tt> flag for the compiler command-line, if the compiler supports
this flag. Some systems, like Windows, do not need this flag. Defaults to ON.</dd>
<dt><strong>LLVM_ENABLE_RTTI</strong>:BOOL</dt>
<dd>Build LLVM with run time type information. Defaults to OFF.</dd>
<dt><strong>LLVM_ENABLE_WARNINGS</strong>:BOOL</dt>
<dd>Enable all compiler warnings. Defaults to ON.</dd>
<dt><strong>LLVM_ENABLE_PEDANTIC</strong>:BOOL</dt>
<dd>Enable pedantic mode. This disable compiler specific extensions, is
possible. Defaults to ON.</dd>
<dt><strong>LLVM_ENABLE_WERROR</strong>:BOOL</dt>
<dd>Stop and fail build, if a compiler warning is triggered. Defaults to OFF.</dd>
<dt><strong>LLVM_BUILD_32_BITS</strong>:BOOL</dt>
<dd>Build 32-bits executables and libraries on 64-bits systems. This option is
available only on some 64-bits unix systems. Defaults to OFF.</dd>
<dt><strong>LLVM_TARGET_ARCH</strong>:STRING</dt>
<dd>LLVM target to use for native code generation. This is required for JIT
generation. It defaults to “host”, meaning that it shall pick the architecture
of the machine where LLVM is being built. If you are cross-compiling, set it
to the target architecture name.</dd>
<dt><strong>LLVM_TABLEGEN</strong>:STRING</dt>
<dd>Full path to a native TableGen executable (usually named <tt class="docutils literal"><span class="pre">tblgen</span></tt>). This is
intended for cross-compiling: if the user sets this variable, no native
TableGen will be created.</dd>
<dt><strong>LLVM_LIT_ARGS</strong>:STRING</dt>
<dd>Arguments given to lit. <tt class="docutils literal"><span class="pre">make</span> <span class="pre">check</span></tt> and <tt class="docutils literal"><span class="pre">make</span> <span class="pre">clang-test</span></tt> are affected.
By default, <tt class="docutils literal"><span class="pre">'-sv</span> <span class="pre">--no-progress-bar'</span></tt> on Visual C++ and Xcode, <tt class="docutils literal"><span class="pre">'-sv'</span></tt> on
others.</dd>
<dt><strong>LLVM_LIT_TOOLS_DIR</strong>:PATH</dt>
<dd>The path to GnuWin32 tools for tests. Valid on Windows host. Defaults to “”,
then Lit seeks tools according to %PATH%. Lit can find tools(eg. grep, sort,
&c) on LLVM_LIT_TOOLS_DIR at first, without specifying GnuWin32 to %PATH%.</dd>
<dt><strong>LLVM_ENABLE_FFI</strong>:BOOL</dt>
<dd>Indicates whether LLVM Interpreter will be linked with Foreign Function
Interface library. If the library or its headers are installed on a custom
location, you can set the variables FFI_INCLUDE_DIR and
FFI_LIBRARY_DIR. Defaults to OFF.</dd>
<dt><strong>LLVM_EXTERNAL_{CLANG,LLD,POLLY}_SOURCE_DIR</strong>:PATH</dt>
<dd>Path to <tt class="docutils literal"><span class="pre">{Clang,lld,Polly}</span></tt>‘s source directory. Defaults to
<tt class="docutils literal"><span class="pre">tools/{clang,lld,polly}</span></tt>. <tt class="docutils literal"><span class="pre">{Clang,lld,Polly}</span></tt> will not be built when it
is empty or it does not point to a valid path.</dd>
<dt><strong>LLVM_USE_OPROFILE</strong>:BOOL</dt>
<dd>Enable building OProfile JIT support. Defaults to OFF</dd>
<dt><strong>LLVM_USE_INTEL_JITEVENTS</strong>:BOOL</dt>
<dd>Enable building support for Intel JIT Events API. Defaults to OFF</dd>
<dt><strong>LLVM_ENABLE_ZLIB</strong>:BOOL</dt>
<dd>Build with zlib to support compression/uncompression in LLVM tools.
Defaults to ON.</dd>
<dt><strong>LLVM_USE_SANITIZER</strong>:STRING</dt>
<dd>Define the sanitizer used to build LLVM binaries and tests. Possible values
are <tt class="docutils literal"><span class="pre">Address</span></tt>, <tt class="docutils literal"><span class="pre">Memory</span></tt> and <tt class="docutils literal"><span class="pre">MemoryWithOrigins</span></tt>. Defaults to empty
string.</dd>
<dt><strong>LLVM_BUILD_DOCS</strong>:BOOL</dt>
<dd>Enables all enabled documentation targets (i.e. Doxgyen and Sphinx targets) to
be built as part of the normal build. If the <tt class="docutils literal"><span class="pre">install</span></tt> target is run then
this also enables all built documentation targets to be installed. Defaults to
OFF.</dd>
<dt><strong>LLVM_ENABLE_DOXYGEN</strong>:BOOL</dt>
<dd>Enables the generation of browsable HTML documentation using doxygen.
Defaults to OFF.</dd>
<dt><strong>LLVM_ENABLE_DOXYGEN_QT_HELP</strong>:BOOL</dt>
<dd>Enables the generation of a Qt Compressed Help file. Defaults to OFF.
This affects the make target <tt class="docutils literal"><span class="pre">doxygen-llvm</span></tt>. When enabled, apart from
the normal HTML output generated by doxygen, this will produce a QCH file
named <tt class="docutils literal"><span class="pre">org.llvm.qch</span></tt>. You can then load this file into Qt Creator.
This option is only useful in combination with <tt class="docutils literal"><span class="pre">-DLLVM_ENABLE_DOXYGEN=ON</span></tt>;
otherwise this has no effect.</dd>
<dt><strong>LLVM_DOXYGEN_QCH_FILENAME</strong>:STRING</dt>
<dd>The filename of the Qt Compressed Help file that will be genrated when
<tt class="docutils literal"><span class="pre">-DLLVM_ENABLE_DOXYGEN=ON</span></tt> and
<tt class="docutils literal"><span class="pre">-DLLVM_ENABLE_DOXYGEN_QT_HELP=ON</span></tt> are given. Defaults to
<tt class="docutils literal"><span class="pre">org.llvm.qch</span></tt>.
This option is only useful in combination with
<tt class="docutils literal"><span class="pre">-DLLVM_ENABLE_DOXYGEN_QT_HELP=ON</span></tt>;
otherwise this has no effect.</dd>
<dt><strong>LLVM_DOXYGEN_QHP_NAMESPACE</strong>:STRING</dt>
<dd>Namespace under which the intermediate Qt Help Project file lives. See <a class="reference external" href="http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-filters">Qt
Help Project</a>
for more information. Defaults to “org.llvm”. This option is only useful in
combination with <tt class="docutils literal"><span class="pre">-DLLVM_ENABLE_DOXYGEN_QT_HELP=ON</span></tt>; otherwise
this has no effect.</dd>
<dt><strong>LLVM_DOXYGEN_QHP_CUST_FILTER_NAME</strong>:STRING</dt>
<dd>See <a class="reference external" href="http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-filters">Qt Help Project</a> for
more information. Defaults to the CMake variable <tt class="docutils literal"><span class="pre">${PACKAGE_STRING}</span></tt> which
is a combination of the package name and version string. This filter can then
be used in Qt Creator to select only documentation from LLVM when browsing
through all the help files that you might have loaded. This option is only
useful in combination with <tt class="docutils literal"><span class="pre">-DLLVM_ENABLE_DOXYGEN_QT_HELP=ON</span></tt>;
otherwise this has no effect.</dd>
</dl>
<dl class="docutils">
<dt><strong>LLVM_DOXYGEN_QHELPGENERATOR_PATH</strong>:STRING</dt>
<dd>The path to the <tt class="docutils literal"><span class="pre">qhelpgenerator</span></tt> executable. Defaults to whatever CMake’s
<tt class="docutils literal"><span class="pre">find_program()</span></tt> can find. This option is only useful in combination with
<tt class="docutils literal"><span class="pre">-DLLVM_ENABLE_DOXYGEN_QT_HELP=ON</span></tt>; otherwise this has no
effect.</dd>
<dt><strong>LLVM_ENABLE_SPHINX</strong>:BOOL</dt>
<dd>If enabled CMake will search for the <tt class="docutils literal"><span class="pre">sphinx-build</span></tt> executable and will make
the <tt class="docutils literal"><span class="pre">SPHINX_OUTPUT_HTML</span></tt> and <tt class="docutils literal"><span class="pre">SPHINX_OUTPUT_MAN</span></tt> CMake options available.
Defaults to OFF.</dd>
<dt><strong>SPHINX_EXECUTABLE</strong>:STRING</dt>
<dd>The path to the <tt class="docutils literal"><span class="pre">sphinx-build</span></tt> executable detected by CMake.</dd>
<dt><strong>SPHINX_OUTPUT_HTML</strong>:BOOL</dt>
<dd>If enabled (and <tt class="docutils literal"><span class="pre">LLVM_ENABLE_SPHINX</span></tt> is enabled) then the targets for
building the documentation as html are added (but not built by default unless
<tt class="docutils literal"><span class="pre">LLVM_BUILD_DOCS</span></tt> is enabled). There is a target for each project in the
source tree that uses sphinx (e.g. <tt class="docutils literal"><span class="pre">docs-llvm-html</span></tt>, <tt class="docutils literal"><span class="pre">docs-clang-html</span></tt>
and <tt class="docutils literal"><span class="pre">docs-lld-html</span></tt>). Defaults to ON.</dd>
<dt><strong>SPHINX_OUTPUT_MAN</strong>:BOOL</dt>
<dd>If enabled (and <tt class="docutils literal"><span class="pre">LLVM_ENABLE_SPHINX</span></tt> is enabled) the targets for building
the man pages are added (but not built by default unless <tt class="docutils literal"><span class="pre">LLVM_BUILD_DOCS</span></tt>
is enabled). Currently the only target added is <tt class="docutils literal"><span class="pre">docs-llvm-man</span></tt>. Defaults
to ON.</dd>
</dl>
</div>
</div>
<div class="section" id="executing-the-test-suite">
<h2><a class="toc-backref" href="#id12">Executing the test suite</a><a class="headerlink" href="#executing-the-test-suite" title="Permalink to this headline">¶</a></h2>
<p>Testing is performed when the <em>check</em> target is built. For instance, if you are
using makefiles, execute this command while on the top level of your build
directory:</p>
<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> make check
</pre></div>
</div>
<p>On Visual Studio, you may run tests to build the project “check”.</p>
</div>
<div class="section" id="cross-compiling">
<h2><a class="toc-backref" href="#id13">Cross compiling</a><a class="headerlink" href="#cross-compiling" title="Permalink to this headline">¶</a></h2>
<p>See <a class="reference external" href="http://www.vtk.org/Wiki/CMake_Cross_Compiling">this wiki page</a> for
generic instructions on how to cross-compile with CMake. It goes into detailed
explanations and may seem daunting, but it is not. On the wiki page there are
several examples including toolchain files. Go directly to <a class="reference external" href="http://www.vtk.org/Wiki/CMake_Cross_Compiling#Information_how_to_set_up_various_cross_compiling_toolchains">this section</a>
for a quick solution.</p>
<p>Also see the <a class="reference internal" href="#llvm-specific-variables">LLVM-specific variables</a> section for variables used when
cross-compiling.</p>
</div>
<div class="section" id="embedding-llvm-in-your-project">
<span id="id5"></span><h2><a class="toc-backref" href="#id14">Embedding LLVM in your project</a><a class="headerlink" href="#embedding-llvm-in-your-project" title="Permalink to this headline">¶</a></h2>
<p>From LLVM 3.5 onwards both the CMake and autoconf/Makefile build systems export
LLVM libraries as importable CMake targets. This means that clients of LLVM can
now reliably use CMake to develop their own LLVM based projects against an
installed version of LLVM regardless of how it was built.</p>
<p>Here is a simple example of CMakeLists.txt file that imports the LLVM libraries
and uses them to build a simple application <tt class="docutils literal"><span class="pre">simple-tool</span></tt>.</p>
<div class="highlight-cmake"><div class="highlight"><pre><span class="nb">cmake_minimum_required</span><span class="p">(</span><span class="s">VERSION</span> <span class="s">2.8.8</span><span class="p">)</span>
<span class="nb">project</span><span class="p">(</span><span class="s">SimpleProject</span><span class="p">)</span>
<span class="nb">find_package</span><span class="p">(</span><span class="s">LLVM</span> <span class="s">REQUIRED</span> <span class="s">CONFIG</span><span class="p">)</span>
<span class="nb">message</span><span class="p">(</span><span class="s">STATUS</span> <span class="s2">"Found LLVM ${LLVM_PACKAGE_VERSION}"</span><span class="p">)</span>
<span class="nb">message</span><span class="p">(</span><span class="s">STATUS</span> <span class="s2">"Using LLVMConfig.cmake in: ${LLVM_DIR}"</span><span class="p">)</span>
<span class="c"># Set your project compile flags.</span>
<span class="c"># E.g. if using the C++ header files</span>
<span class="c"># you will need to enable C++11 support</span>
<span class="c"># for your compiler.</span>
<span class="nb">include_directories</span><span class="p">(</span><span class="o">${</span><span class="nv">LLVM_INCLUDE_DIRS</span><span class="o">}</span><span class="p">)</span>
<span class="nb">add_definitions</span><span class="p">(</span><span class="o">${</span><span class="nv">LLVM_DEFINITIONS</span><span class="o">}</span><span class="p">)</span>
<span class="c"># Now build our tools</span>
<span class="nb">add_excutable</span><span class="p">(</span><span class="s">simple-tool</span> <span class="s">tool.cpp</span><span class="p">)</span>
<span class="c"># Find the libraries that correspond to the LLVM components</span>
<span class="c"># that we wish to use</span>
<span class="nb">llvm_map_components_to_libnames</span><span class="p">(</span><span class="s">llvm_libs</span> <span class="s">support</span> <span class="s">core</span> <span class="s">irreader</span><span class="p">)</span>
<span class="c"># Link against LLVM libraries</span>
<span class="nb">target_link_libraries</span><span class="p">(</span><span class="s">simple-tool</span> <span class="o">${</span><span class="nv">llvm_libs</span><span class="o">}</span><span class="p">)</span>
</pre></div>
</div>
<p>The <tt class="docutils literal"><span class="pre">find_package(...)</span></tt> directive when used in CONFIG mode (as in the above
example) will look for the <tt class="docutils literal"><span class="pre">LLVMConfig.cmake</span></tt> file in various locations (see
cmake manual for details). It creates a <tt class="docutils literal"><span class="pre">LLVM_DIR</span></tt> cache entry to save the
directory where <tt class="docutils literal"><span class="pre">LLVMConfig.cmake</span></tt> is found or allows the user to specify the
directory (e.g. by passing <tt class="docutils literal"><span class="pre">-DLLVM_DIR=/usr/share/llvm/cmake</span></tt> to
the <tt class="docutils literal"><span class="pre">cmake</span></tt> command or by setting it directly in <tt class="docutils literal"><span class="pre">ccmake</span></tt> or <tt class="docutils literal"><span class="pre">cmake-gui</span></tt>).</p>
<p>This file is available in two different locations.</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre"><INSTALL_PREFIX>/share/llvm/cmake/LLVMConfig.cmake</span></tt> where
<tt class="docutils literal"><span class="pre"><INSTALL_PREFIX></span></tt> is the install prefix of an installed version of LLVM.
On Linux typically this is <tt class="docutils literal"><span class="pre">/usr/share/llvm/cmake/LLVMConfig.cmake</span></tt>.</li>
<li><tt class="docutils literal"><span class="pre"><LLVM_BUILD_ROOT>/share/llvm/cmake/LLVMConfig.cmake</span></tt> where
<tt class="docutils literal"><span class="pre"><LLVM_BUILD_ROOT></span></tt> is the root of the LLVM build tree. <strong>Note this only
available when building LLVM with CMake</strong></li>
</ul>
<p>If LLVM is installed in your operating system’s normal installation prefix (e.g.
on Linux this is usually <tt class="docutils literal"><span class="pre">/usr/</span></tt>) <tt class="docutils literal"><span class="pre">find_package(LLVM</span> <span class="pre">...)</span></tt> will
automatically find LLVM if it is installed correctly. If LLVM is not installed
or you wish to build directly against the LLVM build tree you can use
<tt class="docutils literal"><span class="pre">LLVM_DIR</span></tt> as previously mentioned.</p>
<p>The <tt class="docutils literal"><span class="pre">LLVMConfig.cmake</span></tt> file sets various useful variables. Notable variables
include</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">LLVM_CMAKE_DIR</span></tt></dt>
<dd>The path to the LLVM CMake directory (i.e. the directory containing
LLVMConfig.cmake).</dd>
<dt><tt class="docutils literal"><span class="pre">LLVM_DEFINITIONS</span></tt></dt>
<dd>A list of preprocessor defines that should be used when building against LLVM.</dd>
<dt><tt class="docutils literal"><span class="pre">LLVM_ENABLE_ASSERTIONS</span></tt></dt>
<dd>This is set to ON if LLVM was built with assertions, otherwise OFF.</dd>
<dt><tt class="docutils literal"><span class="pre">LLVM_ENABLE_EH</span></tt></dt>
<dd>This is set to ON if LLVM was built with exception handling (EH) enabled,
otherwise OFF.</dd>
<dt><tt class="docutils literal"><span class="pre">LLVM_ENABLE_RTTI</span></tt></dt>
<dd>This is set to ON if LLVM was built with run time type information (RTTI),
otherwise OFF.</dd>
<dt><tt class="docutils literal"><span class="pre">LLVM_INCLUDE_DIRS</span></tt></dt>
<dd>A list of include paths to directories containing LLVM header files.</dd>
<dt><tt class="docutils literal"><span class="pre">LLVM_PACKAGE_VERSION</span></tt></dt>
<dd>The LLVM version. This string can be used with CMake conditionals. E.g. <tt class="docutils literal"><span class="pre">if</span>
<span class="pre">(${LLVM_PACKAGE_VERSION}</span> <span class="pre">VERSION_LESS</span> <span class="pre">"3.5")</span></tt>.</dd>
<dt><tt class="docutils literal"><span class="pre">LLVM_TOOLS_BINARY_DIR</span></tt></dt>
<dd>The path to the directory containing the LLVM tools (e.g. <tt class="docutils literal"><span class="pre">llvm-as</span></tt>).</dd>
</dl>
<p>Notice that in the above example we link <tt class="docutils literal"><span class="pre">simple-tool</span></tt> against several LLVM
libraries. The list of libraries is determined by using the
<tt class="docutils literal"><span class="pre">llvm_map_components_to_libnames()</span></tt> CMake function. For a list of available
components look at the output of running <tt class="docutils literal"><span class="pre">llvm-config</span> <span class="pre">--components</span></tt>.</p>
<p>Note that for LLVM < 3.5 <tt class="docutils literal"><span class="pre">llvm_map_components_to_libraries()</span></tt> was
used instead of <tt class="docutils literal"><span class="pre">llvm_map_components_to_libnames()</span></tt>. This is now deprecated
and will be removed in a future version of LLVM.</p>
<div class="section" id="developing-llvm-passes-out-of-source">
<span id="cmake-out-of-source-pass"></span><h3><a class="toc-backref" href="#id15">Developing LLVM passes out of source</a><a class="headerlink" href="#developing-llvm-passes-out-of-source" title="Permalink to this headline">¶</a></h3>
<p>It is possible to develop LLVM passes out of LLVM’s source tree (i.e. against an
installed or built LLVM). An example of a project layout is provided below.</p>
<div class="highlight-none"><div class="highlight"><pre><project dir>/
|
CMakeLists.txt
<pass name>/
|
CMakeLists.txt
Pass.cpp
...
</pre></div>
</div>
<p>Contents of <tt class="docutils literal"><span class="pre"><project</span> <span class="pre">dir>/CMakeLists.txt</span></tt>:</p>
<div class="highlight-cmake"><div class="highlight"><pre><span class="nb">find_package</span><span class="p">(</span><span class="s">LLVM</span> <span class="s">REQUIRED</span> <span class="s">CONFIG</span><span class="p">)</span>
<span class="nb">add_definitions</span><span class="p">(</span><span class="o">${</span><span class="nv">LLVM_DEFINITIONS</span><span class="o">}</span><span class="p">)</span>
<span class="nb">include_directories</span><span class="p">(</span><span class="o">${</span><span class="nv">LLVM_INCLUDE_DIRS</span><span class="o">}</span><span class="p">)</span>
<span class="nb">add_subdirectory</span><span class="p">(</span><span class="s"><pass</span> <span class="s">name></span><span class="p">)</span>
</pre></div>
</div>
<p>Contents of <tt class="docutils literal"><span class="pre"><project</span> <span class="pre">dir>/<pass</span> <span class="pre">name>/CMakeLists.txt</span></tt>:</p>
<div class="highlight-cmake"><div class="highlight"><pre><span class="nb">add_library</span><span class="p">(</span><span class="s">LLVMPassname</span> <span class="s">MODULE</span> <span class="s">Pass.cpp</span><span class="p">)</span>
</pre></div>
</div>
<p>Note if you intend for this pass to be merged into the LLVM source tree at some
point in the future it might make more sense to use LLVM’s internal
add_llvm_loadable_module function instead by...</p>
<p>Adding the following to <tt class="docutils literal"><span class="pre"><project</span> <span class="pre">dir>/CMakeLists.txt</span></tt> (after
<tt class="docutils literal"><span class="pre">find_package(LLVM</span> <span class="pre">...)</span></tt>)</p>
<div class="highlight-cmake"><div class="highlight"><pre><span class="nb">list</span><span class="p">(</span><span class="s">APPEND</span> <span class="s">CMAKE_MODULE_PATH</span> <span class="s2">"${LLVM_CMAKE_DIR}"</span><span class="p">)</span>
<span class="nb">include</span><span class="p">(</span><span class="s">AddLLVM</span><span class="p">)</span>
</pre></div>
</div>
<p>And then changing <tt class="docutils literal"><span class="pre"><project</span> <span class="pre">dir>/<pass</span> <span class="pre">name>/CMakeLists.txt</span></tt> to</p>
<div class="highlight-cmake"><div class="highlight"><pre><span class="nb">add_llvm_loadable_module</span><span class="p">(</span><span class="s">LLVMPassname</span>
<span class="s">Pass.cpp</span>
<span class="p">)</span>
</pre></div>
</div>
<p>When you are done developing your pass, you may wish to integrate it
into LLVM source tree. You can achieve it in two easy steps:</p>
<ol class="arabic simple">
<li>Copying <tt class="docutils literal"><span class="pre"><pass</span> <span class="pre">name></span></tt> folder into <tt class="docutils literal"><span class="pre"><LLVM</span> <span class="pre">root>/lib/Transform</span></tt> directory.</li>
<li>Adding <tt class="docutils literal"><span class="pre">add_subdirectory(<pass</span> <span class="pre">name>)</span></tt> line into
<tt class="docutils literal"><span class="pre"><LLVM</span> <span class="pre">root>/lib/Transform/CMakeLists.txt</span></tt>.</li>
</ol>
</div>
</div>
<div class="section" id="compiler-platform-specific-topics">
<h2><a class="toc-backref" href="#id16">Compiler/Platform-specific topics</a><a class="headerlink" href="#compiler-platform-specific-topics" title="Permalink to this headline">¶</a></h2>
<p>Notes for specific compilers and/or platforms.</p>
<div class="section" id="microsoft-visual-c">
<h3><a class="toc-backref" href="#id17">Microsoft Visual C++</a><a class="headerlink" href="#microsoft-visual-c" title="Permalink to this headline">¶</a></h3>
<dl class="docutils">
<dt><strong>LLVM_COMPILER_JOBS</strong>:STRING</dt>
<dd>Specifies the maximum number of parallell compiler jobs to use per project
when building with msbuild or Visual Studio. Only supported for the Visual
Studio 2010 CMake generator. 0 means use all processors. Default is 0.</dd>
</dl>
</div>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="HowToBuildOnARM.html" title="How To Build On ARM"
>next</a> |</li>
<li class="right" >
<a href="LangRef.html" title="LLVM Language Reference Manual"
>previous</a> |</li>
<li><a href="http://llvm.org/">LLVM Home</a> | </li>
<li><a href="index.html">Documentation</a>»</li>
</ul>
</div>
<div class="footer">
© Copyright 2003-2014, LLVM Project.
Last updated on 2015-02-27.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3.
</div>
</body>
</html>
|