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

Dan Liew dan at su-root.co.uk
Thu Mar 31 05:50:06 EDT 2016


Hi,

On 28 March 2016 at 15:05, Brad King <brad.king at kitware.com> wrote:
> 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.

Thanks for the info Brad. I wish I had time to look into this but I
don't so for now I'll just work around it.

Dan.


More information about the cmake-developers mailing list