Alexander Vassilev
Alexander Vassilev

Reputation: 1439

Optional targets in Cmake

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

Upvotes: 6

Views: 4310

Answers (2)

Martin
Martin

Reputation: 1381

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.

Upvotes: 11

arrowd
arrowd

Reputation: 34401

Take a look at add_custom_target() command.

Upvotes: 0

Related Questions