Question about find package in Module mode

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about find package in Module mode

Fabio Fracassi
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.

Is the current state the way it is supposed to be? Can I force CMake to
do what I want?

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

--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Question about find package in Module mode

Andreas Pakulat-2
Hi,

On Tue, Oct 9, 2012 at 3:46 PM, Fabio Fracassi
<[hidden email]> 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.
>
> Is the current state the way it is supposed to be? Can I force CMake to do
> what I want?

Unless you happen to build in /usr or /usr/local CMake won't
automatically find packages in module mode, so you must already be
doing something to have cmake find the module from the builddir first.
The documentation of the find_package function (cmake --help-command
find_package) has quite extensive documentation about the paths that
are being searched and their order.

Whats your find_package call? Check which of the variables mentioned
in the find_package docs are set before the find_package call.

Andreas
--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Question about find package in Module mode

Fabio Fracassi
On 10/9/12 5:05 PM, Andreas Pakulat wrote:
Hi,

On Tue, Oct 9, 2012 at 4:42 PM, Fabio Fracassi
[hidden email] wrote:
On 10/9/12 4:12 PM, Andreas Pakulat wrote:
Hi,

On Tue, Oct 9, 2012 at 3:46 PM, Fabio Fracassi
[hidden email] 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

--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Question about find package in Module mode

Andreas Pakulat-2
Hi,

On Tue, Oct 9, 2012 at 5:39 PM, Fabio Fracassi
<[hidden email]> wrote:
> On 10/9/12 5:05 PM, Andreas Pakulat wrote:
> On Tue, Oct 9, 2012 at 4:42 PM, Fabio Fracassi
> 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.

Ah, never came across that part before. What happens if you explicitly
disable searching the package registry?

> 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

Hmm, at this point I'd probably try cmake --trace and/or --debug-outpu
and maybe also the output of --system-information to find out why
cmake decides to load the config file from that location.

Oh and I assume that your client thats using the config has its own
build-directory, i.e. something like ~/build/<client>/ and there's no
CMakeCache.txt in ~/build/

Andreas
--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Question about find package in Module mode

Alexander Neundorf-3
In reply to this post by Fabio Fracassi
On Tuesday 09 October 2012, Fabio Fracassi 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.
>
> Is the current state the way it is supposed to be? Can I force CMake to
> do what I want?

Have you tried setting the environment variable CMAKE_PREFIX_PATH to point to
the install location of your library ?

Alex
--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake