DrPepperJo
DrPepperJo

Reputation: 722

CMake and access name of special targets

Is it possible to access the special targets (e.g. ALL_BUILD, INSTALL, RUN_TESTS, ZERO_CHECK) by some name to call commands like add_property() or add_custom_command() on them in CMake?

Use-cases for this pop up all the time in my code (e.g. running a target that is not part of ALL_BUILD when INSTALL is called).

Upvotes: 2

Views: 88

Answers (1)

No, unfortunately it is not possible to refer to the pre-defined targets from within CMake code. Workarounds may exist for specific things you need to do, but the general answer is no.

For the specific case you mention (building a target when building INSTALL), you might have luck with something like this:

install(CODE "EXECUTE_PROCESS(${CMAKE_COMMAND} --build other_args_here)")

Upvotes: 4

Related Questions