[CMake] adding a custom command with the file name as a target

2011-03-11 Thread Jim Newsome
I'd like to do something like add_custom_command, with the output file name as a target in the generated makefile. Is there an elegant way of doing this? The closest I've come is: add_executable (hello hello.c) add_custom_command(OUTPUT hello.bin COMMAND objcopy

Re: [CMake] adding a custom command with the file name as a target

2011-03-11 Thread Tyler
The target in the Makefile is created with the add_custom_target() call. So just change yours to: add_custom_target(hello.bin ALL DEPENDS hello.bin) hth, tyler On Fri, Mar 11, 2011 at 7:58 AM, Jim Newsome jnews...@cmu.edu wrote: I'd like to do something like add_custom_command, with the output

Re: [CMake] adding a custom command with the file name as a target

2011-03-11 Thread Jim Newsome
Unfortunately it seems that the target needs to have a different name from its dependencies. When building I get: make[2]: Circular CMakeFiles/hello.bin - hello.bin dependency dropped. Another workaround I thought of is to change the output filename to, e.g., _hello.bin and have a command in the

Re: [CMake] adding a custom command with the file name as a target

2011-03-11 Thread David Cole
On Fri, Mar 11, 2011 at 12:05 PM, Jim Newsome jnews...@cmu.edu wrote: Unfortunately it seems that the target needs to have a different name from its dependencies. When building I get: make[2]: Circular CMakeFiles/hello.bin - hello.bin dependency dropped. Another workaround I thought of is to

Re: [CMake] adding a custom command with the file name as a target

2011-03-11 Thread Michael Hertling
On 03/11/2011 08:00 PM, David Cole wrote: On Fri, Mar 11, 2011 at 12:05 PM, Jim Newsome jnews...@cmu.edu wrote: Unfortunately it seems that the target needs to have a different name from its dependencies. When building I get: make[2]: Circular CMakeFiles/hello.bin - hello.bin dependency

Re: [CMake] adding a custom command with the file name as a target

2011-03-11 Thread Jim Newsome
That doesn't quite work either. I get some errors about circular dependencies. Strangely, doing it this way hello.bin _does_ get built, but it gets built every time, even if 'hello' hasn't changed. I imagine this behavior could depend on the build system- I'm using GNU make 3.81. Here's what I

Re: [CMake] adding a custom command with the file name as a target

2011-03-11 Thread Michael Hertling
On 03/11/2011 09:41 PM, Jim Newsome wrote: That doesn't quite work either. I get some errors about circular dependencies. Strangely, doing it this way hello.bin _does_ get built, Yes, I can see these messages - not errors - too, but obviously, they don't prevent the hello.bin file from being