cannot link to dynamic library correctly during parallel build

I met a compile fail problem, which is caused during parallel build. Please see this bug report for detail:
https://bugs.llvm.org/show_bug.cgi?id=46617

how can I fix this in CMakeList.txt? I have tried to explicitly change target_link_libraries to .so, but during parallel build, if .a is generated first, it is possbile that .a is used, and make the build fail, is this bug of cmake?

Thanks

Already posted here.