[CMake] Question about find package in Module mode

Fabio Fracassi fabio.fracassi at charite.de
Tue Oct 9 11:39:29 EDT 2012


On 10/9/12 5:05 PM, Andreas Pakulat wrote:
> Hi,
>
> On Tue, Oct 9, 2012 at 4:42 PM, Fabio Fracassi
> <fabio.fracassi at charite.de> wrote:
>> On 10/9/12 4:12 PM, Andreas Pakulat wrote:
>>> Hi,
>>>
>>> On Tue, Oct 9, 2012 at 3:46 PM, Fabio Fracassi
>>> <fabio.fracassi at charite.de> wrote:
>>>> Hello,
>>>>
>>>> I am using find_package in Module mode for a Library that is also build
>>>> using cmake.
>>>> The Library is build in a way that it can be used both from the build
>>>> dir,
>>>> and from the installed location.
>>>>
>>>> When using find_package it always seems to prefer the build dir version,
>>>> which is somewhat surprising since I expect the default to be the
>>>> (supposably more stable) installed version and that the build dir version
>>>> (that could be broken at any time) needs some explicit interaction.
[...]
>>>> Whats your find_package call? Check which of the variables mentioned
>>>> in the find_package docs are set before the find_package call.
>>>>
>>>> Andreas
>> Ups, sorry it is Config mode, of course, i.e. I do not have a
>> Find<MyLibrarty>.cmake anywhere, but my Library does provide a
>> <MyLibrary>-config.cmake in both the installed location and in its build
>> dir.
> I was actually talking about Config as well and mixed up the two types
> myself too :)
>
>> The call I use is just: find_package(<MyLibrary>)
> You could try explicitly disabling the module mode here to avoid
> pulling in a possibly existing Find-Module somewhere on
> CMAKE_MODULE_PATH. If that results in the same behaviour, then there's
> something else wrong.
I checked, there is no Find<MyLibrary>.cmake anywhere on the system. The 
<MyLibrary>-config.cmake is indeed used, it is just the wrong one.

>> I do not explicitly set any environment or cmake vars that affect
>> find_package.
>> The build dirs (both of my library and its client) are somewhere in home,
>> and my libray is installed in /usr/local (and /usr/local/bin is in the PATH)
>> The package registry for my library contains the pathes to the build dir.
> What do you mean with "package registry" here?
It means the package registry where cmake stores previously build 
packages, which can be disabled with NO_CMAKE_PACKAGE_REGISTRY and is 
located in ~/.cmake/packages/<name>/* and which is searched as the 6th 
point.


> Does that mean the
> files installed into /usr/local/ reference the builddir? If that is
> the case then you probably didn't generate the config files properly.
> Can you post the generated files as well as the corresponding
> install(EXPORT) and install(TARGETS ... EXPORT) lines?
No, those are ok, and indeed work if I manualy point to the installed 
dir. It is just that for some reason CMake prefers 
~/build/<MyLibrary>/<Mylibrary>-config.cmake over 
/usr/local/lib/CMake/<MyLibrary>/<Mylibrary>-config.cmake

Best regards

Fabio

-- 
Dipl.-Inf. Fabio Fracassi
BZMM - Charite & Fraunhofer IPK (bzmm.charite.de)
Augustenburger Platz. 1
13353 Berlin
Tel. +49 (0)30 / 450 555 185

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20121009/7af618d9/attachment.htm>


More information about the CMake mailing list