Are you using the Release or the Debug version? You could try the following commands.
pip install ninja
# Activate the VC environment
for /f "usebackq tokens=*" %i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -version [15^,17^) -products * -latest -property installationPath`) do call "%i\VC\Auxiliary\Build\vcvarsall.bat" x64
set CC=cl.exe
set CXX=cl.exe
cmake -GNinja  -DCMAKE_PREFIX_PATH=c:\hp\desktop\libtorch -DCMAKE_BUILD_TYPE=Release ..