cmake: how to use libtorch in my project

I want to use libtorch in my project.

The libtorch release the debug/release version:

Download here (Release version):
Download here (Debug version):

Both debug/release contain a cmake file. I can seperately use libtorch by provide the libtorch_dir as: libtorch_debug/xx/TorchConfig.cmake or libtorch_release/xx/TorchConfig.cmake.

However, in this way, if I want to switch debug to release in vs, I need to cmake again.

Is it possible to cmake once and switch vs from debug to release?

Any suggestion is appreciated~~~

When the configuration file changes like that, there’s no way to support it with a single configure. There needs to be a single TorchConfig.cmake file which makes both the release and debug builds available (as configuration-specific property values).