<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Am 31.07.19 um 08:20 schrieb Stephan Menzel:<br>
    <blockquote type="cite"
cite="mid:CAEQ568toNEYC6=SCzyWLnmfAuOX-AjFqdUY7KRo-P9YhDk7eiA@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Hello all,
        <div><br>
        </div>
        <div>I'm trying to adapt my CMake based toolchain to Android and
          I'm noticing very strange behavior that I'd like to ask about.</div>
        <div>My toolchain is C++ based with some dependencies such as
          Boost, OpenSSL or protobuf. So far it works on a variety of
          platforms such as Windows (MSVC), several Linuxes, including
          Raspbian on ARM. So I considered myself well prepared for
          Android, thinking it can't be that different. How wrong I
          was... I'm cross compiling from a Linux system, which is able
          to build the source in question just fine with clang and gcc.
          Most recent Android SDK and bundled NDK.</div>
        <div><br>
        </div>
        <div>As soon as I started building and finding my 3rd party
          dependencies I noticed that many commands in my own scripts or
          others that try to find a file (like a header) or a lib fail
          despite the file being there.</div>
        <div>Like here in this case for example (randomly taken from the
          AWS SDK installed CMake finders):</div>
      </div>
    </blockquote>
    <p>My experience has been that find_file and friends behave in
      unexpected ways when you set CMAKE_SYSROOT. In our toolchain
      files, we set</p>
    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)<br>
    set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)<br>
    <p>as suggested in the cmake-toolchains(7) documentation. We then
      add the path to the top-level directory where we keep all our
      thirdparty dependencies to CMAKE_FIND_ROOT_PATH, as otherwise
      find_package and find_path cannot find anything even when we give
      them the absolute path where to search (the find_file
      documentation suggests that the elements of the
      CMAKE_FIND_ROOT_PATH are prepended to the paths specified in the
      find_file arguments, but that does not seem to happen if the
      search paths are subpaths of the CMAKE_FIND_ROOT_PATH). My guess
      would be that the NDK does something similar, meaning you would
      need to add the path where to look for AWS to
      CMAKE_FIND_ROOT_PATH.<br>
    </p>
    <p>CMake feature request: it would be real nice to have a verbose
      mode for the find_XXX functions that tell you exactly where CMake
      is looking for stuff and why to help debug problems like this.</p>
    <p>With kind regards,<br>
      Eric<br>
    </p>
    -- <br>
    <div class="moz-signature">
      <div style="width:480px; text-align: left; font-family: Arial,
        Helvetica, sans-serif;">
        <p style="color: #062d64; font-size: 14px; text-align: left;
          font-family: Arial, Helvetica, sans-serif;"><b>
            Dr. Eric Dönges
          </b><br>
          Senior Software Engineer
        </p>
        <p style="color: #062d64; font-size: 12px; text-align: left;
          font-family: Arial, Helvetica, sans-serif;">MVTec Software
          GmbH | Arnulfstr. 205 | 80634 Munich | Germany<br>
          <a style="font-size: 12px; font-family: Arial, Helvetica,
            sans-serif; color: #062d64;" href="mailto:doenges@mvtec.com">doenges@mvtec.com</a>
          | Tel: +49 89 457 695-0 | <a style="font-size: 12px;
            font-family: Arial, Helvetica, sans-serif; color: #062d64;"
            href="http://www.mvtec.com">www.mvtec.com</a>
        </p>
        <p style="color: #062d64; font-size: 12px; text-align: left;
          font-family: Arial, Helvetica, sans-serif;"><img
src="https://mvtec.com/fileadmin/Redaktion/newsletter/mail-signature/newsletter-icon.png"
            valign="bottom" width="16" height="16"> <a style="font-size:
            12px; font-family: Arial, Helvetica, sans-serif; color:
            #062d64; font-weight: bold;"
            href="http://www.mvtec.com/newsletter">Sign up</a> for our
          MVTec Newsletter!</p>
        <p style="margin: 0px; color: #666; font-size: 12px; text-align:
          left; font-family: Arial, Helvetica, sans-serif;">Geschäftsführer:
          Dr. Wolfgang Eckstein, Dr. Olaf Munkelt<br>
          Amtsgericht München HRB 114695</p>
        <p style="margin: 0px; color: #666; font-size: 12px; text-align:
          left; font-family: Arial, Helvetica, sans-serif;"> </p>
        <img
src="https://www.mvtec.com/fileadmin/Redaktion/newsletter/mail-signature/mvtec-logo-line.png"
          alt="MVTec Software GmbH Logo"></div>
    </div>
  </body>
</html>