[CMake] Generate and install a file
Norton Allen
allen at huarp.harvard.edu
Thu Mar 28 16:38:33 EDT 2019
On 3/28/2019 4:12 PM, Kyle Edwards wrote:
> One more thing: if you want the custom target to be built by "make" or
> "make all", you have to give it the ALL argument:
>
> add_custom_target(mygeneratedtarget ALL
> DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mygeneratedfile
> )
>
> Otherwise you can build the target with "make mygeneratedtarget".
>
OK! That does make a difference. I had focused on the add_custom_target
documentation that indicated the rule was always considered out of date,
and jumped to the conclusion that that meant it was always run.
Thank you for sorting that out!
What I find surprising is that 'make install' could not identify how to
create mygeneratedfile. Is there some reason why 'mygeneratedfile'
cannot be a target in its own right with needing to refer to this phony
target to achieve the desired result?
Related to that, I noticed in another thread the mention of
'CMAKE_SKIP_INSTALL_ALL_DEPENDENCY'. If that were set in this case, how
could I indicate that install depends on mygeneratedtarget? (Admittedly,
I'm having a hard time coming up with a case where this would apply, but
I'm having trouble with the tenuous connection between the instruction
to install mygeneratedfile and the rule that actually generates it.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190328/9cee295a/attachment.html>
More information about the CMake
mailing list