<html><body><div style="font-family: arial,helvetica,sans-serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>De: </b>"Nils Gladitz" <nilsgladitz@gmail.com><br><b>À: </b>"Julien Schueller" <schueller@phimeca.com>, "cmake-developers" <cmake-developers@cmake.org><br><b>Envoyé: </b>Vendredi 1 Juillet 2016 14:19:25<br><b>Objet: </b>Re: [cmake-developers] PATHS guess in find_package ignored with NO_DEFAULT_PATH & CMAKE_FIND_ROOT_PATH_MODE_PACKAGE<br></blockquote></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><br>
    <br>
    <div class="moz-cite-prefix">On 07/01/2016 02:08 PM, Julien
      Schueller wrote:<br>
    </div>
    <blockquote cite="mid:99255226.769010.1467374911634.JavaMail.zimbra@phimeca.com">
      <div style="font-family: arial,helvetica,sans-serif; font-size:
        12pt; color: #000000">
        <div><br>
        </div>
        <div><br>
        </div>
        <hr id="zwchr">
        <div>
          <blockquote style="border-left:2px solid
#1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>De:
            </b>"Nils Gladitz" <a class="moz-txt-link-rfc2396E" href="mailto:nilsgladitz@gmail.com" target="_blank"><nilsgladitz@gmail.com></a><br>
            <b>À: </b>"Julien Schueller" <a class="moz-txt-link-rfc2396E" href="mailto:schueller@phimeca.com" target="_blank"><schueller@phimeca.com></a>,
            "cmake-developers" <a class="moz-txt-link-rfc2396E" href="mailto:cmake-developers@cmake.org" target="_blank"><cmake-developers@cmake.org></a><br>
            <b>Envoyé: </b>Vendredi 1 Juillet 2016 13:57:40<br>
            <b>Objet: </b>Re: [cmake-developers] PATHS guess in
            find_package ignored with NO_DEFAULT_PATH &
            CMAKE_FIND_ROOT_PATH_MODE_PACKAGE<br>
          </blockquote>
        </div>
        <div>
          <blockquote style="border-left:2px solid
#1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><br>
            <br>
            <div class="moz-cite-prefix">On 07/01/2016 01:44 PM, Julien
              Schueller wrote:<br>
            </div>
            <blockquote cite="mid:1577503543.735558.1467373476859.JavaMail.zimbra@phimeca.com">
              <div style="font-family: arial,helvetica,sans-serif;
                font-size: 12pt; color: #000000">
                <div><br>
                </div>
                <div><br>
                </div>
                <hr id="zwchr">
                <div>
                  <blockquote style="border-left:2px solid
#1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>De:

                    </b>"Nils Gladitz" <a class="moz-txt-link-rfc2396E" href="mailto:nilsgladitz@gmail.com" target="_blank"><nilsgladitz@gmail.com></a><br>
                    <b>À: </b>"Julien Schueller" <a class="moz-txt-link-rfc2396E" href="mailto:schueller@phimeca.com" target="_blank"></a><a class="moz-txt-link-rfc2396E" href="mailto:schueller@phimeca.com" target="_blank"><schueller@phimeca.com></a>,
                    "cmake-developers" <a class="moz-txt-link-rfc2396E" href="mailto:cmake-developers@cmake.org" target="_blank"><cmake-developers@cmake.org></a><br>
                    <b>Envoyé: </b>Vendredi 1 Juillet 2016 12:37:47<br>
                    <b>Objet: </b>Re: [cmake-developers] PATHS guess in
                    find_package ignored with NO_DEFAULT_PATH &
                    CMAKE_FIND_ROOT_PATH_MODE_PACKAGE<br>
                  </blockquote>
                </div>
                <div>
                  <blockquote style="border-left:2px solid
#1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;">On

                    07/01/2016 11:13 AM, Julien Schueller wrote:<br>
                    <blockquote cite="mid:16353177.488934.1467364427090.JavaMail.zimbra@phimeca.com">
                      <div style="font-family:
                        arial,helvetica,sans-serif; font-size: 12pt;
                        color: #000000">
                        <div>
                          <div style="font-family:
                            arial,helvetica,sans-serif; font-size: 12pt;
                            color: #000000">
                            <div>
                              <div style="font-family:
                                arial,helvetica,sans-serif; font-size:
                                12pt; color: #000000"><br>
                              </div>
                              <div style="font-family:
                                arial,helvetica,sans-serif; font-size:
                                12pt; color: #000000">I'm using
                                find_package in no-module mode with the
                                PATHS option to provide a hard-coded
                                guess to a path where a sublibrary
                                'hmat' was previously found,<br>
                              </div>
                              <div style="font-family:
                                arial,helvetica,sans-serif; font-size:
                                12pt; color: #000000">and with the
                                NO_DEFAULT_PATH to not find it first in
                                system directories.<br>
                              </div>
                              <div style="font-family:
                                arial,helvetica,sans-serif; font-size:
                                12pt; color: #000000">find_package (HMAT
                                REQUIRED NO_MODULE PATHS
                                <hmat-prefix>/lib/cmake/hmat
                                NO_DEFAULT_PATH)<br>
                              </div>
                              <div style="font-family:
                                arial,helvetica,sans-serif; font-size:
                                12pt; color: #000000"><br>
                              </div>
                              <div style="font-family:
                                arial,helvetica,sans-serif; font-size:
                                12pt; color: #000000">So far so good.
                                Now I want to cross-compile with the
                                usual toolchain file:<br>
                              </div>
                              <div style="font-family:
                                arial,helvetica,sans-serif; font-size:
                                12pt; color: #000000"> set
                                (CMAKE_FIND_ROOT_PATH
                                /usr/i686-w64-mingw32)<br>
                                set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM
                                NEVER)<br>
                                set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY
                                ONLY)<br>
                                set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE
                                ONLY)</div>
                              <div style="font-family:
                                arial,helvetica,sans-serif; font-size:
                                12pt; color: #000000">...<br>
                              </div>
                              <div style="font-family:
                                arial,helvetica,sans-serif; font-size:
                                12pt; color: #000000">This works
                                wonderfully too.<br>
                              </div>
                              <div style="font-family:
                                arial,helvetica,sans-serif; font-size:
                                12pt; color: #000000"><br>
                              </div>
                              <div style="font-family:
                                arial,helvetica,sans-serif; font-size:
                                12pt; color: #000000">But now I add
                                CMAKE_FIND_ROOT_PATH_MODE_PACKAGE to
                                ONLY in my toolchain file to prevent
                                detecting native libraries <br>
                                set (CMAKE_FIND_ROOT_PATH_MODE_PACKAGE
                                ONLY)<br>
                              </div>
                              <div style="font-family:
                                arial,helvetica,sans-serif; font-size:
                                12pt; color: #000000">And now
                                find_package fails to find my package!<br>
                              </div>
                              <div style="font-family:
                                arial,helvetica,sans-serif; font-size:
                                12pt; color: #000000"><br>
                              </div>
                              <div style="font-family:
                                arial,helvetica,sans-serif; font-size:
                                12pt; color: #000000">I'm puzzled as I
                                did not find in the doc something that
                                explains why the PATHS is ignored (step
                                #8 in find_package):<br>
                              </div>
                              <div style="font-family:
                                arial,helvetica,sans-serif; font-size:
                                12pt; color: #000000"><a class="moz-txt-link-freetext" href="https://cmake.org/cmake/help/v3.5/command/find_package.html#command:find_package" target="_blank"></a><a class="moz-txt-link-freetext" href="https://cmake.org/cmake/help/v3.5/command/find_package.html#command:find_package" target="_blank">https://cmake.org/cmake/help/v3.5/command/find_package.html#command:find_package</a><br>
                              </div>
                              <br>
                            </div>
                          </div>
                        </div>
                      </div>
                    </blockquote>
                    <br>
                    The given path "<hmat-prefix>/lib/cmake/hmat"
                    is prefixed by the paths in CMAKE_FIND_ROOT_PATH.<br>
                    Which means that (given ONLY) cmake only looks for
                    the package in
                    "/usr/i686-w64-mingw32/<hmat-prefix>/lib/cmake/hmat".<br>
                    <br>
                    You might want to e.g. add <hmat-prefix> to
                    CMAKE_FIND_ROOT_PATH and use PATHS / instead.<br>
                    <br>
                    Nils<br>
                  </blockquote>
                  <div><br>
                  </div>
                  <div>Thanks,<br>
                  </div>
                  <div><br>
                  </div>
                </div>
                <div>In my case <hmat-prefix> has the same value
                  as CMAKE_FIND_ROOT_PATH, and even if I modify the
                  PATHS option value to be relative (PATHS
                  lib/cmake/hmat) the detection fails.<br>
                </div>
                <div>(They're not actually set to /usr/i686-w64-mingw32
                  but some absolute location in my home where I unzip a
                  mingw toolchain, but I can reproduce the issue on
                  another box where the toolchain is natively
                  /usr/i686-w64-mingw32).</div>
              </div>
            </blockquote>
            <br>
            I don't think behavior for relative paths is defined.<br>
            <br>
            Use absolute paths like "/lib/cmake/hmat", just "/" probably
            works as well (since the path in the prefix matches
            "<prefix>/(lib/<arch>|lib|share)/cmake/<name>*/").<br>
            <br>
            Nils<br>
            <br>
          </blockquote>
        </div>
        <div><br>
        </div>
        <div>Yes, if I use just "/lib/cmake/hmat" it works. Couldn't
          cmake see that that my absolute path begins with
          CMAKE_FIND_ROOT_PATH and hence should be treated as valid
          according to CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ?<br>
        </div>
      </div>
    </blockquote>
    <br>
    CMake could do a lot of things but as-is the defined (documented)
    behavior is that when you tell cmake to only look in the prefixes
    provided by CMAKE_FIND_ROOT_PATH then all search locations are
    re-rooted to those prefixes.<br>
    <br>
    e.g. a given path "/usr" can exist under your regular filesystem
    root and as /usr/i686-w64-mingw32/usr.<br>
    Still you would not want cmake to look in your native /usr directory
    in this case even though it is "valid" (exists).<br>
    <br>
    Nils<br><br></blockquote></div><div>I see your point.<br></div><div>Thank you so much for the quick response.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div data-marker="__SIG_POST__">-- <br></div><div>Julien Schueller<br>Phimeca Engineering<br>www.phimeca.com</div></div></body></html>