Arun Arun - 1 year ago 142
C++ Question

could not find load file OpenCVModules.cmake

I'm doing this for the first time but couldn't get going with CMake find_package(OpenCV)

OpenCVModules.cmake is in the same folder as OpenCVConfig.cmake but for some reasons CMake configure fails with this error.

I'm on Windows using Visual Studio Express 2010, CMake v2.8.0 and OpenCV v2.4.9

CMake Error at D:/opencv/mybuild/install/x86/vc10/lib/OpenCVConfig.cmake:49 (include):
include could not find load file:

Call Stack (most recent call first):
CMakeLists.txt:19 (FIND_PACKAGE)

I've to get this going with VS 2010 Express but I'm allowed to pick any compatible version of CMake and OpenCV for this project.

I'm doing this in CMakeLists.txt and the "OpenCVConfig.cmake" is the default one which gets shipped with OpenCV. I didn't modify it.

SET(OpenCV_DIR "D:/opencv/mybuild")
# this project requires OpenCV, so find it

Line#49 from OpenCVConfig.cmake looks like this


Any help in the right direction is greatly appreciated. Thanks.

if I modify line#49 by hard-coding the path, it works!


For some reasons ${CMAKE_CURRENT_LIST_DIR} is not getting set appropriately.
This looks like dynamically changed variable. Why is this not set as expected?

Answer Source

Proper support for versions of CMake prior to 2.8.3 was not present in OpenCV 2.4.9. In particular, this means that CMAKE_CURRENT_LIST_DIR is not a defined variable in the generated OpenCVConfig.cmake. This causes the the path to OpenCVModules.cmake to be formed incorrectly. At least in regards to this offending line in OpenCVConfig.cmake, compatibility for older versions of CMake was not added until 2.4.11 (I checked this by looking at ./cmake/templates/ on OpenCV's github).

That being said, if you can choose what versions of CMake and OpenCV to use, then I would suggest using the latest release of CMake (>=2.8.12) and the latest version of OpenCV 2.4 ( or OpenCV 3.1.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download