PlatformIO Community

CMake + PIO Workflow explanation

I’m workin with PIO, CMake + CLion since years and I really like it.
I think my CMake knowledge is not the worst but recently I struggled with the following problem:
I tried to add one of my internal libs (logger) to a pio-Project.
I placed “logger” in a subfolder called .dependencies. (/.dependencies/logger)
In CMakeListsUser I tried everything I could think of to integrate logger.

set(LOGGER_PACKAGE "${CMAKE_CURRENT_LIST_DIR}/.dependencies/logger")


Nothing worked. After two days back and forth I gave up and added

lib_extra_dirs =

to my platformio.ini - This solved my problem but!!! in my opinion, what pio generates:


Looks like my own attempt in CMakeListsUser.txt.

Can someone explain why the approach works in CMakeListsPrivate but doesn’t work in CMakeListsUser???

Hmmm - to answer my own question:
I think PIO doesn’t care how the whole CMake-Stuff looks like. I completely ignores it. CMakeLists* are only relevant for the IDE!
OMG - I always thought PIO generates it’s stuff based on cmake…

Oh no, no no. You don’t use CMake files to add a dependency. You need to tell PlatformIO about your dependency. The CMakeLists.txt that PlatformIO generates is a really fancy wrapper that just calls into pio run for compilation. PIO is always the build system. Otherwise it could not efficiently support all these IDEs – they are all made to call into PlatformIO for the actual compilation, so things only have to implemented once.

If you have a library, just add it to the lib/ folder of the project, or otherwise refer to it via lib_deps.