Cannot include headers from driver module ESP-IDF

I’m working on a project that requires the use of the twai.h header which is located in the “driver” folder as part of the ESP32 IDF. I can see that I do have this file as part of my esp-idf framework in my .platformio/packages/framework-espidf/components/driver. However when I try to include it in my code with #include "driver/twai.h" when i try to build i get

fatal error: driver/twai.h: No such file or directory
    5 | #include "driver/twai.h"

I’ve googled around a bunch and I’m unable to figure out why this is.

Looking at the esp-idf documentation, it mentions that you need to do the following to your CMakeLists.txt file:

I tried adding that line to my CMakeLists.txt for my CAN component like so:

REQUIRES driver
idf_component_register(SRCS "CAN.cpp"
                  INCLUDE_DIRS ".")

But this causes the following error:

 CMake Error at components/CAN/CMakeLists.txt:1:

    Parse error.  Expected "(", got identifier with text "driver".

If anyone knows how to fix this for including things from the driver folder, the help would be greatly appreciated.

After just trying random things , I discovered that the “REQUIRES” thing is supposed to go inside your component register brackets…the documentation wasn’t really clear on what exactly you needed to do and in their example repository they don’t do this at all so I had no reference.

What I needed to do was

idf_component_register(SRCS "CAN.cpp"
                  INCLUDE_DIRS "."
                  REQUIRES "driver")