@@ -19,15 +19,15 @@ The LLVM project and many of the core projects built on LLVM build using CMake.
1919This document aims to provide a brief overview of CMake for developers modifying
2020LLVM projects or building their own projects on top of LLVM.
2121
22- The official CMake language references is available in the cmake-language
22+ The official CMake language reference is available in the cmake-language
2323manpage and `cmake-language online documentation
2424<https://cmake.org/cmake/help/v3.4/manual/cmake-language.7.html> `_.
2525
262610,000 ft View
2727==============
2828
2929CMake is a tool that reads script files in its own language that describe how a
30- software project builds. As CMake evaluates the scripts it constructs an
30+ software project builds. As CMake evaluates the scripts, it constructs an
3131internal representation of the software project. Once the scripts have been
3232fully processed, if there are no errors, CMake will generate build files to
3333actually build the project. CMake supports generating build files for a variety
@@ -58,8 +58,8 @@ program. The example uses only CMake language-defined functions.
5858 project(HelloWorld)
5959 add_executable(HelloWorld HelloWorld.cpp)
6060
61- The CMake language provides control flow constructs in the form of foreach loops
62- and if blocks. To make the example above more complicated you could add an if
61+ The CMake language provides control flow constructs in the form of `` foreach `` loops
62+ and `` if `` blocks. To make the example above more complicated you could add an if
6363block to define "APPLE" when targeting Apple platforms:
6464
6565.. code-block :: cmake
@@ -77,7 +77,7 @@ Variables, Types, and Scope
7777Dereferencing
7878-------------
7979
80- In CMake variables are "stringly" typed. All variables are represented as
80+ In CMake, variables are "stringly" typed. All variables are represented as
8181strings throughout evaluation. Wrapping a variable in ``${} `` dereferences it
8282and results in a literal substitution of the name for the value. CMake refers to
8383this as "variable evaluation" in their documentation. Dereferences are performed
@@ -115,8 +115,8 @@ evaluated as empty before add_executable is given its arguments.
115115Lists
116116-----
117117
118- In CMake lists are semi-colon delimited strings, and it is strongly advised that
119- you avoid using semi-colons in lists; it doesn't go smoothly. A few examples of
118+ In CMake, lists are semicolon- delimited strings, and it is strongly advised that
119+ you avoid using semicolons in lists; it doesn't go smoothly. A few examples of
120120defining lists:
121121
122122.. code-block :: cmake
@@ -132,7 +132,7 @@ Lists of Lists
132132--------------
133133
134134One of the more complicated patterns in CMake is lists of lists. Because a list
135- cannot contain an element with a semi-colon to construct a list of lists you
135+ cannot contain an element with a semicolon to construct a list of lists you
136136make a list of variable names that refer to other lists. For example:
137137
138138.. code-block :: cmake
@@ -160,15 +160,15 @@ the list.
160160
161161This pattern is used throughout CMake, the most common example is the compiler
162162flags options, which CMake refers to using the following variable expansions:
163- CMAKE_${LANGUAGE}_FLAGS and CMAKE_${LANGUAGE}_FLAGS_${CMAKE_BUILD_TYPE}.
163+ `` CMAKE_${LANGUAGE}_FLAGS `` and `` CMAKE_${LANGUAGE}_FLAGS_${CMAKE_BUILD_TYPE} `` .
164164
165165Other Types
166166-----------
167167
168168Variables that are cached or specified on the command line can have types
169169associated with them. The variable's type is used by CMake's UI tool to display
170- the right input field. A variable's type generally doesn't impact evaluation,
171- however CMake does have special handling for some variables such as PATH.
170+ the right input field. A variable's type generally doesn't impact evaluation;
171+ however, CMake does have special handling for some variables such as `` PATH `` .
172172You can read more about the special handling in `CMake's set documentation
173173<https://cmake.org/cmake/help/v3.5/command/set.html#set-cache-entry> `_.
174174
@@ -183,11 +183,11 @@ set in the scope they are included from, and all subdirectories.
183183When a variable that is already set is set again in a subdirectory it overrides
184184the value in that scope and any deeper subdirectories.
185185
186- The CMake set command provides two scope-related options. PARENT_SCOPE sets a
187- variable into the parent scope, and not the current scope. The CACHE option sets
186+ The CMake set command provides two scope-related options. `` PARENT_SCOPE `` sets a
187+ variable into the parent scope, and not the current scope. The `` CACHE `` option sets
188188the variable in the CMakeCache, which results in it being set in all scopes. The
189- CACHE option will not set a variable that already exists in the CACHE unless the
190- FORCE option is specified.
189+ `` CACHE `` option will not set a variable that already exists in the `` CACHE `` unless the
190+ `` FORCE `` option is specified.
191191
192192In addition to directory-based scope, CMake functions also have their own scope.
193193This means variables set inside functions do not bleed into the parent scope.
@@ -213,7 +213,7 @@ If, ElseIf, Else
213213 `here <https://cmake.org/cmake/help/v3.4/command/if.html >`_. That resource is
214214 far more complete.
215215
216- In general CMake if blocks work the way you'd expect:
216+ In general, CMake `` if `` blocks work the way you'd expect:
217217
218218.. code-block :: cmake
219219
@@ -225,7 +225,7 @@ In general CMake if blocks work the way you'd expect:
225225 message("do other other stuff")
226226 endif()
227227
228- The single most important thing to know about CMake's if blocks coming from a C
228+ The single most important thing to know about CMake's `` if `` blocks coming from a C
229229background is that they do not have their own scope. Variables set inside
230230conditional blocks persist after the ``endif() ``.
231231
@@ -317,20 +317,20 @@ Modules are CMake's vehicle for enabling code reuse. CMake modules are just
317317CMake script files. They can contain code to execute on include as well as
318318definitions for commands.
319319
320- In CMake macros and functions are universally referred to as commands, and they
320+ In CMake, macros and functions are universally referred to as commands, and they
321321are the primary method of defining code that can be called multiple times.
322322
323323In LLVM we have several CMake modules that are included as part of our
324324distribution for developers who don't build our project from source. Those
325325modules are the fundamental pieces needed to build LLVM-based projects with
326326CMake. We also rely on modules as a way of organizing the build system's
327- functionality for maintainability and re-use within LLVM projects.
327+ functionality for maintainability and reuse within LLVM projects.
328328
329329Argument Handling
330330-----------------
331331
332332When defining a CMake command handling arguments is very useful. The examples
333- in this section will all use the CMake ``function `` block, but this all applies
333+ in this section will all use the CMake ``function `` block, but this also applies
334334to the ``macro `` block as well.
335335
336336CMake commands can have named arguments that are required at every call site. In
@@ -395,7 +395,7 @@ result in some unexpected behavior if using unreferenced variables. For example:
395395 # c
396396 # d
397397
398- Generally speaking this issue is uncommon because it requires using
398+ Generally speaking, this issue is uncommon because it requires using
399399non-dereferenced variables with names that overlap in the parent scope, but it
400400is important to be aware of because it can lead to subtle bugs.
401401
@@ -424,7 +424,7 @@ LLVM.
424424Useful Built-in Commands
425425========================
426426
427- CMake has a bunch of useful built-in commands. This document isn't going to
427+ CMake has a collection of useful built-in commands. This document isn't going to
428428go into details about them because The CMake project has excellent
429429documentation. To highlight a few useful functions see:
430430
0 commit comments