1CMAKE-GENERATORS(7) CMake CMAKE-GENERATORS(7)
2
3
4
6 cmake-generators - CMake Generators Reference
7
9 A CMake Generator is responsible for writing the input files for a
10 native build system. Exactly one of the CMake Generators must be
11 selected for a build tree to determine what native build system is to
12 be used. Optionally one of the Extra Generators may be selected as a
13 variant of some of the Command-Line Build Tool Generators to produce
14 project files for an auxiliary IDE.
15
16 CMake Generators are platform-specific so each may be available only on
17 certain platforms. The cmake(1) command-line tool --help output lists
18 available generators on the current platform. Use its -G option to
19 specify the generator for a new build tree. The cmake-gui(1) offers
20 interactive selection of a generator when creating a new build tree.
21
23 Command-Line Build Tool Generators
24 These generators support command-line build tools. In order to use
25 them, one must launch CMake from a command-line prompt whose environ‐
26 ment is already configured for the chosen compiler and build tool.
27
28 Makefile Generators
29 Borland Makefiles
30 Generates Borland makefiles.
31
32 MSYS Makefiles
33 Generates makefiles for use with MSYS (Minimal SYStem) make under the
34 MSYS shell.
35
36 Use this generator in a MSYS shell prompt and using make as the build
37 tool. The generated makefiles use /bin/sh as the shell to launch build
38 rules. They are not compatible with a Windows command prompt.
39
40 To build under a Windows command prompt, use the MinGW Makefiles gener‐
41 ator.
42
43 MinGW Makefiles
44 Generates makefiles for use with mingw32-make under a Windows command
45 prompt.
46
47 Use this generator under a Windows command prompt with MinGW (Minimal‐
48 ist GNU for Windows) in the PATH and using mingw32-make as the build
49 tool. The generated makefiles use cmd.exe as the shell to launch build
50 rules. They are not compatible with MSYS or a unix shell.
51
52 To build under the MSYS shell, use the MSYS Makefiles generator.
53
54 NMake Makefiles
55 Generates NMake makefiles.
56
57 NMake Makefiles JOM
58 Generates JOM makefiles.
59
60 Unix Makefiles
61 Generates standard UNIX makefiles.
62
63 A hierarchy of UNIX makefiles is generated into the build tree. Use
64 any standard UNIX-style make program to build the project through the
65 all target and install the project through the install (or
66 install/strip) target.
67
68 For each subdirectory sub/dir of the project a UNIX makefile will be
69 created, containing the following targets:
70
71 all Depends on all targets required by the subdirectory.
72
73 install
74 Runs the install step in the subdirectory, if any.
75
76 install/strip
77 Runs the install step in the subdirectory followed by a
78 CMAKE_STRIP command, if any.
79
80 The CMAKE_STRIP variable will contain the platform’s strip util‐
81 ity, which removes symbols information from generated binaries.
82
83 test Runs the test step in the subdirectory, if any.
84
85 package
86 Runs the package step in the subdirectory, if any.
87
88 Watcom WMake
89 Generates Watcom WMake makefiles.
90
91 Ninja Generator
92 Ninja
93 Generates build.ninja files.
94
95 A build.ninja file is generated into the build tree. Use the ninja
96 program to build the project through the all target and install the
97 project through the install (or install/strip) target.
98
99 For each subdirectory sub/dir of the project, additional targets are
100 generated:
101
102 sub/dir/all
103 Depends on all targets required by the subdirectory.
104
105 sub/dir/install
106 Runs the install step in the subdirectory, if any.
107
108 sub/dir/install/strip
109 Runs the install step in the subdirectory followed by a
110 CMAKE_STRIP command, if any.
111
112 The CMAKE_STRIP variable will contain the platform’s strip util‐
113 ity, which removes symbols information from generated binaries.
114
115 sub/dir/test
116 Runs the test step in the subdirectory, if any.
117
118 sub/dir/package
119 Runs the package step in the subdirectory, if any.
120
121 Fortran Support
122 The Ninja generator conditionally supports Fortran when the ninja tool
123 has the required features. As of this version of CMake the needed fea‐
124 tures have not been integrated into upstream Ninja. Kitware maintains
125 a branch of Ninja with the required features on
126 github.com/Kitware/ninja.
127
128 IDE Build Tool Generators
129 These generators support Integrated Development Environment (IDE)
130 project files. Since the IDEs configure their own environment one may
131 launch CMake from any environment.
132
133 Visual Studio Generators
134 Visual Studio 6
135 Removed. This once generated Visual Studio 6 project files, but the
136 generator has been removed since CMake 3.6. It is still possible to
137 build with VS 6 tools using the NMake Makefiles generator.
138
139 Visual Studio 7
140 Removed. This once generated Visual Studio .NET 2002 project files,
141 but the generator has been removed since CMake 3.6. It is still possi‐
142 ble to build with VS 7.0 tools using the NMake Makefiles generator.
143
144 Visual Studio 7 .NET 2003
145 Removed. This once generated Visual Studio .NET 2003 project files,
146 but the generator has been removed since CMake 3.9. It is still possi‐
147 ble to build with VS 7.1 tools using the NMake Makefiles generator.
148
149 Visual Studio 8 2005
150 Removed. This once generated Visual Studio 8 2005 project files, but
151 the generator has been removed since CMake 3.12. It is still possible
152 to build with VS 2005 tools using the NMake Makefiles generator.
153
154 Visual Studio 9 2008
155 Generates Visual Studio 9 2008 project files.
156
157 Platform Selection
158 The default target platform name (architecture) is Win32.
159
160 The CMAKE_GENERATOR_PLATFORM variable may be set, perhaps via the
161 cmake(1) -A option, to specify a target platform name (architecture).
162 For example:
163
164 · cmake -G "Visual Studio 9 2008" -A Win32
165
166 · cmake -G "Visual Studio 9 2008" -A x64
167
168 · cmake -G "Visual Studio 9 2008" -A Itanium
169
170 · cmake -G "Visual Studio 9 2008" -A <WinCE-SDK> (Specify a target
171 platform matching a Windows CE SDK name.)
172
173 For compatibility with CMake versions prior to 3.1, one may specify a
174 target platform name optionally at the end of the generator name. This
175 is supported only for:
176
177 Visual Studio 9 2008 Win64
178 Specify target platform x64.
179
180 Visual Studio 9 2008 IA64
181 Specify target platform Itanium.
182
183 Visual Studio 9 2008 <WinCE-SDK>
184 Specify target platform matching a Windows CE SDK name.
185
186 Visual Studio 10 2010
187 Generates Visual Studio 10 (VS 2010) project files.
188
189 For compatibility with CMake versions prior to 3.0, one may specify
190 this generator using the name Visual Studio 10 without the year compo‐
191 nent.
192
193 Project Types
194 Only Visual C++ and C# projects may be generated. Other types of
195 projects (Database, Website, etc.) are not supported.
196
197 Platform Selection
198 The default target platform name (architecture) is Win32.
199
200 The CMAKE_GENERATOR_PLATFORM variable may be set, perhaps via the
201 cmake(1) -A option, to specify a target platform name (architecture).
202 For example:
203
204 · cmake -G "Visual Studio 10 2010" -A Win32
205
206 · cmake -G "Visual Studio 10 2010" -A x64
207
208 · cmake -G "Visual Studio 10 2010" -A Itanium
209
210 For compatibility with CMake versions prior to 3.1, one may specify a
211 target platform name optionally at the end of the generator name. This
212 is supported only for:
213
214 Visual Studio 10 2010 Win64
215 Specify target platform x64.
216
217 Visual Studio 10 2010 IA64
218 Specify target platform Itanium.
219
220 Toolset Selection
221 The v100 toolset that comes with Visual Studio 10 2010 is selected by
222 default. The CMAKE_GENERATOR_TOOLSET option may be set, perhaps via
223 the cmake(1) -T option, to specify another toolset.
224
225 Visual Studio 11 2012
226 Generates Visual Studio 11 (VS 2012) project files.
227
228 For compatibility with CMake versions prior to 3.0, one may specify
229 this generator using the name “Visual Studio 11” without the year com‐
230 ponent.
231
232 Project Types
233 Only Visual C++ and C# projects may be generated. Other types of
234 projects (JavaScript, Database, Website, etc.) are not supported.
235
236 Platform Selection
237 The default target platform name (architecture) is Win32.
238
239 The CMAKE_GENERATOR_PLATFORM variable may be set, perhaps via the
240 cmake(1) -A option, to specify a target platform name (architecture).
241 For example:
242
243 · cmake -G "Visual Studio 11 2012" -A Win32
244
245 · cmake -G "Visual Studio 11 2012" -A x64
246
247 · cmake -G "Visual Studio 11 2012" -A ARM
248
249 · cmake -G "Visual Studio 11 2012" -A <WinCE-SDK> (Specify a target
250 platform matching a Windows CE SDK name.)
251
252 For compatibility with CMake versions prior to 3.1, one may specify a
253 target platform name optionally at the end of the generator name. This
254 is supported only for:
255
256 Visual Studio 11 2012 Win64
257 Specify target platform x64.
258
259 Visual Studio 11 2012 ARM
260 Specify target platform ARM.
261
262 Visual Studio 11 2012 <WinCE-SDK>
263 Specify target platform matching a Windows CE SDK name.
264
265 Toolset Selection
266 The v110 toolset that comes with Visual Studio 11 2012 is selected by
267 default. The CMAKE_GENERATOR_TOOLSET option may be set, perhaps via
268 the cmake(1) -T option, to specify another toolset.
269
270 Visual Studio 12 2013
271 Generates Visual Studio 12 (VS 2013) project files.
272
273 For compatibility with CMake versions prior to 3.0, one may specify
274 this generator using the name “Visual Studio 12” without the year com‐
275 ponent.
276
277 Project Types
278 Only Visual C++ and C# projects may be generated. Other types of
279 projects (JavaScript, Powershell, Python, etc.) are not supported.
280
281 Platform Selection
282 The default target platform name (architecture) is Win32.
283
284 The CMAKE_GENERATOR_PLATFORM variable may be set, perhaps via the
285 cmake(1) -A option, to specify a target platform name (architecture).
286 For example:
287
288 · cmake -G "Visual Studio 12 2013" -A Win32
289
290 · cmake -G "Visual Studio 12 2013" -A x64
291
292 · cmake -G "Visual Studio 12 2013" -A ARM
293
294 For compatibility with CMake versions prior to 3.1, one may specify a
295 target platform name optionally at the end of the generator name. This
296 is supported only for:
297
298 Visual Studio 12 2013 Win64
299 Specify target platform x64.
300
301 Visual Studio 12 2013 ARM
302 Specify target platform ARM.
303
304 Toolset Selection
305 The v120 toolset that comes with Visual Studio 12 2013 is selected by
306 default. The CMAKE_GENERATOR_TOOLSET option may be set, perhaps via
307 the cmake(1) -T option, to specify another toolset.
308
309 For each toolset that comes with this version of Visual Studio, there
310 are variants that are themselves compiled for 32-bit (x86) and 64-bit
311 (x64) hosts (independent of the architecture they target). By default
312 this generator uses the 32-bit variant even on a 64-bit host. One may
313 explicitly request use of either the 32-bit or 64-bit host tools by
314 adding either host=x86 or host=x64 to the toolset specification. See
315 the CMAKE_GENERATOR_TOOLSET variable for details.
316
317 Visual Studio 14 2015
318 Generates Visual Studio 14 (VS 2015) project files.
319
320 Project Types
321 Only Visual C++ and C# projects may be generated. Other types of
322 projects (JavaScript, Powershell, Python, etc.) are not supported.
323
324 Platform Selection
325 The default target platform name (architecture) is Win32.
326
327 The CMAKE_GENERATOR_PLATFORM variable may be set, perhaps via the
328 cmake(1) -A option, to specify a target platform name (architecture).
329 For example:
330
331 · cmake -G "Visual Studio 14 2015" -A Win32
332
333 · cmake -G "Visual Studio 14 2015" -A x64
334
335 · cmake -G "Visual Studio 14 2015" -A ARM
336
337 For compatibility with CMake versions prior to 3.1, one may specify a
338 target platform name optionally at the end of the generator name. This
339 is supported only for:
340
341 Visual Studio 14 2015 Win64
342 Specify target platform x64.
343
344 Visual Studio 14 2015 ARM
345 Specify target platform ARM.
346
347 Toolset Selection
348 The v140 toolset that comes with Visual Studio 14 2015 is selected by
349 default. The CMAKE_GENERATOR_TOOLSET option may be set, perhaps via
350 the cmake(1) -T option, to specify another toolset.
351
352 For each toolset that comes with this version of Visual Studio, there
353 are variants that are themselves compiled for 32-bit (x86) and 64-bit
354 (x64) hosts (independent of the architecture they target). By default
355 this generator uses the 32-bit variant even on a 64-bit host. One may
356 explicitly request use of either the 32-bit or 64-bit host tools by
357 adding either host=x86 or host=x64 to the toolset specification. See
358 the CMAKE_GENERATOR_TOOLSET variable for details.
359
360 Visual Studio 15 2017
361 Generates Visual Studio 15 (VS 2017) project files.
362
363 Project Types
364 Only Visual C++ and C# projects may be generated. Other types of
365 projects (JavaScript, Powershell, Python, etc.) are not supported.
366
367 Instance Selection
368 VS 2017 supports multiple installations on the same machine. The
369 CMAKE_GENERATOR_INSTANCE variable may be set as a cache entry contain‐
370 ing the absolute path to a Visual Studio instance. If the value is not
371 specified explicitly by the user or a toolchain file, CMake queries the
372 Visual Studio Installer to locate VS instances, chooses one, and sets
373 the variable as a cache entry to hold the value persistently.
374
375 When CMake first chooses an instance, if the VS150COMNTOOLS environment
376 variable is set and points to the Common7/Tools directory within one of
377 the instances, that instance will be used. Otherwise, if more than one
378 instance is installed we do not define which one is chosen by default.
379
380 Platform Selection
381 The default target platform name (architecture) is Win32.
382
383 The CMAKE_GENERATOR_PLATFORM variable may be set, perhaps via the
384 cmake(1) -A option, to specify a target platform name (architecture).
385 For example:
386
387 · cmake -G "Visual Studio 15 2017" -A Win32
388
389 · cmake -G "Visual Studio 15 2017" -A x64
390
391 · cmake -G "Visual Studio 15 2017" -A ARM
392
393 · cmake -G "Visual Studio 15 2017" -A ARM64
394
395 For compatibility with CMake versions prior to 3.1, one may specify a
396 target platform name optionally at the end of the generator name. This
397 is supported only for:
398
399 Visual Studio 15 2017 Win64
400 Specify target platform x64.
401
402 Visual Studio 15 2017 ARM
403 Specify target platform ARM.
404
405 Toolset Selection
406 The v141 toolset that comes with Visual Studio 15 2017 is selected by
407 default. The CMAKE_GENERATOR_TOOLSET option may be set, perhaps via
408 the cmake(1) -T option, to specify another toolset.
409
410 For each toolset that comes with this version of Visual Studio, there
411 are variants that are themselves compiled for 32-bit (x86) and 64-bit
412 (x64) hosts (independent of the architecture they target). By default
413 this generator uses the 32-bit variant even on a 64-bit host. One may
414 explicitly request use of either the 32-bit or 64-bit host tools by
415 adding either host=x86 or host=x64 to the toolset specification. See
416 the CMAKE_GENERATOR_TOOLSET variable for details.
417
418 Visual Studio 16 2019
419 Generates Visual Studio 16 (VS 2019) project files.
420
421 Project Types
422 Only Visual C++ and C# projects may be generated. Other types of
423 projects (JavaScript, Powershell, Python, etc.) are not supported.
424
425 Instance Selection
426 VS 2019 supports multiple installations on the same machine. The
427 CMAKE_GENERATOR_INSTANCE variable may be set as a cache entry contain‐
428 ing the absolute path to a Visual Studio instance. If the value is not
429 specified explicitly by the user or a toolchain file, CMake queries the
430 Visual Studio Installer to locate VS instances, chooses one, and sets
431 the variable as a cache entry to hold the value persistently.
432
433 When CMake first chooses an instance, if the VS160COMNTOOLS environment
434 variable is set and points to the Common7/Tools directory within one of
435 the instances, that instance will be used. Otherwise, if more than one
436 instance is installed we do not define which one is chosen by default.
437
438 Platform Selection
439 The default target platform name (architecture) is that of the host and
440 is provided in the CMAKE_VS_PLATFORM_NAME_DEFAULT variable.
441
442 The CMAKE_GENERATOR_PLATFORM variable may be set, perhaps via the
443 cmake(1) -A option, to specify a target platform name (architecture).
444 For example:
445
446 · cmake -G "Visual Studio 16 2019" -A Win32
447
448 · cmake -G "Visual Studio 16 2019" -A x64
449
450 · cmake -G "Visual Studio 16 2019" -A ARM
451
452 · cmake -G "Visual Studio 16 2019" -A ARM64
453
454 Toolset Selection
455 The v142 toolset that comes with Visual Studio 16 2019 is selected by
456 default. The CMAKE_GENERATOR_TOOLSET option may be set, perhaps via
457 the cmake(1) -T option, to specify another toolset.
458
459 For each toolset that comes with this version of Visual Studio, there
460 are variants that are themselves compiled for 32-bit (x86) and 64-bit
461 (x64) hosts (independent of the architecture they target). By default
462 this generator uses the 64-bit variant on x64 hosts and the 32-bit
463 variant otherwise. One may explicitly request use of either the 32-bit
464 or 64-bit host tools by adding either host=x86 or host=x64 to the
465 toolset specification. See the CMAKE_GENERATOR_TOOLSET variable for
466 details.
467
468 Other Generators
469 Green Hills MULTI
470 Generates Green Hills MULTI project files (experimental,
471 work-in-progress).
472
473 The buildsystem has predetermined build-configuration settings that can
474 be controlled via the CMAKE_BUILD_TYPE variable.
475
476 Customizations that are used to pick toolset and target system:
477
478 The -A <arch> can be supplied for setting the target architecture.
479 <arch> usually is one of arm, ppc, 86, etcetera. If the target archi‐
480 tecture is not specified then the default architecture of arm will be
481 used.
482
483 The -T <toolset> option can be used to set the directory location of
484 the toolset. Both absolute and relative paths are valid. Relative
485 paths use GHS_TOOLSET_ROOT as the root. If the toolset is not specified
486 then the latest toolset found in GHS_TOOLSET_ROOT will be used.
487
488 Cache variables that are used for toolset and target system customiza‐
489 tion:
490
491 · GHS_TARGET_PLATFORM
492 Defaults to integrity.
493 Usual values are integrity, threadx, uvelosity, velosity,
494 vxworks, standalone.
495
496
497 · GHS_PRIMARY_TARGET
498 Sets primaryTarget entry in project file.
499 Defaults to <arch>_<GHS_TARGET_PLATFORM>.tgt.
500
501
502 · GHS_TOOLSET_ROOT
503 Root path for toolset searches.
504 Defaults to C:/ghs in Windows or /usr/ghs in Linux.
505
506
507 · GHS_OS_ROOT
508 Root path for RTOS searches.
509 Defaults to C:/ghs in Windows or /usr/ghs in Linux.
510
511
512 · GHS_OS_DIR and GHS_OS_DIR_OPTION
513 Sets -os_dir entry in project file.
514 Defaults to latest platform OS installation at GHS_OS_ROOT. Set this value if
515 a specific RTOS is to be used.
516 GHS_OS_DIR_OPTION default value is -os_dir.
517
518
519 · GHS_BSP_NAME
520 Sets -bsp entry in project file.
521 Defaults to sim<arch> for integrity platforms.
522
523
524 Customizations are available through the following cache variables:
525
526 · GHS_CUSTOMIZATION
527
528 · GHS_GPJ_MACROS
529
530 The following properties are available:
531
532 · GHS_INTEGRITY_APP
533
534 · GHS_NO_SOURCE_GROUP_FILE
535
536 NOTE:
537 This generator is deemed experimental as of CMake 3.16.1 and is
538 still a work in progress. Future versions of CMake may make break‐
539 ing changes as the generator matures.
540
541 Xcode
542 Generate Xcode project files.
543
544 This supports Xcode 5.0 and above.
545
546 Toolset Selection
547 By default Xcode is allowed to select its own default toolchain. The
548 CMAKE_GENERATOR_TOOLSET option may be set, perhaps via the cmake(1) -T
549 option, to specify another toolset.
550
552 Some of the CMake Generators listed in the cmake(1) command-line tool
553 --help output may have variants that specify an extra generator for an
554 auxiliary IDE tool. Such generator names have the form <extra-genera‐
555 tor> - <main-generator>. The following extra generators are known to
556 CMake.
557
558 CodeBlocks
559 Generates CodeBlocks project files.
560
561 Project files for CodeBlocks will be created in the top directory and
562 in every subdirectory which features a CMakeLists.txt file containing a
563 project() call. Additionally a hierarchy of makefiles is generated
564 into the build tree. The CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES vari‐
565 able may be set to ON to exclude any files which are located outside of
566 the project root directory. The appropriate make program can build the
567 project through the default all target. An install target is also pro‐
568 vided.
569
570 This “extra” generator may be specified as:
571
572 CodeBlocks - MinGW Makefiles
573 Generate with MinGW Makefiles.
574
575 CodeBlocks - NMake Makefiles
576 Generate with NMake Makefiles.
577
578 CodeBlocks - NMake Makefiles JOM
579 Generate with NMake Makefiles JOM.
580
581 CodeBlocks - Ninja
582 Generate with Ninja.
583
584 CodeBlocks - Unix Makefiles
585 Generate with Unix Makefiles.
586
587 CodeLite
588 Generates CodeLite project files.
589
590 Project files for CodeLite will be created in the top directory and in
591 every subdirectory which features a CMakeLists.txt file containing a
592 project() call. The CMAKE_CODELITE_USE_TARGETS variable may be set to
593 ON to change the default behavior from projects to targets as the basis
594 for project files. The appropriate make program can build the project
595 through the default all target. An install target is also provided.
596
597 This “extra” generator may be specified as:
598
599 CodeLite - MinGW Makefiles
600 Generate with MinGW Makefiles.
601
602 CodeLite - NMake Makefiles
603 Generate with NMake Makefiles.
604
605 CodeLite - Ninja
606 Generate with Ninja.
607
608 CodeLite - Unix Makefiles
609 Generate with Unix Makefiles.
610
611 Eclipse CDT4
612 Generates Eclipse CDT 4.0 project files.
613
614 Project files for Eclipse will be created in the top directory. In out
615 of source builds, a linked resource to the top level source directory
616 will be created. Additionally a hierarchy of makefiles is generated
617 into the build tree. The appropriate make program can build the
618 project through the default all target. An install target is also pro‐
619 vided.
620
621 This “extra” generator may be specified as:
622
623 Eclipse CDT4 - MinGW Makefiles
624 Generate with MinGW Makefiles.
625
626 Eclipse CDT4 - NMake Makefiles
627 Generate with NMake Makefiles.
628
629 Eclipse CDT4 - Ninja
630 Generate with Ninja.
631
632 Eclipse CDT4 - Unix Makefiles
633 Generate with Unix Makefiles.
634
635 Kate
636 Generates Kate project files.
637
638 A project file for Kate will be created in the top directory in the top
639 level build directory. To use it in Kate, the Project plugin must be
640 enabled. The project file is loaded in Kate by opening the Project‐
641 Name.kateproject file in the editor. If the Kate Build-plugin is
642 enabled, all targets generated by CMake are available for building.
643
644 This “extra” generator may be specified as:
645
646 Kate - MinGW Makefiles
647 Generate with MinGW Makefiles.
648
649 Kate - NMake Makefiles
650 Generate with NMake Makefiles.
651
652 Kate - Ninja
653 Generate with Ninja.
654
655 Kate - Unix Makefiles
656 Generate with Unix Makefiles.
657
658 Sublime Text 2
659 Generates Sublime Text 2 project files.
660
661 Project files for Sublime Text 2 will be created in the top directory
662 and in every subdirectory which features a CMakeLists.txt file contain‐
663 ing a project() call. Additionally Makefiles (or build.ninja files)
664 are generated into the build tree. The appropriate make program can
665 build the project through the default all target. An install target is
666 also provided.
667
668 This “extra” generator may be specified as:
669
670 Sublime Text 2 - MinGW Makefiles
671 Generate with MinGW Makefiles.
672
673 Sublime Text 2 - NMake Makefiles
674 Generate with NMake Makefiles.
675
676 Sublime Text 2 - Ninja
677 Generate with Ninja.
678
679 Sublime Text 2 - Unix Makefiles
680 Generate with Unix Makefiles.
681
683 2000-2019 Kitware, Inc. and Contributors
684
685
686
687
6883.16.1 Dec 14, 2019 CMAKE-GENERATORS(7)