[CMake] Meaning of `*' in find_library()

Konstantin Tokarev annulen at yandex.ru
Tue Nov 14 07:08:12 EST 2017



14.11.2017, 14:56, "Robin Verschueren" <robin.verschueren at gmail.com>:
> Dear all,
>
> I'm having some troubles using the 'PATHS' argument to find_library. More specifically, I'm trying to find the gfortran libraries (/usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.so on my system).
>
> If I call
>
> find_library(FORTRAN_LIBRARY
>     NAMES gfortran
>     PATHS "/usr/lib/gcc/x86_64-linux-gnu/*")
>
> CMake finds the gfortran libs. However, if I change the last argument to "usr/lib/gcc/*", CMake does not find the specified library and throws an error (if REQUIRED is set).

FWIW shell globs (from which this syntax derives) are not recursive

>
> Why is the extra directory necessary? Does the `*' symbol only look one directory deeper?  How can I traverse folders recursively?
>
> I tried to look for documentation on this, but searches in both Google and the CMake docs did not return anything useful. (looked for find_library, file, glob, etc.)
>
> Best regards,
> Robin
>
> PS if someone knows a better way of finding Fortran libraries, please feel free to enlighten me.

Parse `gcc -print-search-dirs`

>
> ,--
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake


-- 
Regards,
Konstantin


More information about the CMake mailing list