Hi, I want to use a component, but have some problems configuring it. I use ESP-IDF 4.2
I placed the files and subfolders into my project/components folder. The componenets header files are in project/components/include and the source files (.cpp) in project/components/src
I have a CMakeLists.txt in project/components
The compiler complains that it cannot find a source file (msg.cpp) so I added:
idf_component_register(
SRCS "msg.cpp"
INCLUDE_DIRS "./src" "include"
)
and variants with and without the ./
What should I do to make the building system discover project/components/src/msg.cpp ?
Do I have to add something in my CMakeLists.txt in the main folder? Or even in the top level?
Or should I add something to my main.cpp?
Thanks
Fred
Source files in sub-folder
-
- Posts: 112
- Joined: Thu Oct 03, 2019 10:52 pm
- Contact:
Re: Source files in sub-folder
The ESP-IDF example has some examples using components.
$ find . -name components -print
./provisioning/legacy/custom_config/components
./ethernet/enc28j60/components
./bluetooth/esp_ble_mesh/ble_mesh_coex_test/components
./bluetooth/esp_ble_mesh/aligenie_demo/components
./system/unit_test/components
./system/console/advanced/components
./system/gcov/components
./peripherals/rmt/musical_buzzer/components
./peripherals/rmt/ir_protocols/components
./peripherals/rmt/step_motor/components
./peripherals/spi_master/hd_eeprom/components
./peripherals/pcnt/rotary_encoder/components
./peripherals/gpio/matrix_keyboard/components
./peripherals/secure_element/atecc608_ecdsa/components
./peripherals/mcpwm/mcpwm_brushed_dc_control/components
./storage/custom_flash_driver/components
./build_system/cmake/import_prebuilt/prebuilt/components
./cxx/experimental/esp_mqtt_cxx/components
./protocols/http2_request/components
./protocols/slip/slip_udp/components
./protocols/pppos_client/components
$ find . -name components -print
./provisioning/legacy/custom_config/components
./ethernet/enc28j60/components
./bluetooth/esp_ble_mesh/ble_mesh_coex_test/components
./bluetooth/esp_ble_mesh/aligenie_demo/components
./system/unit_test/components
./system/console/advanced/components
./system/gcov/components
./peripherals/rmt/musical_buzzer/components
./peripherals/rmt/ir_protocols/components
./peripherals/rmt/step_motor/components
./peripherals/spi_master/hd_eeprom/components
./peripherals/pcnt/rotary_encoder/components
./peripherals/gpio/matrix_keyboard/components
./peripherals/secure_element/atecc608_ecdsa/components
./peripherals/mcpwm/mcpwm_brushed_dc_control/components
./storage/custom_flash_driver/components
./build_system/cmake/import_prebuilt/prebuilt/components
./cxx/experimental/esp_mqtt_cxx/components
./protocols/http2_request/components
./protocols/slip/slip_udp/components
./protocols/pppos_client/components
Re: Source files in sub-folder
It looks like you are missing src/ before the file name. Source file names are relative to the component CMakeLists file:
idf_component_register(
SRCS "src/msg.cpp"
INCLUDE_DIRS "./src" "include"
)
Note that the more standard arrangement is to have the component directory inside components directory of the project, i.e.
idf_component_register(
SRCS "src/msg.cpp"
INCLUDE_DIRS "./src" "include"
)
Note that the more standard arrangement is to have the component directory inside components directory of the project, i.e.
Code: Select all
project/
- components/
- component1/
CMakeLists.txt
(sources, headers)
- component2/
CMakeLists.txt
(sources, headers)
Who is online
Users browsing this forum: No registered users and 78 guests