[CMake] find_file - strange behavior when using Android toolchain

Eric Noulard eric.noulard at gmail.com
Wed Jul 31 05:47:23 EDT 2019


Le mer. 31 juil. 2019 à 11:19, Stephan Menzel <stephan.menzel at gmail.com> a
écrit :

> Thank you, Eric and Ugesh,
>
> Am Mi., 31. Juli 2019 um 09:16 Uhr schrieb Eric Doenges <doenges at mvtec.com
> >:
>
>> My experience has been that find_file and friends behave in unexpected
>> ways when you set CMAKE_SYSROOT. In our toolchain files, we set
>> set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
>> set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
>> set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
>> set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
>>
>> 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.
>>
>
> I have just looked that up and yes, it would explain what I'm seeing.
> CMAKE_SYSROOT is being set by the toolchain file and it would appear as
> this would make all search hints and paths implicitly relative.
>
> I'm now trying to restructure my 3rd party management for this target to
> enable me to install my dependencies into the subdirs set as sysroot,
> hoping that they will then be found.
>
> Thanks for the suggestion, that looks promising. I will get back with more
> info on if and how that turned out.
>
>> 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.
>>
> Seconded.
>

+1


> I always insert debug message() statements all over the place and then
> often forget to clean them up. Also, this way I can only verify the search
> paths are correct but not why find_file fails.
>

In CMake 3.15 message command learned DEBUG mode:
https://cmake.org/cmake/help/v3.15/release/3.15.html and
https://cmake.org/cmake/help/v3.15/command/message.html#command:message
so that you my leave your message(DEBUG ...) message while not being
displayed at default loglevel.

You may use the --loglevel command line option to get them. The default
level being displayed is STATUS.
See: https://cmake.org/cmake/help/v3.15/manual/cmake.1.html


-- 
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190731/a5ccb18f/attachment-0001.html>


More information about the CMake mailing list