--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -84,11 +84,15 @@ set(SOURCE_FILES
 source_group(include FILES ${INCLUDE_FILES})
 source_group(source FILES ${SOURCE_FILES})
 
-add_library(enet STATIC
+if(MSVC AND BUILD_SHARED_LIBS)
+    add_definitions(-DENET_DLL)
+    add_definitions(-DENET_BUILDING_LIB)
+endif()
+add_library(enet
     ${INCLUDE_FILES}
     ${SOURCE_FILES}
 )
 
-if (MINGW)
+if(WIN32)
     target_link_libraries(enet winmm ws2_32)
 endif()
