Oscar Fuentes | 25f1d03 | 2008-11-20 22:05:48 +0000 | [diff] [blame^] | 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> |
| 8 | |
| 9 | <div class="doc_title"> |
| 10 | Building LLVM with CMake |
| 11 | </div> |
| 12 | |
| 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 | </ul> |
| 26 | |
| 27 | <div class="doc_author"> |
| 28 | <p>Written by <a href="mailto:ofv@wanadoo.es">Óscar Fuentes</a></p> |
| 29 | </div> |
| 30 | |
| 31 | <!-- *********************************************************************** --> |
| 32 | <div class="doc_section"> |
| 33 | <a name="intro">Introduction</a> |
| 34 | </div> |
| 35 | <!-- *********************************************************************** --> |
| 36 | |
| 37 | <div class="doc_text"> |
| 38 | |
| 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 |
| 42 | building LLVM.</p> |
| 43 | |
| 44 | <p>If you are really anxious |
| 45 | </div> |
| 46 | |
| 47 | <!-- *********************************************************************** --> |
| 48 | <div class="doc_section"> |
| 49 | <a name="quickstart">Quick start</a> |
| 50 | </div> |
| 51 | <!-- *********************************************************************** --> |
| 52 | |
| 53 | <div class="doc_text"> |
| 54 | |
| 55 | <p> We use here the command-line, non-interactive CMake interface </p> |
| 56 | |
| 57 | <ol> |
| 58 | |
| 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> |
| 61 | |
| 62 | <li><p>Open a shell. Your development tools must be reachable from this |
| 63 | shell through the PATH environment variable.</p> |
| 64 | |
| 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 |
| 67 | directory:</p> |
| 68 | <div class="doc_code"> |
| 69 | <p><tt>mkdir mybuilddir</tt></p> |
| 70 | <p><tt>cd mybuilddir</tt></p> |
| 71 | </div> |
| 72 | |
| 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> |
| 78 | </div> |
| 79 | |
| 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> |
| 85 | |
| 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> |
| 95 | |
| 96 | </ol> |
| 97 | |
| 98 | </div> |
| 99 | |
| 100 | <!-- *********************************************************************** --> |
| 101 | <div class="doc_section"> |
| 102 | <a name="usage">Basic CMake usage</a> |
| 103 | </div> |
| 104 | <!-- *********************************************************************** --> |
| 105 | |
| 106 | <div class="doc_text"> |
| 107 | |
| 108 | <p>TODO</p> |
| 109 | |
| 110 | </div> |
| 111 | |
| 112 | <!-- *********************************************************************** --> |
| 113 | <div class="doc_section"> |
| 114 | <a name="options">Options and variables</a> |
| 115 | </div> |
| 116 | <!-- *********************************************************************** --> |
| 117 | |
| 118 | <div class="doc_text"> |
| 119 | |
| 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> |
| 123 | |
| 124 | <div class="doc_code"> |
| 125 | <p><tt>cmake -DVARIABLE=value path/to/llvm/source</tt></p> |
| 126 | </div> |
| 127 | |
| 128 | <p>You can set a variable after the initial CMake invocation for |
| 129 | changing its value. You can also undefine a variable:</p> |
| 130 | |
| 131 | <div class="doc_code"> |
| 132 | <p><tt>cmake -UVARIABLE path/to/llvm/source</tt></p> |
| 133 | </div> |
| 134 | |
| 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> |
| 138 | |
| 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 |
| 141 | line:</p> |
| 142 | |
| 143 | <div class="doc_code"> |
| 144 | <p><tt>cmake -DVARIABLE:TYPE=value path/to/llvm/source</tt></p> |
| 145 | </div> |
| 146 | |
| 147 | </div> |
| 148 | |
| 149 | <!-- ======================================================================= --> |
| 150 | <div class="doc_subsection"> |
| 151 | <a name="freccmake">Frequently-used CMake variables</a> |
| 152 | </div> |
| 153 | |
| 154 | <div class="doc_text"> |
| 155 | |
| 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>. |
| 160 | |
| 161 | <dl> |
| 162 | <dt><b>CMAKE_BUILD_TYPE</b>:STRING</dt> |
| 163 | |
| 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 |
| 167 | settings.</dd> |
| 168 | |
| 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> |
| 172 | |
| 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> |
| 177 | </dl> |
| 178 | |
| 179 | </div> |
| 180 | |
| 181 | <!-- ======================================================================= --> |
| 182 | <div class="doc_subsection"> |
| 183 | <a name="llvmvars">LLVM-specific variables</a> |
| 184 | </div> |
| 185 | |
| 186 | <div class="doc_text"> |
| 187 | |
| 188 | <dl> |
| 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> |
| 194 | |
| 195 | <dt><b>LLVM_ENABLE_THREADS</b>:BOOL</dt> |
| 196 | <dd>Build with threads support, if available. Defaults to ON.</dd> |
| 197 | |
| 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> |
| 202 | |
| 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 |
| 206 | OFF.</dd> |
| 207 | |
| 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> |
| 211 | |
| 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> |
| 216 | </dl> |
| 217 | |
| 218 | </div> |
| 219 | |
| 220 | <!-- *********************************************************************** --> |
| 221 | <div class="doc_section"> |
| 222 | <a name="testing">Executing the test suite</a> |
| 223 | </div> |
| 224 | <!-- *********************************************************************** --> |
| 225 | |
| 226 | <div class="doc_text"> |
| 227 | |
| 228 | <p>TODO</p> |
| 229 | |
| 230 | </div> |
| 231 | |
| 232 | <!-- *********************************************************************** --> |
| 233 | <div class="doc_section"> |
| 234 | <a name="cross">Cross compiling</a> |
| 235 | </div> |
| 236 | <!-- *********************************************************************** --> |
| 237 | |
| 238 | <div class="doc_text"> |
| 239 | |
| 240 | <p>TODO</p> |
| 241 | |
| 242 | </div> |
| 243 | |
| 244 | <!-- *********************************************************************** --> |
| 245 | <div class="doc_section"> |
| 246 | <a name="embedding">Embedding LLVM in your project</a> |
| 247 | </div> |
| 248 | <!-- *********************************************************************** --> |
| 249 | |
| 250 | <div class="doc_text"> |
| 251 | |
| 252 | <p>TODO</p> |
| 253 | |
| 254 | </div> |
| 255 | |
| 256 | <!-- *********************************************************************** --> |
| 257 | |
| 258 | <hr> |
| 259 | <address> |
| 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> |
| 264 | |
| 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) $ |
| 268 | </address> |
| 269 | |
| 270 | </body> |
| 271 | </html> |