[CMake] FIND_PACKAGE does not work

Michael Wild themiwi at gmail.com
Fri Dec 18 08:17:17 EST 2009


On 18. Dec, 2009, at 13:06 , Adolfo Rodríguez Tsouroukdissian wrote:

> On Fri, Dec 18, 2009 at 12:57 PM, Müller Michael <
> michael.mueller at dkfz-heidelberg.de> wrote:
> 
>> Hi all,
>> 
>> i am trying to include OpenCV 2.0 (which is using CMake now) in our
>> project. Therefore, I call FIND_PACKAGE(OpenCV 2 REQUIRED) in one of our
>> CMake files with the following result:
>> 
>> CMake Error at mitk/CMake/MITK_OpenCV_Config.cmake:2 (FIND_PACKAGE):
>> Could not find module FindOpenCV.cmake or a configuration file for package
>> OpenCV.
>> 
>> Adjust CMAKE_MODULE_PATH to find FindOpenCV.cmake or set OpenCV_DIR to the
>> directory containing a CMake configuration file for OpenCV.  The file will
>> have one of the following names:
>> 
>>   OpenCVConfig.cmake
>>   opencv-config.cmake
>> 
>> ...
>> 
>> The file OpenCVConfig.cmake exists and I provide an ENV variable OpenCV_DIR
>> pointing to the correct dir which CMake should find. However, even if I set
>> OpenCV_DIR manually in the cache, CMake keeps failing.
>> 
>> Any ideas?
>> 
> 
> As the error message says, you should use  CMAKE_MODULE_PATH (and not
> OpenCV_DIR) to specify the path where OpenCVConfig.cmake is located.
> OpenCV_DIR is most probably used to specify where OpenCV is installed when a
> nonstandard path is used.
> 
> HTH,
> 
> Adolfo
> 
> 
>> Greets
>> Michael

No, that's not accurate. If you read the documentation, you will see that CMAKE_MODULE_PATH is used for INCLUDE() and FindXXX.cmake stuff. Probably it will also find OpenCVConfig.cmake, but it really should work with OpenCV_DIR, as this is also documented in the FIND_PACKAGE documentation (however, most people ever read that far...). There must be something else going wrong here...

Michael, have you tried it without the version number?

Michael


More information about the CMake mailing list