[Polly] Don't redundantly link libPolly into unittests.

With LLVM_LINK_LLVM_DYLIB and LLVM_POLLY_LINK_INTO_TOOLS, Polly is
already linked into libLLVM.so, linking libPolly.a as well into
unittests results in duplicate command line registration errors.

GitOrigin-RevId: cdbc86dd225063beb9fc8f6ba1f09afc18435331
diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt
index fac7038..94b7544 100644
--- a/unittests/CMakeLists.txt
+++ b/unittests/CMakeLists.txt
@@ -16,7 +16,13 @@
 
     set_property(TARGET ${test_name} PROPERTY FOLDER "Polly")
   endif()
-  target_link_libraries(${test_name} PRIVATE Polly)
+
+  if(LLVM_LINK_LLVM_DYLIB AND LLVM_POLLY_LINK_INTO_TOOLS)
+    # In this case Polly is already present in libLLVM,
+    # no need to link it again.
+  else()
+    target_link_libraries(${test_name} PRIVATE Polly)
+  endif()
 endfunction()
 
 add_subdirectory(Isl)