[CMake] findpackage.cmake vs packageconfig.cmake

Alexander Neundorf a.neundorf-work at gmx.net
Tue Aug 10 13:47:02 EDT 2010


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.

Alex


More information about the CMake mailing list