[CMake] GLOB_RECURSE
Dan Liew
dan at su-root.co.uk
Thu Jul 26 01:32:07 EDT 2018
On 25 July 2018 at 23:47, Michael Hennebry
<michael.hennebry at rivieranexus.com> wrote:
> Emphasis on curse.
>
> from CMakeLists.txt:
>
> file (GLOB_RECURSE ards ./ArduinoCore/src *.cpp *.c)
> file (GLOB_RECURSE apps ./SensorUnit *.cpp *.c)
Your syntax is wrong. `./ArduinoCore/src`, ` ./SensorUnit`, `*.cpp`,
`*.c` are all being treated as separate glob expressions so `*.cpp`
and `*.c` recursively match the current directory.
If you look at the signature of the function you're calling
```
file(GLOB_RECURSE <variable> [FOLLOW_SYMLINKS]
[LIST_DIRECTORIES true|false] [RELATIVE <path>]
[<globbing-expressions>...])
```
you can see that all your arguments after `ards` and `apps` are being
treated as `<globbing-expressions>`.
Instead you want something like this
file(GLOB_RECURSE ards RELATIVE ArduinoCore/src *.cpp *.c)
file (GLOB_RECURSE apps RELATIVE ./SensorUnit *.cpp *.c)
Note the use of the `RELATIVE` argument. See
https://cmake.org/cmake/help/v3.10/command/file.html for more details.
Hope that helps.
More information about the CMake
mailing list