Main Content

target.CMake Class

Namespace: target

Specify CMake installation for building generated code

Since R2022b

Description

Use a target.CMake object when you want to define a toolchain that uses a specific CMake installation instead of the version that ships with the software.

To create a target.CMake object, use the target.create function.

Properties

expand all

Optional. Version of the CMake tool.

Attributes:

GetAccess
public
SetAccess
public

An object that describes the full path to the CMake executable file.

Attributes:

GetAccess
public
SetAccess
public

An object that gives the platforms that the CMake installation can run on.

Attributes:

GetAccess
public
SetAccess
public

Optional. An object that gives the target devices that the CMake installation can build code for. If the property is empty, it is treated as a wildcard.

Attributes:

GetAccess
public
SetAccess
public

A unique name for your CMake tool installation.

Example: 'CMake with Third-Party Customizations'

Attributes:

GetAccess
public
SetAccess
public

Examples

collapse all

This code snippet shows how you can use the Tools property of the target.Toolchain object and a target.CMake object to specify your CMake installation.

tc = target.create('Toolchain', 'Name', 'CMake/Ninja for all hosts');
tc.Builder = target.create('CMakeBuilder');
tc.Builder.Generator = 'Ninja';
tc.Builder.CommandLineCacheEntries(end+1) = ...
   target.create('CMakeCacheEntry', 'Name', 'CMAKE_C_COMPILER', 'Value', 'gcc');
tc.Builder.CommandLineCacheEntries(end+1) = ...
   target.create('CMakeCacheEntry', 'Name', 'CMAKE_CXX_COMPILER', 'Value', 'g++');


tc.Tools = target.create('CMake', 'Name', 'My CMake')
tc.Tools(1).Command.String = 'C:\pathToMyCMakeInstallation\cmake.exe'

Version History

Introduced in R2022b