--- ldc-0.14.0/runtime/CMakeLists.txt	2014-08-16 06:55:50.000000000 +0000
+++ ldc-0.14.0.mine/runtime/CMakeLists.txt	2014-08-20 08:55:17.089722062 +0000
@@ -12,7 +12,7 @@
 set(BUILD_BC_LIBS         OFF                                       CACHE BOOL    "Build the runtime as LLVM bitcode libraries")
 set(LIB_SUFFIX            ""                                        CACHE STRING  "'64' to install libraries into ${PREFIX}/lib64")
 set(INCLUDE_INSTALL_DIR   ${CMAKE_INSTALL_PREFIX}/include/d         CACHE PATH    "Path to install D modules to")
-set(BUILD_SHARED_LIBS     OFF                                       CACHE BOOL    "Whether to build the runtime as a shared library (*UNSUPPORTED*)")
+set(BUILD_SHARED_LIBS     ${BUILD_SHARED_LIBS}                      CACHE BOOL    "Whether to build the runtime as a shared library (*UNSUPPORTED*)")
 set(D_FLAGS               -w;-d                                     CACHE STRING  "Runtime build flags, separated by ;")
 set(D_FLAGS_DEBUG         -g                                        CACHE STRING  "Runtime build flags (debug libraries), separated by ;")
 set(D_FLAGS_RELEASE       -O3;-release                              CACHE STRING  "Runtime build flags (release libraries), separated by ;")
@@ -209,7 +209,7 @@
 # due to incompatible switches.
 if(NOT MSVC)
     set(cfiles "${CORE_C};${DCRT_C}")
-    if(PHOBOS2_DIR)
+    if(PHOBOS2_DIR AND NOT BUILD_SHARED_LIBS)
         list(APPEND cfiles "${ZLIB_C}")
     endif()
     set_source_files_properties(${cfiles} PROPERTIES
@@ -389,8 +389,12 @@
         set(phobos2_o "")
         set(phobos2_bc "")
         compile_phobos2("${d_flags}" "${lib_suffix}" "${path_suffix}" phobos2_o phobos2_bc)
-
-        add_library(phobos2-ldc${target_suffix} ${D_LIBRARY_TYPE} ${ZLIB_C} ${phobos2_o})
+	
+        if(NOT BUILD_SHARED_LIBS)
+            add_library(phobos2-ldc${target_suffix} ${D_LIBRARY_TYPE} ${ZLIB_C} ${phobos2_o})
+        else()
+            add_library(phobos2-ldc${target_suffix} ${D_LIBRARY_TYPE} ${phobos2_o})
+        endif()
         set_target_properties(
             phobos2-ldc${target_suffix} PROPERTIES
             OUTPUT_NAME                 phobos2-ldc${lib_suffix}
@@ -408,7 +412,7 @@
             # TODO: As for druntime, adapt once shared libraries are supported
             # on more operating systems.
             target_link_libraries(phobos2-ldc${target_suffix}
-                druntime-ldc${target_suffix} "curl" "m" "pthread" "dl")
+                druntime-ldc${target_suffix} "z" "curl" "m" "pthread" "dl")
         endif()
 
         list(APPEND ${outlist_targets} "phobos2-ldc${target_suffix}")

