foreach(FLAG_VAR
        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)
