Using FetchContent_Declare in CMake to pull LibTorch

As the title says, I am trying to use FetchContent_Declare in the CMakeLists.txt, in order to download LibTroch directly, without further “manual” configuration on Windows.
So, in order to do this, I copied the example in the documentation and changed the CMakeLists.txt file to the following:

cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
project(exampleApp)

# Set the C++ standard
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)

include(FetchContent)

FetchContent_Declare(
        Torch
        URL https://download.pytorch.org/libtorch/cpu/libtorch-win-shared-with-deps-2.0.0%2Bcpu.zip
        # URL https://download.pytorch.org/libtorch/cpu/libtorch-win-shared-with-deps-debug-2.0.0%2Bcpu.zip
        # OVERRIDE_FIND_PACKAGE
)
FetchContent_MakeAvailable(Torch)
list(APPEND CMAKE_PREFIX_PATH "${torch_SOURCE_DIR}")

find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")

add_executable(exampleApp main.cpp)
target_link_libraries(exampleApp "${TORCH_LIBRARIES}")
set_property(TARGET exampleApp PROPERTY CXX_STANDARD 14)

# The following code block is suggested to be used on Windows.
# According to https://github.com/pytorch/pytorch/issues/25457,
# the DLLs need to be copied to avoid memory errors.
if (MSVC)
    file(GLOB TORCH_DLLS "${TORCH_INSTALL_PREFIX}/lib/*.dll")
    add_custom_command(TARGET exampleApp
            POST_BUILD
            COMMAND ${CMAKE_COMMAND} -E copy_if_different
            ${TORCH_DLLS}
            $<TARGET_FILE_DIR:exampleApp>)
endif (MSVC)

cmake appears to run without any issue, but when compiling, I am getting the following errors:

And the following errors when compiling:

CLionProjects\untitled\cmake-build-release-visual-studio\_deps\torch-src\include\c10/util/safe_numerics.h(26): error C3861: '_addcarry_u64': identifier not found

Any idea what how to fix this?

PS: I know about the OVERRIDE_FIND_PACKAGE flag, but couldn’t get cmake to work with it.

Edit: Just tried this CMakeLists.txt file on linux and it worked perfectly.