Allow to build shared libraries if BUILD_SHARED_LIBS is enabled

Contributed-by: Richard Membarth <richard.membarth@uni-saarland.de>

git-svn-id: https://llvm.org/svn/llvm-project/polly/branches/release_36@231275 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 9625458..651aee6 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -49,6 +49,22 @@
   ${POLLY_PLUTO_FILES}
   )
 
+if (BUILD_SHARED_LIBS)
+  target_link_libraries(Polly
+    LLVMSupport
+    LLVMCore
+    LLVMScalarOpts
+    LLVMInstCombine
+    LLVMTransformUtils
+    LLVMAnalysis
+    LLVMipo
+    LLVMProfileData
+  )
+  link_directories(
+      ${LLVM_LIBRARY_DIR}
+  )
+endif()
+
 # Build a monolithic Polly.a and a thin module LLVMPolly.moduleext that links to
 # that static library.
 add_polly_loadable_module(LLVMPolly