I have been working on porting my CLion (2017 1.3)+ Arduino CMake project over to CLion + PlatformIO. I am completely stuck on the library imports.
Background
- Created project structure: platformio init --ide clion --board megaatmega2560 --board nanoatmega328
- Opened this structure in CLion
- Copied my main source PPC.ino over and put into /src
- Convert PPC.ino to PPC.cpp by adding forward declarations of functions.
- Copied all my additional local files over and put into /lib
- Merged my original CMakeLists.txt file with the new one that platformIO created.
- PLATFORMIO_REBUILD_PROJECT_INDEX
- Issue: My CMakeLists.txt file gets completely rewritten by PlatformIO. Yikes.
- Iāve learned to keep a backup of my CMakeLists.txt file
This is a big-ish project. Iām referencing an external (Adafruit_Neopixel) library that I keep in a folder far outside my build directory (so that other projects can use it).
Original Settings
CMakeLists.txt:
set(ARDUINO_SKETCH_FOLDER ā/Users/me/Documents/ARDUINO_DEVELOPMENTā)
include_directories(ā${ARDUINO_SKETCH_FOLDER}/libraries/Adafruit_Neopixelā)
PPC.ino (now PPC.cpp)
`#include āAdafruit_Neopixel.hā
This worked with ArduinoCMake (but I suspect they had some functions in there for making includes easier). However, once I was working with PlatformIO, I just kept on getting āAdafruit_Neopixelā file not found.
Tried to resolve in CMake
I tried just about every CMake call I could try, including:
- include_directories()
- link_directories()
- set(SRC_LIST ${SRC_LIST} āpath/to/Adafruit_Neopixel.cppā
I verified all the INCLUDED_DIRECTORIES are correct in CMakeā¦but itās like PlatformIO is not even using that list to search for the ā.hā files. Question: Does PlatformIO even look at the INCLUDED_DIRECTORIES from Cmake?
Hack Workaround in Source File
By putting the full path into the include, I was able to get it to compile. But why should I have to do this?
`#include āfull/path/to/the/include/file/Adafruit_Neopixel.hā
Tryied to resolve in platformio.ini
In search of a better solution, within platformio.ini, I have tried:
- lib_deps_external = Adafruit_Neopixel
- lib_extra_dirs = āpath/to/folder/Adafruit_Neopixelā
- lib_ldf_mode = deep+
- (I have also done chain+). Iām using ā+ā because I have include guards to switch between Neopixels and WS2801ās.
Desperation Sets In
Finally, out of desperation, I copied the Adafruit_Neopixel library folder (as well as the other external libraries) into my /lib. After that I was able to get back to simple _`#include āAdafruit_Neopixel.hā, and now it can at least compile. However, there still seem to be issues with linking everything up. This also does not seem to be the correct solution.
Also an Include Chain Issue?
In my /lib file, I have a central include file my_PPC_main.h This file calls several other #includes, referencing all the other required headers within /lib. However, it does not appear that those files are being linked (do they need to be added to source)?
To sum up ā Iām in desperate need of more documentation to support my port from CLion/CMake-Arduino to Clion/CMake/PlatformIO. Can anyone lend some guidance on how to resolve these linking issues?
[/quote]
- PLATFORMIO_BUILD
- FAIL Canāt find external files.
This is a big-ish project. Iām referencing an external (Adafruit_Neopixel) library that I keep in a folder far outside my build directory (so that other projects can use it).
Original Settings
Within CMakeLists.txt:
set(ARDUINO_SKETCH_FOLDER ā/Users/me/Documents/ARDUINO_DEVELOPMENTā)
include_directories(ā${ARDUINO_SKETCH_FOLDER}/libraries/Adafruit_Neopixelā)
Within PPC.ino
`#include āAdafruit_Neopixel.hā
This worked with ArduinoCMake (but I suspect they had some functions in there for making includes easier). However, once I was working with PlatformIO, I just kept on getting āAdafruit_Neopixelā file not found.
Trying to resolve in CMake
I tried just about every CMake call I could try, including:
- include_directories()
- link_directories()
- set(SRC_LIST ${SRC_LIST} āpath/to/Adafruit_Neopixel.cppā
I verified all the INCLUDED_DIRECTORIES are correct in CMakeā¦but itās like PlatformIO is not even using that list to search for the ā.hā files. Question: Does PlatformIO even look at the INCLUDED_DIRECTORIES from Cmake?
Source File Workaround
By putting the full path into the include, I was able to get it to compile. But why should I have to do this?
`#include āfull/path/to/the/include/file/Adafruit_Neopixel.hā
Trying to resolve in platformio.ini
In search of a better solution, within platformio.ini, I have tried:
- lib_deps_external = Adafruit_Neopixel
- lib_extra_dirs = āpath/to/folder/Adafruit_Neopixelā
- lib_ldf_mode = deep+ (I have also done chain+). Iām using ā+ā because I have include guards to switch between Neopixels and WS2801ās.
Desperation Sets In
Finally, out of desperation, I copied the Adafruit_Neopixel library folder (as well as the other external libraries) into my /lib. After that I was able to get back to simple _`#include āAdafruit_Neopixel.hā, and now it can at least compile. However, there still seem to be issues with linking everything up. This does not seem to be the correct solution. Help?
Is There Also an Include Chain Issue?
In my /lib file, I have a central include file my_PPC_main.h This file calls several other #includes, referencing all the other required headers within /lib.
e.g. my_PPC_main.h
#ifndef _my_PPC_Main_H_ #define _my_PPC_Main_H_ //-------PIN DEFINITIONS AND CONSTANTS------ must include first #include "PPC_PinDefs_and_Constants.h" //----------------------------- //for saving structs out to EEPROM. #include "PPC_EEPROMAnything.h" //save many of the common general strings into flash memory #include "PPC_Strings.h"
However, it does not appear that these additional includes are being linked (do they need to be added to source)?
e.g. start of the compile output:
[Wed Jun 21 14:36:14 2017] Processing nanoatmega328 (framework: arduino; lib_ldf_mode: deep+; build_flags: -D USE_NEOPIXEL_LEDS -Wno-unknown-pragmas; platform: atmelavr; board: nanoatmega328; upload_port: /dev/cu.usbmodem1421) -------------------------------------------------------------------------------- Collected 30 compatible libraries Looking for dependencies... Library Dependency Graph |-- <U8glib_mizraith> (/Users/me/Documents/Computer_Science/ARDUINO_DEVELOPMENT/PLATFORMIO_Projects/CLI_Mega_Due/lib/U8glib_mizraith) |-- <EEPROM> v2.0 (/Users/me/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/EEPROM) |-- <Adafruit_NeoPixel> (/Users/me/Documents/Computer_Science/ARDUINO_DEVELOPMENT/PLATFORMIO_Projects/CLI_Mega_Due/lib/Adafruit_NeoPixel) |-- <SPI> v1.0 (/Users/me/.platformio/packages/framework-arduinoavr/libraries/__cores__/arduino/SPI) avr-g++ -o .pioenvs/nanoatmega328/src/PixelPacerController.o -c -fno-exceptions -fno-threadsafe-statics -fpermissive -std=gnu++11 -g -Os -Wall -ffunction-sections
To sum up ā Iām in desperate need of more documentation to support my port from CLion/CMake-Arduino to Clion/CMake/PlatformIO. Can anyone lend some guidance on how to resolve these linking issues?