Page 1 of 1

Include component header

Posted: Tue May 14, 2024 4:00 pm
by BinaryPoet
Hello,
I started a new project using the "ledc_basic_example" template. The main includes "driver/ledc.h" end everything build fine.
Then I added a component. I include the component header, let say "mycomponent.h" into the main, but when compiling this header is not found. So I changed the CMakeLists.txt placed into "led_basic/main/" folder to include my component.
As described in a previous thread I tried both

Code: Select all

idf_component_register(SRCS "main.c"
                  INCLUDE_DIRS "."
                  PRIV_REQUIRES my_component) 
and

Code: Select all

set(includedirs
  ../components/my_component/include/
  "."    # this line is probably not needed since main dir is included by default and there are no sub-directories under main
  )

idf_component_register(SRCS "main.c"
                    INCLUDE_DIRS ${includedirs} 
                    PRIV_REQUIRES my_component)
At this point the driver/ledc.h is not found.
Why?

Re: Include component header

Posted: Tue May 14, 2024 11:53 pm
by ESP_Sprite
The 'main' component implicitly REQUIREs all components; your new component does not. You probably want to add "driver" to PRIV_REQUIRES.