Adding Source Folders to a C++ Project
Posted: Thu Jan 04, 2024 9:40 pm
I'm quite new to IDF and CMake in general. I'm trying to add the FabGL source files to a dummy (blink example) C++ project. My folder structure looks like this:
My top level CMakeLists.txt file is like this:
Is this the correct way to include a subfolder of source files?
The CMakeLists.txt file within fabgl_src looks like this:
Within VSCode, when I save this file, it tries to configure the project and I get the following error:
Should I be using idf_component_register to include the FabGl source folders, should I be including them in a different way, or do I need to do something else?
I don't understand what idf_component_register is actually for - all I want to do is compile a bunch of source as one monolithic project for now.
Code: Select all
paul_fabgl
| CMakeLists.txt
| ...
|
+---fabgl_src
| | canvas.cpp
| | canvas.h
| | CMakeLists.txt
| | ...
|
+---main
| blink_example_main.c
| CMakeLists.txt
| idf_component.yml
| Kconfig.projbuild
Code: Select all
cmake_minimum_required(VERSION 3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/fabgl_src/CMakeLists.txt)
project(paul_fabgl)
The CMakeLists.txt file within fabgl_src looks like this:
Code: Select all
idf_component_register(SRC_DIRS "."
comdrivers
devdrivers
dispdrivers
emudevs
network
INCLUDE_DIRS "."
fonts
images
comdrivers
devdrivers
dispdrivers
emudevs
network
REQUIRES fatfs
spiffs
esp_adc_cal
ulp
nvs_flash
soc)
Code: Select all
[cmake] CMake Error at C:/esp32/frameworks/esp-idf-v5.1.2/tools/cmake/component.cmake:439 (message):
[cmake] Called idf_component_register from a non-component directory.
[cmake] Call Stack (most recent call first):
[cmake] fabgl_src/CMakeLists.txt:1 (idf_component_register)
I don't understand what idf_component_register is actually for - all I want to do is compile a bunch of source as one monolithic project for now.