[CMake] Re: FindXXX, XXXConfig and UseXXX

Fernando Cacciola fernando.cacciola at gmail.com
Tue Feb 19 09:16:52 EST 2008


Brad King wrote:

>> If FindXXX.cmake is found in the paths specified by CMAKE_MODULE_PATH,
>> it is loaded by find_package(XXX).
>
> There should not be a FindXXX.cmake at all.
>
OK.
So is either FindXXX or XXXConfig, for package configured without and with 
cmake respectively.

>> If not, but the user sets XXX_DIR to some binary folder for some
>> installation of XXX, the above code works still by loading
>> XXXConfig.cmake directly (witout going through FindXXX..cmake)
>>
>> Is all that correct?
>
> Yes.
>
>> Is so, how should FindXXX and UseXXX distributed?
>
> UseXXX.cmake should come with the project next to XXXConfig.cmake.
>
OK.
I suppose it could also go the the source tree provided each XXXConfig.cmake 
point to it via XXX_USE_FILE

> The whole idea of creating a package with XXXConfig.cmake is to not have
> to have a FindXXX.cmake module at all.

OK

> The find_package command is
> supposed to find XXXConfig.cmake automatically, but it is not very good
> at finding the files as of CMake 2.4 so the user has to set XXX_DIR
> alot.  CMake 2.6 will have a much better find_package:
>
>   http://www.cmake.org/Wiki/CMake_2.6_Notes#Packages
>

Just read it.

> You should install XXXConfig.cmake and UseXXX.cmake in the XXX install
> tree under one of the locations mentioned in the find_package command
> documentation (as of CMake 2.6).  For example, a project on UNIX might
> install
>
>   <prefix>/lib/xxx-1.2/XXXConfig.cmake
>
Hmmm.
Shouldn't that be decided by the package user?

Right now I generate XXConfig right there in XXX_BINARY_DIR, whatever that 
is, and use an INSTALL command to copy that to whatever the user chooses as 
the installation folder (which could be <prefix>/lib/xxx-1.2, but could be 
something else).

For this package it is importat that a user (such as XXX's testsuite) can 
use XXX without "installing" it via the install target, that's why I put the 
config file in the binary folder right away.

> Someone using CMake 2.4 will have to set XXX_DIR to that directory by
> hand, but anyone using CMake 2.6 will have the file found automatically.

Except on Windows... or are there special search paths for Windows as well?

(please look at my upcoming post about XXX_DIR)

>  Versioning is also supported in the CMake 2.6 find_package.  See the
> nots above.
>
I just read it, cool.

Thanks


-- 
Fernando Cacciola
SciSoft
http://fcacciola.50webs.com
http://groups.google.com/group/cppba





More information about the CMake mailing list