Re: [CMake] Generate and install a file

2019-03-28 Thread Kyle Edwards via CMake
On Thu, 2019-03-28 at 16:38 -0400, Norton Allen wrote: > 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? There is no way to do this. C/C++ targets (e

Re: [CMake] Generate and install a file

2019-03-28 Thread Norton Allen
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 wi

Re: [CMake] Generate and install a file

2019-03-28 Thread Kyle Edwards via CMake
On Thu, 2019-03-28 at 16:07 -0400, Norton Allen wrote: > Kyle, > What you say makes sense, and I can even understand why > add_custom_target might do that, but I cannot get this to actually > work. Here is a minimal CMakeLists.txt. mysourcefile is just and > empty file. > I have these files in test

Re: [CMake] Generate and install a file

2019-03-28 Thread Norton Allen
On 3/28/2019 3:33 PM, Kyle Edwards wrote: Using the DEPENDS argument of add_custom_command() will do this. However, add_custom_command() on its own isn't enough to ensure that the file is generated before installation. You need to pair add_custom_command() with add_custom_target(). Example: a

Re: [CMake] Generate and install a file

2019-03-28 Thread Kyle Edwards via CMake
On Thu, 2019-03-28 at 15:26 -0400, Norton Allen wrote: > On 3/28/2019 3:11 PM, Kyle Edwards wrote: > > On Thu, 2019-03-28 at 14:58 -0400, Norton Allen wrote: > > > because mygeneratedfile is not a 'target', and I can't make it > > > into a target with add_custom_target() because that's talking > >

Re: [CMake] Generate and install a file

2019-03-28 Thread Norton Allen
On 3/28/2019 3:11 PM, Kyle Edwards wrote: On Thu, 2019-03-28 at 14:58 -0400, Norton Allen wrote: because mygeneratedfile is not a 'target', and I can't make it into a target with add_custom_target() because that's talking about something else entirely (commands that will be run unconditionall

Re: [CMake] Generate and install a file

2019-03-28 Thread Kyle Edwards via CMake
On Thu, 2019-03-28 at 14:58 -0400, Norton Allen wrote: > because mygeneratedfile is not a 'target', and I can't make it into a > target with add_custom_target() because that's talking about > something else entirely (commands that will be run unconditionally, > not based on dependencies) What exact

[CMake] Generate and install a file

2019-03-28 Thread Norton Allen
I have spent a few hours trying to solve what seems like a simple problem. I need to generate a file with some dependencies and install it. If I want cmake to figure out how to compile and link it, I can add_executable(mytarget mytarget.c) install(TARGETS mytarget DESTINATION bin) I also