I could build the libs both MT and MD using the normal cmake way(setup.py build --cmake-only). but
I’m getting lots of linker errors when I run that script like  this :
cd tools
set BUILD_SHARED_LIBS=OFF
for /f "usebackq tokens=*" %i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -version [15^,16^) -products * -latest -property installationPath`) do call "%i\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=14.27
python build_libtorch.py

linker errors :
torch_cpu.lib(conv_dnnlowp_op.cc.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl fbgemm::PackWeightMatrixForGConv<signed char,int,3>::PackWeightMatrixForGConv<signed char,int,3>(enum fbgemm::matrix_op_t,struct fbgemm::conv_param_t<3> const &,signed char const *,signed char *)" (__imp_??0?$PackWeightMatrixForGConv@CH$02@fbgemm@@QEAA@W4matrix_op_t@1@AEBU?$conv_param_t@$02@1@PEBCPEAC@Z)
torch_cpu.lib(fbgemm_pack_op.cc.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl fbgemm::PackWeightMatrixForGConv<signed char,int,3>::~PackWeightMatrixForGConv<signed char,int,3>(void)" (__imp_??1?$PackWeightMatrixForGConv@CH$02@fbgemm@@QEAA@XZ) referenced in function "public: __cdecl std::_Temporary_owner<class fbgemm::PackWeightMatrixForGConv<signed char,int,3> >::~_Temporary_owner<class fbgemm::PackWeightMatrixForGConv<signed char,int,3> >(void)" (??1?$_Temporary_owner@V?$PackWeightMatrixForGConv@CH$02@fbgemm@@@std@@QEAA@XZ)
torch_cpu.lib(conv_dnnlowp_op.cc.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl fbgemm::PackWeightMatrixForGConv<signed char,int,3>::~PackWeightMatrixForGConv<signed char,int,3>(void)" (__imp_??1?$PackWeightMatrixForGConv@CH$02@fbgemm@@QEAA@XZ)
torch_cpu.lib(dnnlowp.cc.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl fbgemm::ChooseRequantizationMultiplier(float,int *,int *,int)" (__imp_?ChooseRequantizationMultiplier@fbgemm@@YAXMPEAH0H@Z) referenced in function "public: struct fbgemm::RequantizationParams __cdecl dnnlowp::QuantizationFactory::ChooseRequantizationMultiplier(float,struct fbgemm::TensorQuantizationParams)const " (?ChooseRequantizationMultiplier@QuantizationFactory@dnnlowp@@QEBA?AURequantizationParams@fbgemm@@MUTensorQuantizationParams@4@@Z)
torch_cpu.lib(conv_dnnlowp_op.cc.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl fbgemm::row_offsets_u8acc32_ref(int,int,int,unsigned char const *,int *)" (__imp_?row_offsets_u8acc32_ref@fbgemm@@YAXHHHPEBEPEAH@Z) referenced in function "protected: void __cdecl caffe2::ConvDNNLowPOp<unsigned char,1>::RunOnDeviceEpilogueNHWC_$omp$1(unsigned char const *,int *)" (?RunOnDeviceEpilogueNHWC_$omp$1@?$ConvDNNLowPOp@E$00@caffe2@@IEAAXPEBEPEAH@Z)
torch_cpu.lib(conv_dnnlowp_op.cc.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl fbgemm::depthwise_3x3x3_per_channel_quantization_pad_1<int>(int,int,int,int,int,int,int,int,int,unsigned char const *,int const *,class fbgemm::PackedDepthWiseConvMatrix const &,float const *,int,unsigned char *,int const *,int const *,bool,float const *,int,int)" (__imp_??$depthwise_3x3x3_per_channel_quantization_pad_1@H@fbgemm@@YAXHHHHHHHHHPEBEPEBHAEBVPackedDepthWiseConvMatrix@0@PEBMHPEAE11_N3HH@Z) referenced in function "private: void __cdecl caffe2::ConvDNNLowPOp<unsigned char,1>::ConvNHWCCore_$omp$1(unsigned char const *,class std::vector<int,class std::allocator<int> > *)" (?ConvNHWCCore_$omp$1@?$ConvDNNLowPOp@E$00@caffe2@@AEAAXPEBEPEAV?$vector@HV?$allocator@H@std@@@std@@@Z)
torch_cpu.lib(conv_dnnlowp_op.cc.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl fbgemm::depthwise_3x3x3_pad_1<int>(int,int,int,int,int,int,int,int,int,unsigned char const *,int,class fbgemm::PackedDepthWiseConvMatrix const &,float,int,unsigned char *,int const *,int const *,bool,float,int,int)" (__imp_??$depthwise_3x3x3_pad_1@H@fbgemm@@YAXHHHHHHHHHPEBEHAEBVPackedDepthWiseConvMatrix@0@MHPEAEPEBH3_NMHH@Z) referenced in function "private: void __cdecl caffe2::ConvDNNLowPOp<unsigned char,1>::ConvNHWCCore_$omp$1(unsigned char const *,class std::vector<int,class std::allocator<int> > *)" (?ConvNHWCCore_$omp$1@?$ConvDNNLowPOp@E$00@caffe2@@AEAAXPEBEPEAV?$vector@HV?$allocator@H@std@@@std@@@Z)
torch_cpu.lib(conv_dnnlowp_op.cc.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl fbgemm::depthwise_2d_per_channel_quantization_same_pad<int>(int,int,int,int,int,int,int,unsigned char const *,int const *,class fbgemm::PackedDepthWiseConvMatrix const &,float const *,int,unsigned char *,int const *,int const *,bool,float const *,int,int)" (__imp_??$depthwise_2d_per_channel_quantization_same_pad@H@fbgemm@@YAXHHHHHHHPEBEPEBHAEBVPackedDepthWiseConvMatrix@0@PEBMHPEAE11_N3HH@Z) referenced in function "private: void __cdecl caffe2::ConvDNNLowPOp<unsigned char,1>::ConvNHWCCore_$omp$2(unsigned char const *,class std::vector<int,class std::allocator<int> > *)" (?ConvNHWCCore_$omp$2@?$ConvDNNLowPOp@E$00@caffe2@@AEAAXPEBEPEAV?$vector@HV?$allocator@H@std@@@std@@@Z)
torch_cpu.lib(conv_dnnlowp_op.cc.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl fbgemm::depthwise_2d_same_pad<int>(int,int,int,int,int,int,int,unsigned char const *,int,class fbgemm::PackedDepthWiseConvMatrix const &,float,int,unsigned char *,int const *,int const *,bool,float,int,int)" (__imp_??$depthwise_2d_same_pad@H@fbgemm@@YAXHHHHHHHPEBEHAEBVPackedDepthWiseConvMatrix@0@MHPEAEPEBH3_NMHH@Z) referenced in function "private: void __cdecl caffe2::ConvDNNLowPOp<unsigned char,1>::ConvNHWCCore_$omp$2(unsigned char const *,class std::vector<int,class std::allocator<int> > *)" (?ConvNHWCCore_$omp$2@?$ConvDNNLowPOp@E$00@caffe2@@AEAAXPEBEPEAV?$vector@HV?$allocator@H@std@@@std@@@Z)
....

I couldnt set DISTUTILS_USE_SDK=1 as doing so would result in the following error :
D:\Codes\pytorch-1.6.0\tools>python build_libtorch.py
cmake -GNinja -DBUILD_PYTHON=False -DBUILD_SHARED_LIBS=OFF -DBUILD_TEST=True -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=D:\Codes\pytorch-1.6.0\torch -DCMAKE_PREFIX_PATH=C:\Users\User\Anaconda3\Lib\site-packages -DNUMPY_INCLUDE_DIR=C:\Users\User\Anaconda3\Lib\site-packages\numpy\core\include -DPYTHON_EXECUTABLE=C:\Users\User\Anaconda3\python.exe -DPYTHON_INCLUDE_DIR=C:\Users\User\Anaconda3\include -DUSE_NUMPY=True D:\Codes\pytorch-1.6.0
CMake Error at C:/Users/User/Anaconda3/Library/share/cmake-3.17/Modules/CMakeDetermineCXXCompiler.cmake:48 (message):
  Could not find compiler set in environment variable CXX:

  cl.

Call Stack (most recent call first):
  CMakeLists.txt:23 (project)


CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "D:/Codes/pytorch-1.6.0/tools/build/CMakeFiles/CMakeOutput.log".
See also "D:/Codes/pytorch-1.6.0/tools/build/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
  File "build_libtorch.py", line 23, in <module>
    rerun_cmake=True, cmake_only=False, cmake=CMake())
  File "D:\Codes\pytorch-1.6.0\tools\build_pytorch_libs.py", line 59, in build_caffe2
    rerun_cmake)
  File "D:\Codes\pytorch-1.6.0\tools\setup_helpers\cmake.py", line 329, in generate
    self.run(args, env=my_env)
  File "D:\Codes\pytorch-1.6.0\tools\setup_helpers\cmake.py", line 141, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "C:\Users\User\Anaconda3\Lib\subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '-GNinja', '-DBUILD_PYTHON=False', '-DBUILD_SHARED_LIBS=OFF', '-DBUILD_TEST=True', '-DCMAKE_BUILD_TYPE=Release', '-DCMAKE_INSTALL_PREFIX=D:\\Codes\\pytorch-1.6.0\\torch', '-DCMAKE_PREFIX_PATH=C:\\Users\\User\\Anaconda3\\Lib\\site-packages', '-DNUMPY_INCLUDE_DIR=C:\\Users\\User\\Anaconda3\\Lib\\site-packages\\numpy\\core\\include', '-DPYTHON_EXECUTABLE=C:\\Users\\User\\Anaconda3\\python.exe', '-DPYTHON_INCLUDE_DIR=C:\\Users\\User\\Anaconda3\\include', '-DUSE_NUMPY=True', 'D:\\Codes\\pytorch-1.6.0']' returned non-zero exit status 1.


what am I missing here?
could you kindly point that out?