CMake: ensure that all libraries are linked once and not two times (as
was done with ctemplate and pthread).