Page 1 of 1

Directory Restructure - ESPNOW-example

Posted: Fri Aug 22, 2025 6:54 pm
by akhan@eleappower.com
I am looking to restructure the project to an AUTOSAR formatted version as shown below:

GA_Restructure/
├─ target/ <-- main component
│ ├─ source/
│ │ ├─ GA_main.c <-- contains app_main()
│ │ └─ wifi.c
│ ├─ include/
│ │ └─ wifi.h
│ └─ CMakeLists.txt <-- component CMakeLists
├─ CMakeLists.txt <-- root project CMakeLists
└─ sdkconfig

So I've been having issues with building this. It seems it cannot find app_main.
In the root CMake list I set IDF_MAIN_COMPONENT to look at the target folder.

In the component CMakelist I defined idf_component_register to look at source/GA_main.c for app_main.

Re: Directory Restructure - ESPNOW-example

Posted: Mon Aug 25, 2025 2:31 am
by Sprite
Can you post both CMakeFiles.txt files?

Re: Directory Restructure - ESPNOW-example

Posted: Mon Aug 25, 2025 2:34 pm
by akhan@eleappower.com
Oh sorry attached root and components CMAKElists

Re: Directory Restructure - ESPNOW-example

Posted: Tue Aug 26, 2025 4:13 am
by nopnop2002

Code: Select all

# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

set(EXTRA_COMPONENT_DIRS ${CMAKE_CURRENT_LIST_DIR}/target)
#set(EXTRA_COMPONENTS_DIRS ${PROJECT_SOURCE_DIR}/target)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(test)

Re: Directory Restructure - ESPNOW-example

Posted: Tue Aug 26, 2025 8:05 am
by MicroController
Guess that's not going to work. There are no component directories inside "target".

Re: Directory Restructure - ESPNOW-example

Posted: Tue Aug 26, 2025 3:20 pm
by akhan@eleappower.com
Hi

Actually this line:

set(EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/target")

worked for me. As in I was able to build it without seeing any issues.

For context my directory structure did change a bit

target
|
||---esp32
|||---Include
|||---Source

Thank you.