<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 10/9/12 5:05 PM, Andreas Pakulat
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAExHGmQ4SVZLjgmrTcs192P2iw9zLWQ=8LKH-cMRPHEpCgGCaA@mail.gmail.com"
      type="cite">
      <pre wrap="">Hi,

On Tue, Oct 9, 2012 at 4:42 PM, Fabio Fracassi
<a class="moz-txt-link-rfc2396E" href="mailto:fabio.fracassi@charite.de">&lt;fabio.fracassi@charite.de&gt;</a> wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">On 10/9/12 4:12 PM, Andreas Pakulat wrote:
</pre>
        <blockquote type="cite">
          <pre wrap="">
Hi,

On Tue, Oct 9, 2012 at 3:46 PM, Fabio Fracassi
<a class="moz-txt-link-rfc2396E" href="mailto:fabio.fracassi@charite.de">&lt;fabio.fracassi@charite.de&gt;</a> wrote:
</pre>
          <blockquote type="cite">
            <pre wrap="">
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.
</pre>
          </blockquote>
        </blockquote>
      </blockquote>
    </blockquote>
    [...]<br>
    <blockquote
cite="mid:CAExHGmQ4SVZLjgmrTcs192P2iw9zLWQ=8LKH-cMRPHEpCgGCaA@mail.gmail.com"
      type="cite">
      <blockquote type="cite">
        <blockquote type="cite">
          <blockquote type="cite">
            <pre wrap="">
Whats your find_package call? Check which of the variables mentioned
in the find_package docs are set before the find_package call.

Andreas
</pre>
          </blockquote>
        </blockquote>
        <pre wrap="">
Ups, sorry it is Config mode, of course, i.e. I do not have a
Find&lt;MyLibrarty&gt;.cmake anywhere, but my Library does provide a
&lt;MyLibrary&gt;-config.cmake in both the installed location and in its build
dir.
</pre>
      </blockquote>
      <pre wrap="">
I was actually talking about Config as well and mixed up the two types
myself too :)

</pre>
      <blockquote type="cite">
        <pre wrap="">The call I use is just: find_package(&lt;MyLibrary&gt;)
</pre>
      </blockquote>
      <pre wrap="">
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.
</pre>
    </blockquote>
    I checked, there is no Find&lt;MyLibrary&gt;.cmake anywhere on the
    system. The &lt;MyLibrary&gt;-config.cmake is indeed used, it is
    just the wrong one.<br>
    <br>
    <blockquote
cite="mid:CAExHGmQ4SVZLjgmrTcs192P2iw9zLWQ=8LKH-cMRPHEpCgGCaA@mail.gmail.com"
      type="cite">
      <pre wrap="">
</pre>
      <blockquote type="cite">
        <pre wrap="">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.
</pre>
      </blockquote>
      <pre wrap="">
What do you mean with "package registry" here? </pre>
    </blockquote>
    It means the package registry where cmake stores previously build
    packages, which can be disabled with
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    NO_CMAKE_PACKAGE_REGISTRY and is located in
    ~/.cmake/packages/&lt;name&gt;/* and which is searched as the 6th
    point.<br>
    <br>
    <br>
    <blockquote
cite="mid:CAExHGmQ4SVZLjgmrTcs192P2iw9zLWQ=8LKH-cMRPHEpCgGCaA@mail.gmail.com"
      type="cite">
      <pre wrap="">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?
</pre>
    </blockquote>
    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/&lt;MyLibrary&gt;/&lt;Mylibrary&gt;-config.cmake over
    /usr/local/lib/CMake/&lt;MyLibrary&gt;/&lt;Mylibrary&gt;-config.cmake<br>
    <br>
    Best regards<br>
    <br>
    Fabio<br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Dipl.-Inf. Fabio Fracassi
BZMM - Charite &amp; Fraunhofer IPK (bzmm.charite.de)
Augustenburger Platz. 1
13353 Berlin
Tel. +49 (0)30 / 450 555 185
</pre>
  </body>
</html>