Commit 9bdeba47 authored by Jan Tattermusch's avatar Jan Tattermusch

only link runtime libraries statically for a static build

parent 1858ac9b
...@@ -43,10 +43,9 @@ endif (HAVE_ZLIB) ...@@ -43,10 +43,9 @@ endif (HAVE_ZLIB)
if (MSVC) if (MSVC)
if (BUILD_SHARED_LIBS) if (BUILD_SHARED_LIBS)
add_definitions(-DPROTOBUF_USE_DLLS) add_definitions(-DPROTOBUF_USE_DLLS)
endif (BUILD_SHARED_LIBS) else (BUILD_SHARED_LIBS)
add_definitions(/wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305) # In case we are building static libraries, link also the runtime library statically
# so that MSVCR*.DLL is not required at runtime.
# Link runtime library statically so that MSVCR*.DLL is not required at runtime.
# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
# This is achieved by replacing msvc option /MD with /MT and /MDd with /MTd # This is achieved by replacing msvc option /MD with /MT and /MDd with /MTd
# http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F # http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
...@@ -57,6 +56,8 @@ if (MSVC) ...@@ -57,6 +56,8 @@ if (MSVC)
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/MD") endif(${flag_var} MATCHES "/MD")
endforeach(flag_var) endforeach(flag_var)
endif (BUILD_SHARED_LIBS)
add_definitions(/wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305)
endif (MSVC) endif (MSVC)
if (MSVC) if (MSVC)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment