[CMake] copy_if_different on build
Skippy VonDrake
skippyvondrake at gmail.com
Tue Apr 23 16:00:16 EDT 2013
> Hmm... that is odd. I think there may be something else going on in your
> project that is not obvious from the above information. I wrote a quick
> example along the lines of what you show, and it worked fine for me. Actual
> CMakeLists.txt I used is attached. (The foo.c can contain any compiling
> code, and foo.cfg.in can contain anything or even be empty.)
>
> (Apparently a disadvantage of just using add_custom_target is that it always
> runs, regardless of the DEPENDS. Not that this should be a huge problem,
> though.)
>
> Have you tried naming the input/output like
> "${CMAKE_CURRENT_SOURCE_DIR}/name.in" and
> "${CMAKE_CURRENT_BINARY_DIR}/name"? (I didn't do that in the attached
> example because I was lazy (and the example may only work for in-source
> builds as a result), but that is how I would recommend naming the files in a
> real project.)
The source of my problem was 'naming'. I did use the CMake 'SOURCE_DIR'
variable but my file extensions were wrong and my path was off by one level!
Everything works fine now.
> (Incidentally, this tickles a ninja generator bug in CMake < 2.8.11.)
Don't know about that bug. I did notice an effect I didn't expect - when
'make clean' is run the 'output' is deleted. Hadn't thought about that...
Thanks for your help and patience!
-Skippy
More information about the CMake
mailing list