forked from WShiBin/CMakeTutorial
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcmake_help_variables.txt
More file actions
7483 lines (5291 loc) · 244 KB
/
cmake_help_variables.txt
File metadata and controls
7483 lines (5291 loc) · 244 KB
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
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
cmake-variables(7)
******************
This page documents variables that are provided by CMake
or have meaning to CMake when set by project code.
For general information on variables, see the
:ref:`Variables <CMake Language Variables>`
section in the cmake-language manual.
.. note::
CMake reserves identifiers that:
* begin with ``CMAKE_`` (upper-, lower-, or mixed-case), or
* begin with ``_CMAKE_`` (upper-, lower-, or mixed-case), or
* begin with ``_`` followed by the name of any ``CMake Command``.
Variables that Provide Information
==================================
CMAKE_AR
--------
Name of archiving tool for static libraries.
This specifies the name of the program that creates archive or static
libraries.
CMAKE_ARGC
----------
Number of command line arguments passed to CMake in script mode.
When run in :ref:`-P <Script Processing Mode>` script mode, CMake sets this
variable to the number of command line arguments. See also
``CMAKE_ARGV0``, ``1``, ``2`` ...
CMAKE_ARGV0
-----------
Command line argument passed to CMake in script mode.
When run in :ref:`-P <Script Processing Mode>` script mode, CMake sets this
variable to the first command line argument. It then also sets ``CMAKE_ARGV1``,
``CMAKE_ARGV2``, ... and so on, up to the number of command line arguments
given. See also ``CMAKE_ARGC``.
CMAKE_BINARY_DIR
----------------
The path to the top level of the build tree.
This is the full path to the top level of the current CMake build
tree. For an in-source build, this would be the same as
``CMAKE_SOURCE_DIR``.
When run in -P script mode, CMake sets the variables
``CMAKE_BINARY_DIR``, ``CMAKE_SOURCE_DIR``,
``CMAKE_CURRENT_BINARY_DIR`` and
``CMAKE_CURRENT_SOURCE_DIR`` to the current working directory.
CMAKE_BUILD_TOOL
----------------
This variable exists only for backwards compatibility.
It contains the same value as ``CMAKE_MAKE_PROGRAM``.
Use that variable instead.
CMAKE_CACHE_MAJOR_VERSION
-------------------------
Major version of CMake used to create the ``CMakeCache.txt`` file
This stores the major version of CMake used to write a CMake cache
file. It is only different when a different version of CMake is run
on a previously created cache file.
CMAKE_CACHE_MINOR_VERSION
-------------------------
Minor version of CMake used to create the ``CMakeCache.txt`` file
This stores the minor version of CMake used to write a CMake cache
file. It is only different when a different version of CMake is run
on a previously created cache file.
CMAKE_CACHE_PATCH_VERSION
-------------------------
Patch version of CMake used to create the ``CMakeCache.txt`` file
This stores the patch version of CMake used to write a CMake cache
file. It is only different when a different version of CMake is run
on a previously created cache file.
CMAKE_CACHEFILE_DIR
-------------------
The directory with the ``CMakeCache.txt`` file.
This is the full path to the directory that has the ``CMakeCache.txt``
file in it. This is the same as ``CMAKE_BINARY_DIR``.
CMAKE_CFG_INTDIR
----------------
Build-time reference to per-configuration output subdirectory.
For native build systems supporting multiple configurations in the
build tree (such as :ref:`Visual Studio Generators` and ``Xcode``),
the value is a reference to a build-time variable specifying the name
of the per-configuration output subdirectory. On :ref:`Makefile Generators`
this evaluates to `.` because there is only one configuration in a build tree.
Example values:
::
$(ConfigurationName) = Visual Studio 9
$(Configuration) = Visual Studio 10
$(CONFIGURATION) = Xcode
. = Make-based tools
. = Ninja
${CONFIGURATION} = Ninja Multi-Config
Note that this variable only has limited support on
``Ninja Multi-Config``. It is recommended that you use the
``$<CONFIG>`` ``generator expression``
instead.
Since these values are evaluated by the native build system, this
variable is suitable only for use in command lines that will be
evaluated at build time. Example of intended usage:
::
add_executable(mytool mytool.c)
add_custom_command(
OUTPUT out.txt
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/mytool
${CMAKE_CURRENT_SOURCE_DIR}/in.txt out.txt
DEPENDS mytool in.txt
)
add_custom_target(drive ALL DEPENDS out.txt)
Note that ``CMAKE_CFG_INTDIR`` is no longer necessary for this purpose but
has been left for compatibility with existing projects. Instead
``add_custom_command()`` recognizes executable target names in its
``COMMAND`` option, so
``${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/mytool`` can be replaced
by just ``mytool``.
This variable is read-only. Setting it is undefined behavior. In
multi-configuration build systems the value of this variable is passed
as the value of preprocessor symbol ``CMAKE_INTDIR`` to the compilation
of all source files.
CMAKE_COMMAND
-------------
The full path to the ``cmake(1)`` executable.
This is the full path to the CMake executable ``cmake(1)`` which is
useful from custom commands that want to use the ``cmake -E`` option for
portable system commands. (e.g. ``/usr/local/bin/cmake``)
CMAKE_CPACK_COMMAND
-------------------
Full path to ``cpack(1)`` command installed with CMake.
This is the full path to the CPack executable ``cpack(1)`` which is
useful from custom commands that want to use the ``cmake(1)`` ``-E``
option for portable system commands.
CMAKE_CROSSCOMPILING
--------------------
Intended to indicate whether CMake is cross compiling, but note limitations
discussed below.
This variable will be set to true by CMake if the ``CMAKE_SYSTEM_NAME``
variable has been set manually (i.e. in a toolchain file or as a cache entry
from the ``cmake`` command line). In most cases, manually
setting ``CMAKE_SYSTEM_NAME`` will only be done when cross compiling,
since it will otherwise be given the same value as
``CMAKE_HOST_SYSTEM_NAME`` if not manually set, which is correct for
the non-cross-compiling case. In the event that ``CMAKE_SYSTEM_NAME``
is manually set to the same value as ``CMAKE_HOST_SYSTEM_NAME``, then
``CMAKE_CROSSCOMPILING`` will still be set to true.
Another case to be aware of is that builds targeting Apple platforms other than
macOS are handled differently to other cross compiling scenarios. Rather than
relying on ``CMAKE_SYSTEM_NAME`` to select the target platform, Apple
device builds use ``CMAKE_OSX_SYSROOT`` to select the appropriate SDK,
which indirectly determines the target platform. Furthermore, when using the
``Xcode`` generator, developers can switch between device and
simulator builds at build time rather than having a single
choice at configure time, so the concept
of whether the build is cross compiling or not is more complex. Therefore, the
use of ``CMAKE_CROSSCOMPILING`` is not recommended for projects targeting Apple
devices.
CMAKE_CROSSCOMPILING_EMULATOR
-----------------------------
This variable is only used when ``CMAKE_CROSSCOMPILING`` is on. It
should point to a command on the host system that can run executable built
for the target system.
If this variable contains a :ref:`semicolon-separated list <CMake Language
Lists>`, then the first value is the command and remaining values are its
arguments.
The command will be used to run ``try_run()`` generated executables,
which avoids manual population of the ``TryRunResults.cmake`` file.
It is also used as the default value for the
``CROSSCOMPILING_EMULATOR`` target property of executables.
CMAKE_CTEST_COMMAND
-------------------
Full path to ``ctest(1)`` command installed with CMake.
This is the full path to the CTest executable ``ctest(1)`` which is
useful from custom commands that want to use the ``cmake(1)`` ``-E``
option for portable system commands.
CMAKE_CURRENT_BINARY_DIR
------------------------
The path to the binary directory currently being processed.
This the full path to the build directory that is currently being
processed by cmake. Each directory added by ``add_subdirectory()`` will
create a binary directory in the build tree, and as it is being
processed this variable will be set. For in-source builds this is the
current source directory being processed.
When run in -P script mode, CMake sets the variables
``CMAKE_BINARY_DIR``, ``CMAKE_SOURCE_DIR``,
``CMAKE_CURRENT_BINARY_DIR`` and
``CMAKE_CURRENT_SOURCE_DIR`` to the current working directory.
CMAKE_CURRENT_FUNCTION
----------------------
When executing code inside a ``function()``, this variable
contains the name of the current function. It can be useful for
diagnostic or debug messages.
See also ``CMAKE_CURRENT_FUNCTION_LIST_DIR``,
``CMAKE_CURRENT_FUNCTION_LIST_FILE`` and
``CMAKE_CURRENT_FUNCTION_LIST_LINE``.
CMAKE_CURRENT_FUNCTION_LIST_DIR
-------------------------------
When executing code inside a ``function()``, this variable
contains the full directory of the listfile that defined the current function.
It is quite common practice in CMake for modules to use some additional files,
such as templates to be copied in after substituting CMake variables.
In such cases, a function needs to know where to locate those files in a way
that doesn't depend on where the function is called. Without
``CMAKE_CURRENT_FUNCTION_LIST_DIR``, the code to do that would typically use
the following pattern:
set(_THIS_MODULE_BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
function(foo)
configure_file(
"${_THIS_MODULE_BASE_DIR}/some.template.in"
some.output
)
endfunction()
Using ``CMAKE_CURRENT_FUNCTION_LIST_DIR`` inside the function instead
eliminates the need for the extra variable which would otherwise be visible
outside the function's scope.
The above example can be written in the more concise and more robust form:
function(foo)
configure_file(
"${CMAKE_CURRENT_FUNCTION_LIST_DIR}/some.template.in"
some.output
)
endfunction()
See also ``CMAKE_CURRENT_FUNCTION``,
``CMAKE_CURRENT_FUNCTION_LIST_FILE`` and
``CMAKE_CURRENT_FUNCTION_LIST_LINE``.
CMAKE_CURRENT_FUNCTION_LIST_FILE
--------------------------------
When executing code inside a ``function()``, this variable
contains the full path to the listfile that defined the current function.
See also ``CMAKE_CURRENT_FUNCTION``,
``CMAKE_CURRENT_FUNCTION_LIST_DIR`` and
``CMAKE_CURRENT_FUNCTION_LIST_LINE``.
CMAKE_CURRENT_FUNCTION_LIST_LINE
--------------------------------
When executing code inside a ``function()``, this variable
contains the line number in the listfile where the current function
was defined.
See also ``CMAKE_CURRENT_FUNCTION``,
``CMAKE_CURRENT_FUNCTION_LIST_DIR`` and
``CMAKE_CURRENT_FUNCTION_LIST_FILE``.
CMAKE_CURRENT_LIST_DIR
----------------------
Full directory of the listfile currently being processed.
As CMake processes the listfiles in your project this variable will
always be set to the directory where the listfile which is currently
being processed (``CMAKE_CURRENT_LIST_FILE``) is located. The value
has dynamic scope. When CMake starts processing commands in a source file
it sets this variable to the directory where this file is located.
When CMake finishes processing commands from the file it restores the
previous value. Therefore the value of the variable inside a macro or
function is the directory of the file invoking the bottom-most entry
on the call stack, not the directory of the file containing the macro
or function definition.
See also ``CMAKE_CURRENT_LIST_FILE``.
CMAKE_CURRENT_LIST_FILE
-----------------------
Full path to the listfile currently being processed.
As CMake processes the listfiles in your project this variable will
always be set to the one currently being processed. The value has
dynamic scope. When CMake starts processing commands in a source file
it sets this variable to the location of the file. When CMake
finishes processing commands from the file it restores the previous
value. Therefore the value of the variable inside a macro or function
is the file invoking the bottom-most entry on the call stack, not the
file containing the macro or function definition.
See also ``CMAKE_PARENT_LIST_FILE``.
CMAKE_CURRENT_LIST_LINE
-----------------------
The line number of the current file being processed.
This is the line number of the file currently being processed by
cmake.
If CMake is currently processing deferred calls scheduled by
the ``cmake_language(DEFER)`` command, this variable
evaluates to ``DEFERRED`` instead of a specific line number.
CMAKE_CURRENT_SOURCE_DIR
------------------------
The path to the source directory currently being processed.
This the full path to the source directory that is currently being
processed by cmake.
When run in -P script mode, CMake sets the variables
``CMAKE_BINARY_DIR``, ``CMAKE_SOURCE_DIR``,
``CMAKE_CURRENT_BINARY_DIR`` and
``CMAKE_CURRENT_SOURCE_DIR`` to the current working directory.
CMAKE_DEBUG_TARGET_PROPERTIES
-----------------------------
Enables tracing output for target properties.
This variable can be populated with a list of properties to generate
debug output for when evaluating target properties. Currently it can
only be used when evaluating:
* ``AUTOUIC_OPTIONS``
* ``COMPILE_DEFINITIONS``
* ``COMPILE_FEATURES``
* ``COMPILE_OPTIONS``
* ``INCLUDE_DIRECTORIES``
* ``LINK_DIRECTORIES``
* ``LINK_OPTIONS``
* ``POSITION_INDEPENDENT_CODE``
* ``SOURCES``
target properties and any other property listed in
``COMPATIBLE_INTERFACE_STRING`` and other
``COMPATIBLE_INTERFACE_`` properties. It outputs an origin for each entry
in the target property. Default is unset.
CMAKE_DIRECTORY_LABELS
-----------------------
Specify labels for the current directory.
This is used to initialize the ``LABELS`` directory property.
CMAKE_DL_LIBS
-------------
Name of library containing ``dlopen`` and ``dlclose``.
The name of the library that has ``dlopen`` and ``dlclose`` in it, usually
``-ldl`` on most UNIX machines.
CMAKE_DOTNET_TARGET_FRAMEWORK
-----------------------------
Default value for ``DOTNET_TARGET_FRAMEWORK`` property of
targets.
This variable is used to initialize the
``DOTNET_TARGET_FRAMEWORK`` property on all targets. See that
target property for additional information.
Setting ``CMAKE_DOTNET_TARGET_FRAMEWORK`` may be necessary
when working with ``C#`` and newer .NET framework versions to
avoid referencing errors with the ``ALL_BUILD`` CMake target.
This variable is only evaluated for :ref:`Visual Studio Generators`
VS 2010 and above.
CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION
-------------------------------------
Default value for ``DOTNET_TARGET_FRAMEWORK_VERSION``
property of targets.
This variable is used to initialize the
``DOTNET_TARGET_FRAMEWORK_VERSION`` property on all
targets. See that target property for additional information. When set,
``CMAKE_DOTNET_TARGET_FRAMEWORK`` takes precednece over this
variable. See that variable or the associated target property
``DOTNET_TARGET_FRAMEWORK`` for additional information.
Setting ``CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION`` may be necessary
when working with ``C#`` and newer .NET framework versions to
avoid referencing errors with the ``ALL_BUILD`` CMake target.
This variable is only evaluated for :ref:`Visual Studio Generators`
VS 2010 and above.
CMAKE_EDIT_COMMAND
------------------
Full path to ``cmake-gui(1)`` or ``ccmake(1)``. Defined only for
:ref:`Makefile Generators` when not using an "extra" generator for an IDE.
This is the full path to the CMake executable that can graphically
edit the cache. For example, ``cmake-gui(1)`` or ``ccmake(1)``.
CMAKE_EXECUTABLE_SUFFIX
-----------------------
The suffix for executables on this platform.
The suffix to use for the end of an executable filename if any, ``.exe``
on Windows.
``CMAKE_EXECUTABLE_SUFFIX_<LANG>`` overrides this for language ``<LANG>``.
CMAKE_EXTRA_GENERATOR
---------------------
The extra generator used to build the project. See
``cmake-generators(7)``.
When using the Eclipse, CodeBlocks, CodeLite, Kate or Sublime generators, CMake
generates Makefiles (``CMAKE_GENERATOR``) and additionally project
files for the respective IDE. This IDE project file generator is stored in
``CMAKE_EXTRA_GENERATOR`` (e.g. ``Eclipse CDT4``).
CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES
-----------------------------------
Additional suffixes for shared libraries.
Extensions for shared libraries other than that specified by
``CMAKE_SHARED_LIBRARY_SUFFIX``, if any. CMake uses this to recognize
external shared library files during analysis of libraries linked by a
target.
CMAKE_FIND_DEBUG_MODE
---------------------
Print extra find call information for the following commands to standard
error:
* ``find_program()``
* ``find_library()``
* ``find_file()``
* ``find_path()``
* ``find_package()``
Output is designed for human consumption and not for parsing.
Enabling this variable is equivalent to using ``cmake`` ``--debug-find``
with the added ability to enable debugging for a subset of find calls.
set(CMAKE_FIND_DEBUG_MODE TRUE)
find_program(...)
set(CMAKE_FIND_DEBUG_MODE FALSE)
Default is unset.
CMAKE_FIND_PACKAGE_NAME
-----------------------
Defined by the ``find_package()`` command while loading
a find module to record the caller-specified package name.
See command documentation for details.
CMAKE_FIND_PACKAGE_SORT_DIRECTION
---------------------------------
The sorting direction used by ``CMAKE_FIND_PACKAGE_SORT_ORDER``.
It can assume one of the following values:
``DEC``
Default. Ordering is done in descending mode.
The highest folder found will be tested first.
``ASC``
Ordering is done in ascending mode.
The lowest folder found will be tested first.
If ``CMAKE_FIND_PACKAGE_SORT_ORDER`` is not set or is set to ``NONE``
this variable has no effect.
CMAKE_FIND_PACKAGE_SORT_ORDER
-----------------------------
The default order for sorting packages found using ``find_package()``.
It can assume one of the following values:
``NONE``
Default. No attempt is done to sort packages.
The first valid package found will be selected.
``NAME``
Sort packages lexicographically before selecting one.
``NATURAL``
Sort packages using natural order (see ``strverscmp(3)`` manual),
i.e. such that contiguous digits are compared as whole numbers.
Natural sorting can be employed to return the highest version when multiple
versions of the same library are found by ``find_package()``. For
example suppose that the following libraries have been found:
* libX-1.1.0
* libX-1.2.9
* libX-1.2.10
By setting ``NATURAL`` order we can select the one with the highest
version number ``libX-1.2.10``.
set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
find_package(libX CONFIG)
The sort direction can be controlled using the
``CMAKE_FIND_PACKAGE_SORT_DIRECTION`` variable
(by default decrescent, e.g. lib-B will be tested before lib-A).
CMAKE_GENERATOR
---------------
The generator used to build the project. See ``cmake-generators(7)``.
The name of the generator that is being used to generate the build
files. (e.g. ``Unix Makefiles``, ``Ninja``, etc.)
The value of this variable should never be modified by project code.
A generator may be selected via the ``cmake(1)`` ``-G`` option,
interactively in ``cmake-gui(1)``, or via the ``CMAKE_GENERATOR``
environment variable.
CMAKE_GENERATOR_INSTANCE
------------------------
Generator-specific instance specification provided by user.
Some CMake generators support selection of an instance of the native build
system when multiple instances are available. If the user specifies an
instance (e.g. by setting this cache entry or via the
``CMAKE_GENERATOR_INSTANCE`` environment variable), or after a default
instance is chosen when a build tree is first configured, the value will be
available in this variable.
The value of this variable should never be modified by project code.
A toolchain file specified by the ``CMAKE_TOOLCHAIN_FILE``
variable may initialize ``CMAKE_GENERATOR_INSTANCE`` as a cache entry.
Once a given build tree has been initialized with a particular value
for this variable, changing the value has undefined behavior.
Instance specification is supported only on specific generators:
* For the ``Visual Studio 15 2017`` generator (and above)
this specifies the absolute path to the VS installation directory
of the selected VS instance.
See native build system documentation for allowed instance values.
CMAKE_GENERATOR_PLATFORM
------------------------
Generator-specific target platform specification provided by user.
Some CMake generators support a target platform name to be given
to the native build system to choose a compiler toolchain.
If the user specifies a platform name (e.g. via the ``cmake(1)`` ``-A``
option or via the ``CMAKE_GENERATOR_PLATFORM`` environment variable)
the value will be available in this variable.
The value of this variable should never be modified by project code.
A toolchain file specified by the ``CMAKE_TOOLCHAIN_FILE``
variable may initialize ``CMAKE_GENERATOR_PLATFORM``. Once a given
build tree has been initialized with a particular value for this
variable, changing the value has undefined behavior.
Platform specification is supported only on specific generators:
* For :ref:`Visual Studio Generators` with VS 2005 and above this
specifies the target architecture.
* For ``Green Hills MULTI`` this specifies the target architecture.
See native build system documentation for allowed platform names.
Visual Studio Platform Selection
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
On :ref:`Visual Studio Generators` the selected platform name
is provided in the ``CMAKE_VS_PLATFORM_NAME`` variable.
CMAKE_GENERATOR_TOOLSET
-----------------------
Native build system toolset specification provided by user.
Some CMake generators support a toolset specification to tell the
native build system how to choose a compiler. If the user specifies
a toolset (e.g. via the ``cmake(1)`` ``-T`` option or via
the ``CMAKE_GENERATOR_TOOLSET`` environment variable) the value
will be available in this variable.
The value of this variable should never be modified by project code.
A toolchain file specified by the ``CMAKE_TOOLCHAIN_FILE``
variable may initialize ``CMAKE_GENERATOR_TOOLSET``. Once a given
build tree has been initialized with a particular value for this
variable, changing the value has undefined behavior.
Toolset specification is supported only on specific generators:
* :ref:`Visual Studio Generators` for VS 2010 and above
* The ``Xcode`` generator for Xcode 3.0 and above
* The ``Green Hills MULTI`` generator
See native build system documentation for allowed toolset names.
Visual Studio Toolset Selection
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The :ref:`Visual Studio Generators` support toolset specification
using one of these forms:
* ``toolset``
* ``toolset[,key=value]*``
* ``key=value[,key=value]*``
The ``toolset`` specifies the toolset name. The selected toolset name
is provided in the ``CMAKE_VS_PLATFORM_TOOLSET`` variable.
The ``key=value`` pairs form a comma-separated list of options to
specify generator-specific details of the toolset selection.
Supported pairs are:
``cuda=<version>|<path>``
Specify the CUDA toolkit version to use or the path to a
standalone CUDA toolkit directory. Supported by VS 2010
and above. The version can only be used with the CUDA
toolkit VS integration globally installed.
See the ``CMAKE_VS_PLATFORM_TOOLSET_CUDA`` and
``CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR`` variables.
``host=<arch>``
Specify the host tools architecture as ``x64`` or ``x86``.
Supported by VS 2013 and above.
See the ``CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE``
variable.
``version=<version>``
Specify the toolset version to use. Supported by VS 2017
and above with the specified toolset installed.
See the ``CMAKE_VS_PLATFORM_TOOLSET_VERSION`` variable.
``VCTargetsPath=<path>``
Specify an alternative ``VCTargetsPath`` value for Visual Studio
project files. This allows use of VS platform extension configuration
files (``.props`` and ``.targets``) that are not installed with VS.
CMAKE_IMPORT_LIBRARY_PREFIX
---------------------------
The prefix for import libraries that you link to.
The prefix to use for the name of an import library if used on this
platform.
``CMAKE_IMPORT_LIBRARY_PREFIX_<LANG>`` overrides this for language ``<LANG>``.
CMAKE_IMPORT_LIBRARY_SUFFIX
---------------------------
The suffix for import libraries that you link to.
The suffix to use for the end of an import library filename if used on
this platform.
``CMAKE_IMPORT_LIBRARY_SUFFIX_<LANG>`` overrides this for language ``<LANG>``.
CMAKE_JOB_POOL_COMPILE
----------------------
This variable is used to initialize the ``JOB_POOL_COMPILE``
property on all the targets. See ``JOB_POOL_COMPILE``
for additional information.
CMAKE_JOB_POOL_LINK
-------------------
This variable is used to initialize the ``JOB_POOL_LINK``
property on all the targets. See ``JOB_POOL_LINK``
for additional information.
CMAKE_JOB_POOL_PRECOMPILE_HEADER
--------------------------------
This variable is used to initialize the ``JOB_POOL_PRECOMPILE_HEADER``
property on all the targets. See ``JOB_POOL_PRECOMPILE_HEADER``
for additional information.
CMAKE_JOB_POOLS
---------------
If the ``JOB_POOLS`` global property is not set, the value
of this variable is used in its place. See ``JOB_POOLS``
for additional information.
CMAKE_<LANG>_COMPILER_AR
------------------------
A wrapper around ``ar`` adding the appropriate ``--plugin`` option for the
compiler.
See also ``CMAKE_AR``.
CMAKE_<LANG>_COMPILER_RANLIB
----------------------------
A wrapper around ``ranlib`` adding the appropriate ``--plugin`` option for the
compiler.
See also ``CMAKE_RANLIB``.
CMAKE_<LANG>_LINK_LIBRARY_SUFFIX
--------------------------------
Language-specific suffix for libraries that you link to.
The suffix to use for the end of a library filename, ``.lib`` on Windows.
CMAKE_LINK_LIBRARY_SUFFIX
-------------------------
The suffix for libraries that you link to.
The suffix to use for the end of a library filename, ``.lib`` on Windows.
CMAKE_LINK_SEARCH_END_STATIC
----------------------------
End a link line such that static system libraries are used.
Some linkers support switches such as ``-Bstatic`` and ``-Bdynamic`` to
determine whether to use static or shared libraries for ``-lXXX`` options.
CMake uses these options to set the link type for libraries whose full
paths are not known or (in some cases) are in implicit link
directories for the platform. By default CMake adds an option at the
end of the library list (if necessary) to set the linker search type
back to its starting type. This property switches the final linker
search type to ``-Bstatic`` regardless of how it started.
This variable is used to initialize the target property
``LINK_SEARCH_END_STATIC`` for all targets. If set, its
value is also used by the ``try_compile()`` command.
See also ``CMAKE_LINK_SEARCH_START_STATIC``.
CMAKE_LINK_SEARCH_START_STATIC
------------------------------
Assume the linker looks for static libraries by default.
Some linkers support switches such as ``-Bstatic`` and ``-Bdynamic`` to
determine whether to use static or shared libraries for ``-lXXX`` options.
CMake uses these options to set the link type for libraries whose full
paths are not known or (in some cases) are in implicit link
directories for the platform. By default the linker search type is
assumed to be ``-Bdynamic`` at the beginning of the library list. This
property switches the assumption to ``-Bstatic``. It is intended for use
when linking an executable statically (e.g. with the GNU ``-static``
option).
This variable is used to initialize the target property
``LINK_SEARCH_START_STATIC`` for all targets. If set, its
value is also used by the ``try_compile()`` command.
See also ``CMAKE_LINK_SEARCH_END_STATIC``.
CMAKE_MAJOR_VERSION
-------------------
First version number component of the ``CMAKE_VERSION``
variable.
CMAKE_MAKE_PROGRAM
------------------
Tool that can launch the native build system.
The value may be the full path to an executable or just the tool
name if it is expected to be in the ``PATH``.
The tool selected depends on the ``CMAKE_GENERATOR`` used
to configure the project:
* The :ref:`Makefile Generators` set this to ``make``, ``gmake``, or
a generator-specific tool (e.g. ``nmake`` for ``NMake Makefiles``).
These generators store ``CMAKE_MAKE_PROGRAM`` in the CMake cache
so that it may be edited by the user.
* The ``Ninja`` generator sets this to ``ninja``.
This generator stores ``CMAKE_MAKE_PROGRAM`` in the CMake cache
so that it may be edited by the user.
* The ``Xcode`` generator sets this to ``xcodebuild``.
This generator prefers to lookup the build tool at build time
rather than to store ``CMAKE_MAKE_PROGRAM`` in the CMake cache
ahead of time. This is because ``xcodebuild`` is easy to find.
For compatibility with versions of CMake prior to 3.2, if
a user or project explicitly adds ``CMAKE_MAKE_PROGRAM`` to
the CMake cache then CMake will use the specified value.
* The :ref:`Visual Studio Generators` set this to the full path to
``MSBuild.exe`` (VS >= 10), ``devenv.com`` (VS 7,8,9), or
``VCExpress.exe`` (VS Express 8,9).
(See also variables
``CMAKE_VS_MSBUILD_COMMAND`` and
``CMAKE_VS_DEVENV_COMMAND``.
These generators prefer to lookup the build tool at build time
rather than to store ``CMAKE_MAKE_PROGRAM`` in the CMake cache
ahead of time. This is because the tools are version-specific
and can be located using the Windows Registry. It is also
necessary because the proper build tool may depend on the
project content (e.g. the Intel Fortran plugin to VS 10 and 11
requires ``devenv.com`` to build its ``.vfproj`` project files
even though ``MSBuild.exe`` is normally preferred to support
the ``CMAKE_GENERATOR_TOOLSET``).
For compatibility with versions of CMake prior to 3.0, if
a user or project explicitly adds ``CMAKE_MAKE_PROGRAM`` to
the CMake cache then CMake will use the specified value if
possible.
* The ``Green Hills MULTI`` generator sets this to the full
path to ``gbuild.exe(Windows)`` or ``gbuild(Linux)`` based upon
the toolset being used.
Once the generator has initialized a particular value for this
variable, changing the value has undefined behavior.
The ``CMAKE_MAKE_PROGRAM`` variable is set for use by project code.
The value is also used by the ``cmake(1)`` ``--build`` and
``ctest(1)`` ``--build-and-test`` tools to launch the native
build process.
CMAKE_MATCH_COUNT
-----------------
The number of matches with the last regular expression.
When a regular expression match is used, CMake fills in
``CMAKE_MATCH_<n>`` variables with the match contents.
The ``CMAKE_MATCH_COUNT`` variable holds the number of match
expressions when these are filled.
CMAKE_MATCH_<n>
---------------
Capture group ``<n>`` matched by the last regular expression, for groups
0 through 9. Group 0 is the entire match. Groups 1 through 9 are the
subexpressions captured by ``()`` syntax.
When a regular expression match is used, CMake fills in ``CMAKE_MATCH_<n>``
variables with the match contents. The ``CMAKE_MATCH_COUNT``
variable holds the number of match expressions when these are filled.
CMAKE_MINIMUM_REQUIRED_VERSION
------------------------------
The ``<min>`` version of CMake given to the most recent call to the
``cmake_minimum_required(VERSION)`` command.
CMAKE_MINOR_VERSION
-------------------
Second version number component of the ``CMAKE_VERSION``
variable.
CMAKE_NETRC
-----------
This variable is used to initialize the ``NETRC`` option for
``file(DOWNLOAD)`` and ``file(UPLOAD)`` commands and the
module ``ExternalProject``. See those commands for additional
information.
The local option takes precedence over this variable.
CMAKE_NETRC_FILE
----------------
This variable is used to initialize the ``NETRC_FILE`` option for
``file(DOWNLOAD)`` and ``file(UPLOAD)`` commands and the
module ``ExternalProject``. See those commands for additional
information.
The local option takes precedence over this variable.
CMAKE_PARENT_LIST_FILE
----------------------
Full path to the CMake file that included the current one.
While processing a CMake file loaded by ``include()`` or
``find_package()`` this variable contains the full path to the file
including it. The top of the include stack is always the ``CMakeLists.txt``
for the current directory. See also ``CMAKE_CURRENT_LIST_FILE``.
CMAKE_PATCH_VERSION
-------------------
Third version number component of the ``CMAKE_VERSION``
variable.
CMAKE_PROJECT_DESCRIPTION
-------------------------
The description of the top level project.
This variable holds the description of the project as specified in the top
level CMakeLists.txt file by a ``project()`` command. In the event that
the top level CMakeLists.txt contains multiple ``project()`` calls,
the most recently called one from that top level CMakeLists.txt will determine
the value that ``CMAKE_PROJECT_DESCRIPTION`` contains. For example, consider
the following top level CMakeLists.txt:
cmake_minimum_required(VERSION 3.0)
project(First DESCRIPTION "I am First")
project(Second DESCRIPTION "I am Second")
add_subdirectory(sub)
project(Third DESCRIPTION "I am Third")
And ``sub/CMakeLists.txt`` with the following contents:
project(SubProj DESCRIPTION "I am SubProj")
message("CMAKE_PROJECT_DESCRIPTION = ${CMAKE_PROJECT_DESCRIPTION}")
The most recently seen ``project()`` command from the top level
CMakeLists.txt would be ``project(Second ...)``, so this will print::
CMAKE_PROJECT_DESCRIPTION = I am Second
To obtain the description from the most recent call to ``project()`` in
the current directory scope or above, see the ``PROJECT_DESCRIPTION``
variable.