diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 51e8478f6..ebdc85bed 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -182,7 +182,11 @@ else (protobuf_BUILD_SHARED_LIBS) # making programmatic control difficult. Prefer the functionality in newer # CMake versions when available. if(CMAKE_VERSION VERSION_GREATER 3.15 OR CMAKE_VERSION VERSION_EQUAL 3.15) - set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$:Debug>) + if (protobuf_MSVC_STATIC_RUNTIME) + set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$:Debug>) + else() + set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$:Debug>DLL) + endif() else() # In case we are building static libraries, link also the runtime library statically # so that MSVCR*.DLL is not required at runtime.