@@ -54,7 +54,7 @@ program. The example uses only CMake language-defined functions.
54
54
55
55
.. code-block :: cmake
56
56
57
- cmake_minimum_required(VERSION 3.2 )
57
+ cmake_minimum_required(VERSION 3.15 )
58
58
project(HelloWorld)
59
59
add_executable(HelloWorld HelloWorld.cpp)
60
60
@@ -64,13 +64,13 @@ block to define "APPLE" when targeting Apple platforms:
64
64
65
65
.. code-block :: cmake
66
66
67
- cmake_minimum_required(VERSION 3.2 )
67
+ cmake_minimum_required(VERSION 3.15 )
68
68
project(HelloWorld)
69
69
add_executable(HelloWorld HelloWorld.cpp)
70
70
if(APPLE)
71
71
target_compile_definitions(HelloWorld PUBLIC APPLE)
72
72
endif()
73
-
73
+
74
74
Variables, Types, and Scope
75
75
===========================
76
76
@@ -93,7 +93,7 @@ example:
93
93
set(var_name var1)
94
94
set(${var_name} foo) # same as "set(var1 foo)"
95
95
set(${${var_name}}_var bar) # same as "set(foo_var bar)"
96
-
96
+
97
97
Dereferencing an unset variable results in an empty expansion. It is a common
98
98
pattern in CMake to conditionally set variables knowing that it will be used in
99
99
code paths that the variable isn't set. There are examples of this throughout
@@ -107,7 +107,7 @@ An example of variable empty expansion is:
107
107
set(extra_sources Apple.cpp)
108
108
endif()
109
109
add_executable(HelloWorld HelloWorld.cpp ${extra_sources})
110
-
110
+
111
111
In this example the ``extra_sources `` variable is only defined if you're
112
112
targeting an Apple platform. For all other targets the ``extra_sources `` will be
113
113
evaluated as empty before add_executable is given its arguments.
@@ -124,7 +124,7 @@ defining lists:
124
124
# Creates a list with members a, b, c, and d
125
125
set(my_list a b c d)
126
126
set(my_list "a;b;c;d")
127
-
127
+
128
128
# Creates a string "a b c d"
129
129
set(my_string "a b c d")
130
130
@@ -141,7 +141,7 @@ make a list of variable names that refer to other lists. For example:
141
141
set(a 1 2 3)
142
142
set(b 4 5 6)
143
143
set(c 7 8 9)
144
-
144
+
145
145
With this layout you can iterate through the list of lists printing each value
146
146
with the following code:
147
147
@@ -152,7 +152,7 @@ with the following code:
152
152
message(${value})
153
153
endforeach()
154
154
endforeach()
155
-
155
+
156
156
You'll notice that the inner foreach loop's list is doubly dereferenced. This is
157
157
because the first dereference turns ``list_name `` into the name of the sub-list
158
158
(a, b, or c in the example), then the second dereference is to get the value of
@@ -385,7 +385,7 @@ result in some unexpected behavior if using unreferenced variables. For example:
385
385
message("${var}")
386
386
endforeach()
387
387
endmacro()
388
-
388
+
389
389
set(my_list a b c d)
390
390
set(my_list_of_numbers 1 2 3 4)
391
391
print_list(my_list_of_numbers)
0 commit comments