[CMake] findpackage.cmake vs packageconfig.cmake

Mathieu Malaterre mathieu.malaterre at gmail.com
Wed Aug 11 04:18:53 EDT 2010


On Tue, Aug 10, 2010 at 7:47 PM, Alexander Neundorf
<a.neundorf-work at gmx.net> wrote:
> On Tuesday 10 August 2010, Mathieu Malaterre wrote:
>> Hi there,
>>
>>   I am trying to find a solution to find the openjpeg package.
>>
>>   In the 1.x version, openjpeg uses a makefile based build system. In
>> this case I need to write a custom findopenjpeg.cmake file to discover
>> all required path.
>>
>>   However in the current 2.x version, openjpeg now uses cmake as build
>> system. In this case I need to search for the installed
>> openjpeg-config.cmake.
>>
>>   I did not find a solution to cope with both situations. As soon as I
>> provide a findopenjpeg.cmake in the cmake_module_path, I cannot search
>> for openjpeg-config.cmake anymore.
>>
>> Any hints or suggestion greatly appreciated,
>
> I'd suggest to use a findopenjpeg.cmake, which first does a
> find_package(openjpeg QUIET NO_MODULE)
> and if that fails, continues to search with the "traditional"
> find_library/find_path/etc. calls.
>
> This way you can also print custom success/failure messages if
> the -config.cmake file is not found, or test for additional features even
> if -config.cmake is found.

Neat, I did not relalize there was a NO_MODULE option.

Warning: for anyone trying this solution do NOT use :
find_package(OpenJPEG 1.0 REQUIRED) and expect it to work.
Instead, it is required to use find_package(OpenJPEG REQUIRED) .. I am
not sure if I should report that as a bug or not.

Thanks !
-- 
Mathieu


More information about the CMake mailing list