dont force msvc /Ox flag which can conflict with /RTC1 in debug config (#33164)

Summary:
Relates to https://github.com/pytorch/pytorch/issues/33132

This fix doesn't add full multi-configuration support described in https://github.com/pytorch/pytorch/issues/33132 but at least avoid the error presented in the issue when `CMAKE_BUILD_TYPE=Debug` is used with MSVC.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33164

Differential Revision: D19899727

Pulled By: ezyang

fbshipit-source-id: 28a364d920c4a3fb577c6b484ccd69a133fbcf5d
This commit is contained in:
Francis Charette Migneault 2020-02-13 22:13:38 -08:00 committed by Facebook Github Bot
parent 602aec325d
commit 0150f40dde
2 changed files with 15 additions and 11 deletions

View File

@ -53,16 +53,14 @@ install(FILES ${CMAKE_BINARY_DIR}/caffe2/core/macros.h
# ---[ ATen specific # ---[ ATen specific
if (INTERN_BUILD_ATEN_OPS) if (INTERN_BUILD_ATEN_OPS)
SET(OPT_FLAG "-O3 ")
IF(MSVC) IF(MSVC)
SET(OPT_FLAG "/Ox /fp:strict ") SET(OPT_FLAG "/fp:strict ")
ENDIF() ELSE(MSVC)
SET(VCOMP_LIB "vcomp") SET(OPT_FLAG "-O3 ")
IF("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
IF("${CMAKE_BUILD_TYPE}" MATCHES "Debug") SET(OPT_FLAG " ")
SET(OPT_FLAG " ") ENDIF()
SET(VCOMP_LIB "vcompd") ENDIF(MSVC)
ENDIF()
IF(C_AVX_FOUND) IF(C_AVX_FOUND)
IF(MSVC) IF(MSVC)

View File

@ -305,8 +305,14 @@ endfunction()
# torch_set_target_props(lib_name) # torch_set_target_props(lib_name)
function(torch_set_target_props libname) function(torch_set_target_props libname)
if(MSVC AND AT_MKL_MT) if(MSVC AND AT_MKL_MT)
set(VCOMP_LIB "vcomp")
set_target_properties(${libname} PROPERTIES LINK_FLAGS_MINSIZEREL "/NODEFAULTLIB:${VCOMP_LIB}")
set_target_properties(${libname} PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/NODEFAULTLIB:${VCOMP_LIB}")
set_target_properties(${libname} PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB:${VCOMP_LIB}") set_target_properties(${libname} PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB:${VCOMP_LIB}")
set_target_properties(${libname} PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB:${VCOMP_LIB}") set_target_properties(${libname} PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB:${VCOMP_LIB}d")
set_target_properties(${libname} PROPERTIES STATIC_LIBRARY_FLAGS "/NODEFAULTLIB:${VCOMP_LIB}") set_target_properties(${libname} PROPERTIES STATIC_LIBRARY_FLAGS_MINSIZEREL "/NODEFAULTLIB:${VCOMP_LIB}")
set_target_properties(${libname} PROPERTIES STATIC_LIBRARY_FLAGS_RELWITHDEBINFO "/NODEFAULTLIB:${VCOMP_LIB}")
set_target_properties(${libname} PROPERTIES STATIC_LIBRARY_FLAGS_RELEASE "/NODEFAULTLIB:${VCOMP_LIB}")
set_target_properties(${libname} PROPERTIES STATIC_LIBRARY_FLAGS_DEBUG "/NODEFAULTLIB:${VCOMP_LIB}d")
endif() endif()
endfunction() endfunction()