NAME
cmake-generators - CMake Generators ReferenceINTRODUCTION
A CMake Generator is responsible for writing the input files for a native build system. Exactly one of the CMake Generators must be selected for a build tree to determine what native build system is to be used. Optionally one of the Extra Generators may be selected as a variant of some of the Command-Line Build Tool Generators to produce project files for an auxiliary IDE.CMAKE GENERATORS
Command-Line Build Tool Generators
These generators support command-line build tools. In order to use them, one must launch CMake from a command-line prompt whose environment is already configured for the chosen compiler and build tool.Makefile Generators
Borland Makefiles
Generates Borland makefiles.MSYS Makefiles
Generates makefiles for use with MSYS (Minimal SYStem) make under the MSYS shell.MinGW Makefiles
Generates makefiles for use with mingw32-make under a Windows command prompt.NMake Makefiles
Generates NMake makefiles.NMake Makefiles JOM
Generates JOM makefiles.Unix Makefiles
Generates standard UNIX makefiles.- all
- Depends on all targets required by the subdirectory.
- install
- Runs the install step in the subdirectory, if any.
- install/strip
- Runs the install step in the subdirectory followed by a CMAKE_STRIP command, if any. The CMAKE_STRIP variable will contain the platform's strip utility, which removes symbols information from generated binaries.
- test
- Runs the test step in the subdirectory, if any.
- package
- Runs the package step in the subdirectory, if any.
Watcom WMake
Generates Watcom WMake makefiles.Ninja Generators
Ninja
Generates build.ninja files.New in version 3.6: Depends on all targets
required by the subdirectory.
New in version 3.7: Runs the install step in
the subdirectory, if any.
New in version 3.7: Runs the install step in
the subdirectory followed by a CMAKE_STRIP command, if any.
The CMAKE_STRIP variable will contain the platform's strip
utility, which removes symbols information from generated binaries.
New in version 3.7: Runs the test step in the
subdirectory, if any.
New in version 3.7: Runs the package step in
the subdirectory, if any.
Fortran Support
New in version 3.7.Swift Support
New in version 3.15.See Also
New in version 3.17: The Ninja Multi-Config generator is similar to the Ninja generator, but generates multiple configurations at once.Ninja Multi-Config
New in version 3.17.- CMAKE_CONFIGURATION_TYPES
- Specifies the total set of configurations to build. Unlike with other multi-config generators, this variable has a value of Debug;Release;RelWithDebInfo by default.
- CMAKE_CROSS_CONFIGS
- Specifies a semicolon-separated list of configurations available from all build-<Config>.ninja files.
- CMAKE_DEFAULT_BUILD_TYPE
- Specifies the configuration to use by default in a build.ninja file.
- CMAKE_DEFAULT_CONFIGS
- Specifies a semicolon-separated list of configurations to build for a target in build.ninja if no :<Config> suffix is specified.
cmake_minimum_required(VERSION 3.16) project(MultiConfigNinja C) add_executable(generator generator.c) add_custom_command(OUTPUT generated.c COMMAND generator generated.c) add_library(generated ${CMAKE_BINARY_DIR}/generated.c)
ninja -f build-Debug.ninja generated # OR cmake --build . --config Debug --target generated
ninja -f build-Release.ninja generated:Debug # OR cmake --build . --config Release --target generated:Debug
Custom Commands
New in version 3.20.add_custom_command( OUTPUT "$<CONFIG>.txt" COMMAND generator "$<CONFIG>.txt" "$<OUTPUT_CONFIG:$<CONFIG>>" "$<COMMAND_CONFIG:$<CONFIG>>" DEPENDS tgt1 "$<TARGET_FILE:tgt2>" "$<OUTPUT_CONFIG:$<TARGET_FILE:tgt3>>" "$<COMMAND_CONFIG:$<TARGET_FILE:tgt4>>" )
add_executable(exe main.c) add_custom_command( TARGET exe POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "Running no-byproduct command" ) add_custom_command( TARGET exe POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "Running separate-byproduct command for $<CONFIG>" BYPRODUCTS $<CONFIG>.txt ) add_custom_command( TARGET exe POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "Running common-byproduct command for $<CONFIG>" BYPRODUCTS exe.txt )
IDE Build Tool Generators
These generators support Integrated Development Environment (IDE) project files. Since the IDEs configure their own environment one may launch CMake from any environment.Visual Studio Generators
Visual Studio 6
Removed. This once generated Visual Studio 6 project files, but the generator has been removed since CMake 3.6. It is still possible to build with VS 6 tools using the NMake Makefiles generator.Visual Studio 7
Removed. This once generated Visual Studio .NET 2002 project files, but the generator has been removed since CMake 3.6. It is still possible to build with VS 7.0 tools using the NMake Makefiles generator.Visual Studio 7 .NET 2003
Removed. This once generated Visual Studio .NET 2003 project files, but the generator has been removed since CMake 3.9. It is still possible to build with VS 7.1 tools using the NMake Makefiles generator.Visual Studio 8 2005
Removed. This once generated Visual Studio 8 2005 project files, but the generator has been removed since CMake 3.12. It is still possible to build with VS 2005 tools using the NMake Makefiles generator.Visual Studio 9 2008
Generates Visual Studio 9 2008 project files.Platform Selection
The default target platform name (architecture) is Win32.- •
- cmake -G "Visual Studio 9 2008" -A Win32
- •
- cmake -G "Visual Studio 9 2008" -A x64
- •
- cmake -G "Visual Studio 9 2008" -A Itanium
- •
- cmake -G "Visual Studio 9 2008" -A <WinCE-SDK> (Specify a target platform matching a Windows CE SDK name.)
- Visual Studio 9 2008 Win64
- Specify target platform x64.
- Visual Studio 9 2008 IA64
- Specify target platform Itanium.
- Visual Studio 9 2008 <WinCE-SDK>
- Specify target platform matching a Windows CE SDK name.
Visual Studio 10 2010
Removed. This once generated Visual Studio 10 2010 project files, but the generator has been removed since CMake 3.25. It is still possible to build with VS 10 2010 tools using the Visual Studio 12 2013 (or above) generator with CMAKE_GENERATOR_TOOLSET set to v100, or by using the NMake Makefiles generator.Visual Studio 11 2012
Deprecated. Generates Visual Studio 11 (VS 2012) project files.This generator is deprecated and will be
removed in a future version of CMake. It will still be possible to build with
VS 11 2012 tools using the Visual Studio 12 2013 (or above) generator
with CMAKE_GENERATOR_TOOLSET set to v110, or by using the
NMake Makefiles generator.
Project Types
Only Visual C++ and C# projects may be generated (and Fortran with Intel compiler integration). Other types of projects (JavaScript, Database, Website, etc.) are not supported.Platform Selection
The default target platform name (architecture) is Win32.- •
- cmake -G "Visual Studio 11 2012" -A Win32
- •
- cmake -G "Visual Studio 11 2012" -A x64
- •
- cmake -G "Visual Studio 11 2012" -A ARM
- •
- cmake -G "Visual Studio 11 2012" -A <WinCE-SDK> (Specify a target platform matching a Windows CE SDK name.)
- Visual Studio 11 2012 Win64
- Specify target platform x64.
- Visual Studio 11 2012 ARM
- Specify target platform ARM.
- Visual Studio 11 2012 <WinCE-SDK>
- Specify target platform matching a Windows CE SDK name.
Toolset Selection
The v110 toolset that comes with Visual Studio 11 2012 is selected by default. The CMAKE_GENERATOR_TOOLSET option may be set, perhaps via the cmake -T option, to specify another toolset.Visual Studio 12 2013
Generates Visual Studio 12 (VS 2013) project files.Project Types
Only Visual C++ and C# projects may be generated (and Fortran with Intel compiler integration). Other types of projects (JavaScript, Powershell, Python, etc.) are not supported.Platform Selection
The default target platform name (architecture) is Win32.- •
- cmake -G "Visual Studio 12 2013" -A Win32
- •
- cmake -G "Visual Studio 12 2013" -A x64
- •
- cmake -G "Visual Studio 12 2013" -A ARM
- Visual Studio 12 2013 Win64
- Specify target platform x64.
- Visual Studio 12 2013 ARM
- Specify target platform ARM.
Toolset Selection
The v120 toolset that comes with Visual Studio 12 2013 is selected by default. The CMAKE_GENERATOR_TOOLSET option may be set, perhaps via the cmake -T option, to specify another toolset.Visual Studio 14 2015
New in version 3.1.Project Types
Only Visual C++ and C# projects may be generated (and Fortran with Intel compiler integration). Other types of projects (JavaScript, Powershell, Python, etc.) are not supported.Platform Selection
The default target platform name (architecture) is Win32.- •
- cmake -G "Visual Studio 14 2015" -A Win32
- •
- cmake -G "Visual Studio 14 2015" -A x64
- •
- cmake -G "Visual Studio 14 2015" -A ARM
- Visual Studio 14 2015 Win64
- Specify target platform x64.
- Visual Studio 14 2015 ARM
- Specify target platform ARM.
Toolset Selection
The v140 toolset that comes with Visual Studio 14 2015 is selected by default. The CMAKE_GENERATOR_TOOLSET option may be set, perhaps via the cmake -T option, to specify another toolset.Windows 10 SDK Maximum Version for VS 2015
New in version 3.19.Visual Studio 15 2017
New in version 3.7.1.Project Types
Only Visual C++ and C# projects may be generated (and Fortran with Intel compiler integration). Other types of projects (JavaScript, Powershell, Python, etc.) are not supported.Instance Selection
New in version 3.11.Platform Selection
The default target platform name (architecture) is Win32.- •
- cmake -G "Visual Studio 15 2017" -A Win32
- •
- cmake -G "Visual Studio 15 2017" -A x64
- •
- cmake -G "Visual Studio 15 2017" -A ARM
- •
- cmake -G "Visual Studio 15 2017" -A ARM64
- Visual Studio 15 2017 Win64
- Specify target platform x64.
- Visual Studio 15 2017 ARM
- Specify target platform ARM.
Toolset Selection
The v141 toolset that comes with Visual Studio 15 2017 is selected by default. The CMAKE_GENERATOR_TOOLSET option may be set, perhaps via the cmake -T option, to specify another toolset.Visual Studio 16 2019
New in version 3.14.Project Types
Only Visual C++ and C# projects may be generated (and Fortran with Intel compiler integration). Other types of projects (JavaScript, Powershell, Python, etc.) are not supported.Instance Selection
VS 2019 supports multiple installations on the same machine. The CMAKE_GENERATOR_INSTANCE variable may be used to select one.Platform Selection
The default target platform name (architecture) is that of the host and is provided in the CMAKE_VS_PLATFORM_NAME_DEFAULT variable.- •
- cmake -G "Visual Studio 16 2019" -A Win32
- •
- cmake -G "Visual Studio 16 2019" -A x64
- •
- cmake -G "Visual Studio 16 2019" -A ARM
- •
- cmake -G "Visual Studio 16 2019" -A ARM64
Toolset Selection
The v142 toolset that comes with Visual Studio 16 2019 is selected by default. The CMAKE_GENERATOR_TOOLSET option may be set, perhaps via the cmake -T option, to specify another toolset.Visual Studio 17 2022
New in version 3.21.Project Types
Only Visual C++ and C# projects may be generated (and Fortran with Intel compiler integration). Other types of projects (JavaScript, Powershell, Python, etc.) are not supported.Instance Selection
VS 2022 supports multiple installations on the same machine. The CMAKE_GENERATOR_INSTANCE variable may be used to select one.Platform Selection
The default target platform name (architecture) is that of the host and is provided in the CMAKE_VS_PLATFORM_NAME_DEFAULT variable.- •
- cmake -G "Visual Studio 17 2022" -A Win32
- •
- cmake -G "Visual Studio 17 2022" -A x64
- •
- cmake -G "Visual Studio 17 2022" -A ARM
- •
- cmake -G "Visual Studio 17 2022" -A ARM64
Toolset Selection
The v143 toolset that comes with VS 17 2022 is selected by default. The CMAKE_GENERATOR_TOOLSET option may be set, perhaps via the cmake -T option, to specify another toolset.Other Generators
Green Hills MULTI
New in version 3.3.The buildsystem has predetermined
build-configuration settings that can be controlled via the
CMAKE_BUILD_TYPE variable.
Platform Selection
New in version 3.13.Sets primaryTarget entry in project file.
- •
- cmake -G "Green Hills MULTI" -D GHS_PRIMARY_TARGET=ppc_integrity.tgt
- •
- The CMAKE_GENERATOR_PLATFORM variable may be set,
perhaps via the cmake -A option.
Typical values of arm, ppc, 86, etcetera, are used.
- •
- The variable GHS_TARGET_PLATFORM may be set, perhaps
via the cmake -D option.
Defaults to integrity. Usual values are integrity, threadx, uvelosity, velosity, vxworks, standalone.
- •
- cmake -G "Green Hills MULTI" for arm_integrity.tgt.
- •
- cmake -G "Green Hills MULTI" -A 86 for 86_integrity.tgt.
- •
- cmake -G "Green Hills MULTI" -D GHS_TARGET_PLATFORM=standalone for arm_standalone.tgt.
- •
- cmake -G "Green Hills MULTI" -A ppc -D GHS_TARGET_PLATFORM=standalone for ppc_standalone.tgt.
Toolset Selection
New in version 3.13.- •
- The CMAKE_GENERATOR_TOOLSET option may be set, perhaps via the cmake -T option, to specify the location of the toolset. Both absolute and relative paths are valid. Paths are relative to GHS_TOOLSET_ROOT.
- •
- The variable GHS_TOOLSET_ROOT may be set, perhaps
via the cmake -D option.
Root path for toolset searches and relative paths. Defaults to C:/ghs in Windows or /usr/ghs in Linux.
- •
- cmake -G "Green Hills MULTI" -T comp_201754 for /usr/ghs/comp_201754.
- •
- cmake -G "Green Hills MULTI" -T comp_201754 -D GHS_TOOLSET_ROOT=/opt/ghs for /opt/ghs/comp_201754.
- •
- cmake -G "Green Hills MULTI" -T /usr/ghs/comp_201554
- •
- cmake -G "Green Hills MULTI" -T C:/ghs/comp_201754
- •
- cmake -G "Green Hills MULTI" for searching /usr/ghs.
- •
- cmake -G "Green Hills MULTI -D GHS_TOOLSET_ROOT=/opt/ghs" for searching /opt/ghs.
The CMAKE_GENERATOR_TOOLSET should use
CMake style paths.
OS and BSP Selection
New in version 3.3.- •
-
GHS_OS_DIR and GHS_OS_DIR_OPTION
Sets -os_dir entry in project file.
GHS_OS_DIR_OPTION default value is -os_dir.
New in version 3.15: The GHS_OS_DIR_OPTION variable. For example:
- •
- cmake -G "Green Hills MULTI" -D GHS_OS_DIR=/usr/ghs/int1144
- •
-
GHS_OS_ROOT
Root path for RTOS searches. Defaults to C:/ghs in Windows or /usr/ghs in Linux.
For example:
- •
- cmake -G "Green Hills MULTI" -D GHS_OS_ROOT=/opt/ghs
- •
-
GHS_BSP_NAME
Sets -bsp entry in project file. Defaults to sim<arch> for integrity platforms.
For example:
- •
- cmake -G "Green Hills MULTI" for simarm on arm_integrity.tgt.
- •
- cmake -G "Green Hills MULTI" -A 86 for sim86 on 86_integrity.tgt.
- •
- cmake -G "Green Hills MULTI" -A ppc -D GHS_BSP_NAME=sim800 for sim800 on ppc_integrity.tgt.
- •
- cmake -G "Green Hills MULTI" -D GHS_PRIMARY_TARGET=ppc_integrity.tgt -D GHS_BSP_NAME=fsl-t1040 for fsl-t1040 on ppc_integrity.tgt.
Target Properties
New in version 3.14.- •
- GHS_INTEGRITY_APP
- •
- GHS_NO_SOURCE_GROUP_FILE
MULTI Project Variables
New in version 3.3.- •
- GHS_CUSTOMIZATION - CMake path name to Customization File.
- •
- GHS_GPJ_MACROS - CMake list of Macros.
This generator is deemed experimental as of
CMake 3.25.1 and is still a work in progress. Future versions of CMake may
make breaking changes as the generator matures.
Xcode
Generate Xcode project files.Toolset and Build System Selection
By default Xcode is allowed to select its own default toolchain. The CMAKE_GENERATOR_TOOLSET option may be set, perhaps via the cmake -T option, to specify another toolset.- •
- toolset
- •
- toolset[,key=value]*
- •
- key=value[,key=value]*
- buildsystem=<variant>
- Specify the buildsystem variant to use. See the CMAKE_XCODE_BUILD_SYSTEM variable for allowed values. For example, to select the original build system under Xcode 12, run cmake(1) with the option -T buildsystem=1.
Swift Support
New in version 3.4.Limitations
The Xcode generator does not support per-configuration sources. Code like the following will result in a generation error:add_executable(MyApp mymain-$<CONFIG>.cpp)
EXTRA GENERATORS
Some of the CMake Generators listed in the cmake(1) command-line tool --help output may have variants that specify an extra generator for an auxiliary IDE tool. Such generator names have the form <extra-generator> - <main-generator>. The following extra generators are known to CMake.CodeBlocks
Generates CodeBlocks project files.- CodeBlocks - MinGW Makefiles
- Generate with MinGW Makefiles.
- CodeBlocks - NMake Makefiles
- Generate with NMake Makefiles.
- CodeBlocks - NMake Makefiles JOM
- New in version 3.8: Generate with NMake Makefiles JOM.
- CodeBlocks - Ninja
- Generate with Ninja.
- CodeBlocks - Unix Makefiles
- Generate with Unix Makefiles.
CodeLite
Generates CodeLite project files.- CodeLite - MinGW Makefiles
- Generate with MinGW Makefiles.
- CodeLite - NMake Makefiles
- Generate with NMake Makefiles.
- CodeLite - Ninja
- Generate with Ninja.
- CodeLite - Unix Makefiles
- Generate with Unix Makefiles.
Eclipse CDT4
Generates Eclipse CDT 4.0 project files.- Eclipse CDT4 - MinGW Makefiles
- Generate with MinGW Makefiles.
- Eclipse CDT4 - NMake Makefiles
- Generate with NMake Makefiles.
- Eclipse CDT4 - Ninja
- Generate with Ninja.
- Eclipse CDT4 - Unix Makefiles
- Generate with Unix Makefiles.
Kate
Generates Kate project files.- Kate - MinGW Makefiles
- Generate with MinGW Makefiles.
- Kate - NMake Makefiles
- Generate with NMake Makefiles.
- Kate - Ninja
- Generate with Ninja.
- Kate - Unix Makefiles
- Generate with Unix Makefiles.
Sublime Text 2
Generates Sublime Text 2 project files.- Sublime Text 2 - MinGW Makefiles
- Generate with MinGW Makefiles.
- Sublime Text 2 - NMake Makefiles
- Generate with NMake Makefiles.
- Sublime Text 2 - Ninja
- Generate with Ninja.
- Sublime Text 2 - Unix Makefiles
- Generate with Unix Makefiles.
COPYRIGHT
2000-2022 Kitware, Inc. and ContributorsNovember 30, 2022 | 3.25.1 |