aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmake/msvc_static_runtime.cmake
blob: fc6d1d62d32925e3f59bd30fe14c4e513116cae6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
option(gRPC_MSVC_STATIC_RUNTIME "Link with static msvc runtime libraries" OFF)

if(gRPC_MSVC_STATIC_RUNTIME)
  # switch from dynamic to static linking of msvcrt
  foreach(flag_var
    CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
    CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
    CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
    CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)

    if(${flag_var} MATCHES "/MD")
    string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
    endif(${flag_var} MATCHES "/MD")
  endforeach(flag_var)
endif()