Includes and CMakeLists.txt
Posted: Sat Dec 21, 2024 4:07 am
I'm new to CMake and must be making a simple mistake. Please help.
I am using Expressif Eclipse IDE with the ESP32-S3-WROOM-1.
Problem: In my I2C.h file, the compiler gives an error saying "No such file or directory" for #include "driver/i2c_master.h
Here is how I have my project structured...
I have copied the ESP-IDF Components folder into my project into a folder called ESP-IDF_Components.
> _APP
> _Middleware
> _Middleware > MCU
> _Middleware > MCU > I2C.c & I2C.h
> ESP-IDF_Components
MCU Folder CMakeLists.txt
Main CMakeLists.txt:
If I change the include above to be this "#include "../../ESP-IDF_Components/esp_driver_i2c/include/driver/i2c_master.h", then it works, but now it complains about not being able to find i2c_types.h
I think I have misunderstanding about CMake and maybe even the concept of Components. Can someone please point out my mistake?
I am using Expressif Eclipse IDE with the ESP32-S3-WROOM-1.
Problem: In my I2C.h file, the compiler gives an error saying "No such file or directory" for #include "driver/i2c_master.h
Here is how I have my project structured...
I have copied the ESP-IDF Components folder into my project into a folder called ESP-IDF_Components.
> _APP
> _Middleware
> _Middleware > MCU
> _Middleware > MCU > I2C.c & I2C.h
> ESP-IDF_Components
MCU Folder CMakeLists.txt
Code: Select all
# COMPONENT LOCATION: _Middleware/MCU
# List any directories NOT already referenced by the required Components.
set(include_dirs
"."
)
# List all Components PRIVATELY REQUIRED by this Component.
set(priv_requires
""
)
# List all Components REQUIRED by this Component.
set(requires
"_App"
"console"
"esp_driver_i2c"
"esp_driver_tsens"
)
# List all C/C++ files in this Component.
set(srcs
"I2C.c"
"TEMPERATURE.c"
)
# Register the Component.
idf_component_register(
INCLUDE_DIRS "${include_dirs}"
PRIV_REQUIRES "${priv_requires}"
REQUIRES "${requires}"
SRCS "${srcs}")
Code: Select all
# COMPONENT LOCATION: MASTER
# Minimum Version of CMake allowed.
cmake_minimum_required(VERSION 3.16)
# List the Component Directories.
# Each of these locations needs a CMakeLists.txt file.
set(COMPONENT_DIRS
"_App"
"_Middleware"
"_Middleware/MCU"
"_Middleware/Tools"
"ESP-IDF_Components"
)
# Path to CMake
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
# Project name
project(project)
# Enable C Language
enable_language(C)
I think I have misunderstanding about CMake and maybe even the concept of Components. Can someone please point out my mistake?