I want to use add_custom_command to generate a file. I know I can use add_custom_target to set the DEPENDS to invoke the command. But this will also create a target(like in visual studio, it will create a .vcxproj). I use another add_custom_command, and then set the DEPENDS but it does not work. Why? Which level dependency can invoke it?
Are there any methods to invoke the add_custom_command like make install invokes the install command .
The
add_custom_command()function corresponds to Makefile’s rule. It list commands which are needed to produce some file. If you wish to be able to run in frommakeinvocation, you should wrap it into `add_custom_target(tgt DEPENDS cmd), just as you said.So, there is no way to execute custom_command’s without creating custom_target’s for them.