bitbank2 / JPEGDEC

An optimized JPEG decoder for Arduino
Apache License 2.0
365 stars 47 forks source link

Add ESP-IDF CMakeLists.txt so it can be used as "a component" using git submodule #32

Closed martinberlin closed 2 years ago

martinberlin commented 2 years ago

This small CMakeLists contribution is to enable this to be used as an ESP-IDF component directly.

So after this we can simply do a:

git submodule add https://github.com/bitbank2/JPEGDEC.git components/jpegdec

And then on the build: idf.py build

esp-idf will simply have it ready to be used "as a component" that can be included to your Firmware.

martinberlin commented 2 years ago

@bitbank2 Food for though for tomorrow discussion:

Adding this includes won't hurt when compiling something in Arduino:

#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>

And in my opinion "Arduino.h" you don't need to add in a library when the main.cpp (Or ino) is already adding that header. So this could simply add those required headers and it will compile both in Arduino and in the other platforms as well (Linux, MCUXPRESSO, esp-idf, etc) unless I'm missing something. But I see why it's included and it's because it adds all that definitions together that are needed. The only thing I would like to do it's to exclude it and treat idf as it was Linux. But adding:

#define __LINUX__
#include "JPEGDEC.h" // Does not work also, only if I define it inside that header it works

Another idea:

// ifdef should really ask if we are building this on the Arduino framework not if the header is already defined
#ifndef Arduino_h
   #include <Arduino.h>
#endif
// UPDATE: This idea was bad also since it will include Arduino header also in esp-idf framework which won't find it