Issue #48724. Only set the CMake IMPORTED_LOCATION property in static… (#49173)
Summary:
… library builds, as it is already set in shared library builds from the target that was imported from Caffe2.
This was identified on Windows builds when PyTorch was built in shared Release mode, and a testapp was built with RelWithDebInfo in CMake.
The problem appeared to be that because IMPORTED_LOCATION (in TorchConfig.cmake) and IMPORTED_LOCATION_RELEASE were both set (in Caffe2Targets.cmake), there occurred some confusion in the build as to what was correct. The symptoms are the error:
ninja: error: 'torch-NOTFOUND', needed by 'test_pytorch.exe', missing and no known rule to make it
in a noddy consuming test application.
Fixes https://github.com/pytorch/pytorch/issues/48724
Pull Request resolved: https://github.com/pytorch/pytorch/pull/49173
Reviewed By: malfet
Differential Revision: D25974151
Pulled By: ezyang
fbshipit-source-id: 3454c0d29cbbe7a37608beedaae3efbb624b0479