[CMake] Concurrency issues with copy_if_different

Olivier Croquette ocroquette at free.fr
Sat Dec 8 05:43:35 EST 2018


On 2018-7-12 15:16, J. Caleb Wherry wrote:
>> in one of our projects, we use copy_if_different to copy some DLLs
>> required by the runtime. It's called as post-build action. The problem
>> is that several targets want to copy the same DLLs, and when using
>> parallelized builds, the different "cmake -E copy_if_different" can
>> conflict, leading the whole build to fail.
>>
>> I see two options to fix this:
>>
>> 1. don't use copy_if_different, but a custom tool that can deal with the
>> concurrency
>>
>> 2. instead of adding post-build actions to different targets, fill up a
>> list containing all the files required, and add a single post-build
>> action to a single target that copies all the required files in one go
>>
>> What do you think?
> Had the same problem and went with #2

Hi Caleb,

could you give some more details how you did this? Filling up the list 
is easy, but I am not sure how to define the final action that will copy 
all the DLLs, and make sure it happens only once. Did you define a new 
custom target for that?




More information about the CMake mailing list