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 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 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 (comma

[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