Meaning of `*' in find_library()

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Meaning of `*' in find_library()

Robin Verschueren
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).

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.



--

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
Reply | Threaded
Open this post in threaded view
|

Re: Meaning of `*' in find_library()

Konstantin Tokarev


14.11.2017, 14:56, "Robin Verschueren" <[hidden email]>:

> 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
--

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