Custom project config with IDF4.0+ and CMake

barakchamo
Posts: 2
Joined: Wed Sep 23, 2020 12:16 pm

Custom project config with IDF4.0+ and CMake

Postby barakchamo » Wed Sep 23, 2020 12:27 pm

Hi folks,

ESP-IDF newbie here :D

I'm working on my first ESP-IDF project, having converted it from a Platfrom.io Arduino project.
I managed to set up the CMake files, convert PIO libs to components, and everything is working so far.
I'm struggling to figure out how to convert a few final aspects of my PIO project, and since 4.0 is using
CMake I'm a little unclear on which examples on documentation to follow.

Basically, my question is where can I stick custom project configuration, the equivalent of what would
go in a platformio.ini file for things such as:
- additional compiler flags
- custom CPP defines
- multiple build/device targets
- running pre- and post-build python hooks

I dug around the 4.0 CMake build system documentation and it seems like two candidates for custom configuration
are the CMakeLists files and the KConfig files, but I couldn't get anything to work.

For example:
- I'm trying to use a -O2 compilation optimization flag which I understand needs to be passed as a CPP flag, but was unable to get that to work.
- I'm trying to pass FIRMWARE_VERSION and DEVICE_VERSION flags that are defined at build timed but not sure where to stick them and how to create multiple targets for each device the build is targeting.
- I'm trying to run a pre-build hook to increment that FIRMWARE_VERSION coming from a saved json file, but not sure where to run it from.

I'd really appreciate any pointers on how to begin customizing the build system to fit these requirements.

Thanks!

Who is online

Users browsing this forum: Baidu [Spider] and 140 guests