--- a/libmariadb/CMakeLists.txt
+++ b/libmariadb/CMakeLists.txt
@@ -367,7 +367,7 @@ ELSE()
 ENDIF()
 
 
-IF((NOT WIN32) AND (CMAKE_VERSION VERSION_GREATER 2.8.7))
+IF(FALSE)
   # CREATE OBJECT LIBRARY 
   ADD_LIBRARY(mariadb_obj OBJECT ${LIBMARIADB_SOURCES})
   IF(UNIX)
@@ -393,27 +393,29 @@ IF(WIN32)
                    "FILE_DESCRIPTION:Dynamic lib for client/server communication")
 ENDIF()
 
-
+IF(NOT BUILD_SHARED_LIBS)
 ADD_LIBRARY(mariadbclient STATIC  ${MARIADB_OBJECTS} ${EMPTY_FILE})
 TARGET_LINK_LIBRARIES(mariadbclient ${SYSTEM_LIBS})
+ELSE()
 
 IF(UNIX)
   ADD_LIBRARY(libmariadb SHARED ${libmariadb_RC} ${MARIADB_OBJECTS} ${EMPTY_FILE})
   SET_TARGET_PROPERTIES(libmariadb PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
 ELSE()
-  ADD_LIBRARY(libmariadb SHARED ${libmariadb_RC} mariadbclient.def)
-  TARGET_LINK_LIBRARIES(libmariadb LINK_PRIVATE mariadbclient)
+  ADD_LIBRARY(libmariadb SHARED ${libmariadb_RC} ${MARIADB_OBJECTS} ${EMPTY_FILE} mariadbclient.def)
   SET_TARGET_PROPERTIES(libmariadb PROPERTIES LINKER_LANGUAGE C)
 ENDIF()
 
 TARGET_LINK_LIBRARIES(libmariadb LINK_PRIVATE ${SYSTEM_LIBS})
 
 SIGN_TARGET(libmariadb)
+ENDIF()
 
-IF(CMAKE_SIZEOF_VOID_P EQUAL 8 AND MSVC)
+IF(CMAKE_SIZEOF_VOID_P EQUAL 8 AND MSVC AND NOT BUILD_SHARED_LIBS)
   SET_TARGET_PROPERTIES(mariadbclient PROPERTIES STATIC_LIBRARY_FLAGS "/machine:x64")
 ENDIF()
 
+IF(BUILD_SHARED_LIBS)
 IF(CMAKE_SYSTEM_NAME MATCHES "Linux" OR
    CMAKE_SYSTEM_NAME MATCHES "kFreeBSD" OR
    CMAKE_SYSTEM_NAME MATCHES "GNU")
@@ -423,10 +425,14 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux" OR
   SET_TARGET_PROPERTIES(libmariadb PROPERTIES LINK_FLAGS "${CC_BINARY_DIR}/libmariadb/mariadbclient.def")
 ENDIF()
 
+ELSE()
 SET_TARGET_PROPERTIES(mariadbclient PROPERTIES IMPORTED_INTERFACE_LINK_LIBRARIES "${SYSTEM_LIBS}")
+ENDIF()
+IF(BUILD_SHARED_LIBS)
 SET_TARGET_PROPERTIES(libmariadb PROPERTIES IMPORTED_INTERFACE_LINK_LIBRARIES "${SYSTEM_LIBS}")
 
 SET_TARGET_PROPERTIES(libmariadb PROPERTIES PREFIX "")
+ENDIF()
 
 #
 # Installation
@@ -447,9 +453,11 @@ IF(WITH_MYSQLCOMPAT)
 ENDIF()
 
 
+IF(BUILD_SHARED_LIBS)
 SET_TARGET_PROPERTIES(libmariadb PROPERTIES VERSION
  ${CPACK_PACKAGE_VERSION_MAJOR}
  SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR})
+ELSE()
 
 IF(NOT WIN32)
   SET_TARGET_PROPERTIES(mariadbclient PROPERTIES OUTPUT_NAME "${LIBMARIADB_STATIC_NAME}")
@@ -457,10 +465,16 @@ ENDIF()
 
 INSTALL(TARGETS mariadbclient
           COMPONENT Development
-          DESTINATION ${INSTALL_LIBDIR})
+          RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+          LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+          ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ENDIF()
+IF(BUILD_SHARED_LIBS)
 INSTALL(TARGETS libmariadb
           COMPONENT SharedLibraries
-        DESTINATION ${INSTALL_LIBDIR})
+        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
 
 
 IF(MSVC)
@@ -469,3 +483,4 @@ IF(MSVC)
            CONFIGURATIONS Debug RelWithDebInfo
            COMPONENT Development)
 ENDIF()
+ENDIF()
