Posted on

Mastering Cmake 6th Edition Pdf 🔛


Mastering Cmake 6th Edition Pdf

for a target containing a custom command defined in a cmakelists.txt file, you can use target.command to define the command string in the cmakelists.txt that will be used by cmake to execute the command (provided that the command supports a command name). using add_custom_target to add a new command also provides properties that are relevant to the target, for example, to allow the output of the command to be copied.

the add_custom_target command sets a property that returns the custom command’s executable name to the target.command property, so you can use the toolchain to specify the name of the custom command in a custom_target property, for example:

some commands don’t have an executable name. for example, the make_directory command is intended to be used as a convenience wrapper around mkdir -p. in this case, you can just supply a command name without a call to add_custom_target, which sets the command property of the command object. this method doesn’t provide properties set by add_custom_target.

if you want to add a command with a given command name (specified by name in the call to add_custom_target), there is a handy convenience function (the target.create command) that allows you to create a command with a name that’s set in a single-expression cmakelists.txt file, e.g. to add a custom command by just specifying the name of the command.

the add_custom_target command is useful for supporting a single command with several different properties, for example to execute two different target build types, in two different flavors (debug vs. non-debug), with support for the vs2010 build type, or for new platforms like arm.