Thank you for providing this detailed information.
You can avoid specifying the explicit path by having the header file’s include path in your compiler’s include path. In Cmake this is done by specifying a dependency on the target that defines the include paths for the header files. Espressif has a wrapper around cmake targets and calls them components. The way that you will add the dependency is different depending on if it is a Espressif component or a cmake target.
In your original question, the bluetooth related files that you want to include are defined by the Espressif “bt” component. If I’m understanding correctly, you want one of your components to depend on this “bt” component. In this case, in the CMakeLists.txt file for your component, add the following line before “register_component()”:
“set(COMPONENT_REQUIRES bt)”
In your follow up question, it sounds like you are trying to include the header files of one component that you defined in a header file of a different component that you defined. To do this, you can add a dependency in the same way as the bluetooth module, since they are both “components”.
It looks like you may have some other issues with your project such as the location of the CMakeLists.txt file that you are initially calling and how you are adding component subdirectories.
To help show what I explained and how to fix these errors, I created an example that you can run and compare with on a github branch:
It can be built in the root directory with the following command:
“cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=freertos/tools/cmake/toolchains/xtensa-esp32.cmake -GNinja”
In this example, I have created two components called “wifi” and “common”. The “wifi” component is set to depend on the “common” component and is able to include “common.h”. The “common” component is set to depend on the Espressif bluetooth component that is located at the path you described. In this example I was able to include the “esp_bt.h” header file that belongs to the bluetooth component. Here is a link to where Espressif is adding the header files as private:
I would note that the other header files that you listed are set to be private by Espressif, which means that they won’t be found even if you are correctly dependent on the bluetooth component.
For additional information on how to use the amazon-freertos github repo as a submodule with esp32, see the following link:
https://docs.aws.amazon.com/freertos/latest/userguide/getting_started_espressif.html#getting_started_espressif_cmake_project