Arduino libs with platformio

I'm interested in possibly picking up a copy of CLion to use with platformio to develop for the esp8266, but I'm having a hard time figuring out how to include libraries from the Arduino directories.  Part of the problem is how Arduino goes about laying out it's library directories. They are scattered all over the place. The core libraries are in one place under .arduino15 and platformio creates it's own folders in a similar fashion under .platformio. But even those are split up into cores vs hardware folders depending on what device(s) you are programming. Then Arduino puts the various module/shield libraries each in a separate directory, sometimes in the root of said directory, sometimes under a 'src' subdir.

Short of going into the CMakeLists.txt file manually and throwing a whole slew of values in the includes, I haven't found any other way to include libraries in specific locations. Is there a gui tool anywhere for modifying the CMakeLists.txt and is there any way of globbing or something similar to have it look for the libraries?

I am aware that if you run 'platformio lib install [libraryname]' it will plop them in .piolibdeps in the root folder of the project with a CMakeLists.txt file with it, and initializing the product with --ide clion also creates a CMakeLists.txt in the root folder, but it still doesn't seem to create anything that will resolve the libs and the various files in piolibdeps are still broken into separate folders. Furthermore, they aren't resolveable by default within the CLion IDE (showing read and non-click-able with ctrl-click) unless you again manually insert each folder in CMakeLists.txt.

Is there some better way of adding the libs or an easier way to get CLion to include the libs in the external libraries?

1
1 comment

I know this is an old post - but I kept coming across it trying to find the answer to the same question. I don't know the state of PlatformIO at the time of this OP, but at least as of this writing, there's a `-g` flag available with the lib subcommand:

```
$ platformio lib -g install 'Adafruit NeoPixel'
Library Storage: /Users/rhornsby/.platformio/lib
Looking for Adafruit NeoPixel library in registry
Found: https://platformio.org/lib/show/28/Adafruit NeoPixel
LibraryManager: Installing id=28
Adafruit NeoPixel @ 1.2.5 has been successfully installed!
```

If you leave off the `-g` flag, it will note this by showing you `Library Storage: /path/to/your/project`

Don't forget to update the project afterward with `init` to get it to refresh

`platformio init --ide clion`

`init` will recognize the existing project files and update them.

TBH, this is a bit of a note to my future self because I'm probably not going to remember how to do this in a few months.

3

Please sign in to leave a comment.