espressif / esp-aws-iot

AWS IoT SDK for ESP32 based chipsets
Apache License 2.0
256 stars 154 forks source link

libraries/common/posix_compat missing path to esp_timer (CA-229) #128

Open davidallenmann opened 1 year ago

davidallenmann commented 1 year ago

/libraries/common/posix_compat/CMakeLists.txt should add path for esp_timer or get build error missing esp_timer.h Tested with mqtt_demo_mutual_auth

idf_component_register(
    SRCS
        "clock_esp.c"
        "semaphore.c"
    INCLUDE_DIRS
        "."
        "$ENV{IDF_PATH}/components/esp_timer/include"
    REQUIRES
)
SolidStateLEDLighting commented 1 year ago

I just went through all this....and its a pain the first time around.

First at the project level include extra components like this:

set(EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/components/esp-aws-iot/libraries/common/posix_compat" )

Second at the project component level (main component or another component) -- add REQUIRES posix_compat to your idf_component_register statement

Third -- #include "" in the place that you need it (either source or header file).

It can be more complex than this -- you can PRIV_REQUIRE it as well (learn how private vs non-private can help you reduce the scope of the included components and reduce your exposure to possible undefined reference troubles)

It's an unpleasant experience when you're just getting up to speed with CMake, but I'm starting to like it more now that it seems to be working for me.