Description
🚀 The feature, motivation and pitch
Currently on Windows the Release version (https://download.pytorch.org/libtorch/cu128/libtorch-win-shared-with-deps-2.7.1%2Bcu128.zip) and Debug version (https://download.pytorch.org/libtorch/cu128/libtorch-win-shared-with-deps-debug-2.7.1%2Bcu128.zip) are shipped separately, and there's no easy way to switch between Debug/Release, in cmake we have to set Torch_DIR
to point to either release or debug, and it's not possible to use any if else to make it work because for multi config generator like Visual Studio, whether to compile in release or debug is a build time decision instead of a cmake config time decision, yet we have to decide which libtorch to point to during cmake config time with the current setup, which means if we decided that we want to switch from release to debug, we will have to clear the build folder, adjust Torch_DIR
, redo cmake, and rebuild in order to switch, which is really cumbersome.
Ideally on Windows the Release version and Debug version should be shipped together, and then make use of IMPORTED_LOCATION_DEBUG
to point to the debug dlls and IMPORTED_LOCATION_RELEASE
to point to the release dlls. Instead of just IMPORTED_LOCATION
like we currently have in https://github.com/pytorch/pytorch/blob/main/cmake/TorchConfig.cmake.in#L159. Libraries installed by vcpkg (https://github.com/microsoft/vcpkg/) have this and when compiling our own application it automatically points to the debug dlls in debug mode and release dlls in release mode, and everything just works. For example, vcpkg install glm
, and then investigate the generated glmConfig we will see something like
set_target_properties(glm::glm PROPERTIES
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/glm.lib"
)
and
set_target_properties(glm::glm PROPERTIES
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/debug/lib/glm.lib"
)
Alternatives
No response
Additional context
No response
cc @peterjc123 @mszhanyi @skyline75489 @nbcsm @iremyux @Blackhex