Arun
Arun

Reputation: 2092

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:

    /OpenCVModules.cmake
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
FIND_PACKAGE( OpenCV )
INCLUDE_DIRECTORIES( ${OpenCV_INCLUDE_DIRS} )

Line#49 from OpenCVConfig.cmake looks like this

  include(${CMAKE_CURRENT_LIST_DIR}/OpenCVModules${OpenCV_MODULES_SUFFIX}.cmake)

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

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

include(D:/opencv/mybuild/OpenCVModules${OpenCV_MODULES_SUFFIX}.cmake)

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?

Upvotes: 3

Views: 4379

Answers (1)

Robert Prévost
Robert Prévost

Reputation: 1707

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/OpenCVConfig.cmake.in 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 (2.4.13.1) or OpenCV 3.1.

Upvotes: 2

Related Questions