[CMake] add_custom_command() OUTPUT does not accept generator expressions, why?

Brad King brad.king at kitware.com
Mon Mar 28 10:05:33 EDT 2016


On 03/27/2016 06:11 AM, Dan Liew wrote:
> OUTPUT does not accept generator expressions, why?

It hasn't been implemented.  At least at one time it would have been
very hard to implement.  I'm not sure now because there has been a lot
of refactoring since I last looked at it.

There is some discussion here:

 https://cmake.org/Bug/view.php?id=13840
 https://cmake.org/Bug/view.php?id=12877#c28315

> If I can't use generator expressions with ``OUTPUT``, how am I
> supposed to output a file into the build directory of a target?

Unfortunately it is not possible to do cleanly without fixing the
above.  Approximations include:

* Use a POST_BUILD command on the target instead.

* Make the OUTPUT a timestamp file and generate the real output
  as a side effect.

If anyone is interested in trying to implement generator expressions
for custom command outputs, I can provide more details to get started.

-Brad



More information about the CMake mailing list