Is there a way to specify optional targets in CMake? I mean ones that are built only when one specifies them explicitly, for example by make <target>
, and are not built when you specify just make
? I know I can do this with add_custom_command(), but I need all the features that a normal build target has
In general, targets comprise executables or libraries which are defined by calling add_executable or add_library and which can have many properties set. They can have dependencies on one another, which for targets such as these just means that dependent ones will be built after their dependencies.
set_target_properties(target1 target2 ... PROPERTIES prop1 value1 prop2 value2 ...) Sets properties on targets. The syntax for the command is to list all the targets you want to change, and then provide the values you want to set next.
A build target is a string that identifies a build rule in your project. Build targets are used as arguments to Buck commands, such as buck build and buck run . Build targets are also used as arguments to build rules to enable one build rule to reference another.
An IMPORTED executable target references an executable file located outside the project. No rules are generated to build it, and the IMPORTED target property is True . The target name has scope in the directory in which it is created and below, but the GLOBAL option extends visibility.
There is no need to use add_custom_target. You can simply specify EXCLUDE_FROM_ALL, when specifying the build rule for an executable via add_executable. The same applies to add_library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With