diff --git a/CMakeLists.txt b/CMakeLists.txt
index 316a8210..52a87c4a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -184,6 +184,10 @@ include_directories("include")
 include_directories("${CMAKE_CURRENT_BINARY_DIR}")
 add_definitions(-DHAVE_CONFIG_H)
 
+if(WIN32 AND NOT BUILD_SHARED_LIBS)
+    add_definitions(-DFLAC__NO_DLL)
+endif()
+
 if(MSVC)
     add_definitions(
         -D_CRT_SECURE_NO_WARNINGS
@@ -194,7 +198,6 @@ if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
 endif()
 
 add_subdirectory("src")
-add_subdirectory("microbench")
 if(BUILD_DOCS)
     add_subdirectory("doc")
 endif()
@@ -202,6 +205,7 @@ if(BUILD_EXAMPLES)
     add_subdirectory("examples")
 endif()
 if(BUILD_TESTING)
+    add_subdirectory("microbench")
     add_subdirectory("test")
 endif()
 
