IMPORTED_LOCATION not set for imported target "opencv_core".

I’m cross-compiling a Linux library for ARM using dockcross and linking to OpenCV. OpenCV builds and installs successfully, but configuring my library gives me errors like this:

CMake Error in build/_deps/mylib-src/CMakeLists.txt:
      IMPORTED_LOCATION not set for imported target "opencv_core"

I’m finding the OpenCV package like this:

find_package( OpenCV REQUIRED )

And linking like this:

target_link_libraries( ${PROJECT_NAME} ${OpenCV_LIBS})

I didn’t find the documentation for IMPORTED_LOCATION very helpful. What does this error mean, and how do I fix it?

This worked:

set_target_properties(opencv_core PROPERTIES IMPORTED_LOCATION ${CMAKE_SYSROOT}/usr/local/lib/libopencv_core.so)

But I still don’t know why I needed it…

It seems like a botched install. Is there anything under the OpenCV install prefix that sets IMPORTED_LOCATION?

Did you ever figure this out? I’m having the same problem with current latest OpenCV.

I think it may be because I created a static build of OpenCV that is installed into a target directory. I’ve read somewhere that static builds can only be used from the source tree. Is that possible?