2013年12月30日月曜日

OSX-10.9: macportsでopencv入れてcmakeでfind_package(OpenCV REQUIRED)したらコケるはなし

[症状]

OSX-10.9で`sudo port install opencv`した後で、opencvに依存したアプリのcmakeのfind_packageがコケる。

[cmake エラーメッセージ]

...

CMake Error at CMakeLists.txt: 60 (find_package):
  By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "OpenCV", but
  CMake did not find one.

  Could not find a package configuration file provided by "OpenCV" with any
  of the following names:

    OpenCVConfig.cmake
    opencv-config.cmake

  Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
  "OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
  provides a separate development package or SDK, be sure it has been
  installed.

-- Configuring incomplete, error occurred!

...

[結論的対応]

OpenCVのcmake定義ファイルがシステムに存在するか確認:

find / -name "OpenCV*.cmake" 2>/dev/null

/opt/local/lib/cmake/OpenCVConfig-version.cmake
/opt/local/lib/cmake/OpenCVConfig.cmake
/opt/local/lib/cmake/OpenCVConfigModules-release.cmake
/opt/local/lib/cmake/OpenCVConfigModules.cmake

存在したのでcmakeのエラーメッセージの指示に従ってOpenCV_DIRを環境変数として設定:

export OpenCV_DIR=/opt/local/lib/cmake

これでcmakeのfind_package(OpenCV REQUIRED)が通る。

参考: 

0 件のコメント:

コメントを投稿