I'm attempting to build a project using the esp-idf.
I've been using the idf.py script and the idf_component_register functions and that has worked however I'd like to switch to pure cmake to make debugging my own cmake files easier and to reduce the amount of 'magic' in the system a little bit.
I've tried using idf_build_process(esp32) instead of the script that seems to call cmake again in script mode which disallows certain cmake commands. My project structure is as follows:
-root
---esp-idf
---project
-----build
-----components
-------custom
---------custom.h/custom.c
---------CMakeLists.txt
-----main
-------main.c
-------CMakeLists.txt
Before running the cmake command I run the export.sh first to set any needed environment variables.
Then I cd into build and run cmake ..
Code: Select all
# root/project/CMakeLists.txt
cmake_minimum_required(VERSION 3.5...3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
idf_build_process(esp32)
project(hello-world)
Code: Select all
# root/project/main/CMakeLists.txt
#idf_component_register(
# SRCS "main.c"
# INCLUDE_DIRS "${COMPONENT_DIR}"
#)
add_executable(main.elf main.c)
target_link_libraries(main.elf PRIVATE custom)
idf_build_executable(main.elf)
Code: Select all
# root/project/components/custom/CMakeLists.txt
add_library(
custom STATIC
custom.c
custom.h
)
target_include_directories(custom PUBLIC ${CMAKE_CURRENT_LIST_DIR})
Any hints regarding this and how to better structure a cmake idf project are highly appreciated.
Thanks.