[CMake] copy_if_different on build
Matthew Woehlke
matthew.woehlke at kitware.com
Wed Apr 24 18:19:35 EDT 2013
On 2013-04-23 16:00, Skippy VonDrake wrote:
>> 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.
Ah, good to hear :-). Thanks for letting us know.
> I did notice an effect I didn't expect - when
> 'make clean' is run the 'output' is deleted. Hadn't thought about that...
Well, yes, with the custom commend the output file is effectively a
build artifact, so of course it is deleted by clean :-).
--
Matthew
More information about the CMake
mailing list