What is the use of property IMPORTED_LOCATION on DLL platforms?

Hello,

According to the docs, IMPORTED_LOCATION should be set to the .dll part of the library. I have found that it is not necessary. However the DLL does need to be in an appropriate location such as ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE} at runtime. In that case, why are we advised to set IMPORTED_LOCATION?

1 Like

This is for IMPORTED targets, i.e. targets not built by current CMake project. So binaries are supposed to be elsewhere than current CMake filetree.

In your case, by a side effect, it works because you had copied the library inside CMake filetree.

But it seems more reasonable to set IMPORTED_LOCATION and not copied the library.

Hi Marc,

I tried deleting the DLLs from ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE} and the code which copied them from the imported library and then set the IMPORTED_LOCATION to the DLLs from the imported library, see the new script. It builds successfully but when I run the executable aten_libtorch.exe, I receive pop out System Error messages - The code execution cannot proceed because c10.dll/torch_cpu was not found. So what is the benefit of setting IMPORTED_LOCATION?