CMakeList build system question

adesandr
Posts: 22
Joined: Sat May 05, 2018 10:51 am

CMakeList build system question

Postby adesandr » Thu Apr 30, 2020 8:37 pm

Hello,

Dev env : Linux Ubuntu 18.04

My project is structured like this :
  1. My_project :
  2.     subproject 1
  3.         main
  4.             main.c
  5.             file1.c
  6.             CMakeList.txt
  7.         CMakeList.txt
  8.            
  9.     subproject 2
  10.         main
  11.             main.c
  12.             file 2.c
  13.             CMakeList.txt
  14.         CMakeList.txt
  15.  
  16.     extra_component
  17.         Component1
  18.             file3.c
  19.             filee3.h
  20.             CMakeList.txt
  21.         Component2
  22.             file4.c
  23.             file4.h
  24.             CmakeList.txt
Both subproject (1&2) used the components inside the extra_components directories.

I used this scheme because my project need to build two different .bin to dowload two different board.

The Subproject CmainList is as follow :
  1. cmake_minimum_required(VERSION 3.5)
  2. set(PROJECT_VER "1.0.2")
  3. set(EXTRA_COMPONENT_DIRS "${PROJECT_DIR}/../extra_components")
  4. include($ENV{IDF_PATH}/tools/cmake/project.cmake)
  5. project(esp-mad-server)  
The CmainList for the main component of the subproject is as follow :
  1. idf_component_register(SRCS "main.c" "file1.c"
  2.                REQUIRES Component1 Component2)
When i try to build one subproject, Cmake failed with the following error :

CMake Error at /home/adesandr/esp-idf/tools/cmake/build.cmake:185 (message):
Failed to resolve component ‘Component1'.

I can’t understand that is wrong in my setup.

Thank you in advance for your help.

Regards.

adesandr
Posts: 22
Joined: Sat May 05, 2018 10:51 am

Re: CMakeList build system question

Postby adesandr » Fri May 01, 2020 1:01 pm

Hello,

Env Dev : Linux Ubuntu 18.04 /ESP-IDF 4.00

My_project is structured as follow :
  1. - My_Project/
  2.     - CMakeList.txt
  3.     - main/
  4.             - file1.c
  5.             - file1.h
  6.             - CMakeList.txt
  7. - extra_components/
  8.     - component1/
  9.         - file2.c
  10.         - file2.h
  11.         - CMakeList.txt
  12.     - component2/
  13.         - file3.c
  14.         - file3.h
  15.         - CMakeList.txt
My_Project/CMakeList.txt is as follow :
  1.     # The following lines of boilerplate have to be in your project's
  2. # CMakeLists in this exact order for cmake to work correctly
  3. cmake_minimum_required(VERSION 3.5)
  4.  
  5. # Project version
  6. set(PROJECT_VER "1.0.2")
  7.  
  8. # Additional directorie to search for components
  9. set(EXTRA_COMPONENT_DIRS "${PROJECT_DIR}/../extra_components")
  10.  
  11. include($ENV{IDF_PATH}/tools/cmake/project.cmake)
  12.  
  13. project(My_Project)
My_Project/main/CMakeList.txt is as follow
  1. idf_component_register(SRCS "file1.c"
  2.                                         INCLUDE_DIRS " ")

/extra_components/component1/CMakeList.txt is as follow :
  1. idf_component_register(SRCS "file2.c"
  2.                     INCLUDE_DIRS "")

When i build My_Project, extra_components/component1and extra_component/component2 are not included in the components list, either in the components path ?

It seems that the command set(EXTRA_COMPONENT_DIRS "${PROJECT_DIR}/../extra_components") is not corrected interpreted.

If I change the structure of My_Project like in the ESP32 CMAKE build system documentation  :
  1. - My_Project/
  2.     - CMakeList.txt
  3.     - main/
  4.         - file1.c
  5.         - file1.h
  6.         - CMakeList.txt
  7.     - components/
  8.         - component1/
  9.             - file2.c
  10.             - file2.h
  11.             - CMakeList.txt
  12.         - component2/
  13.             - file3.c
  14.             - file3.h
  15.             - CMakeList.txt
The build is working properly.

Thank you in advance for your help.

Regards.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: CMakeList build system question

Postby ESP_Angus » Fri May 15, 2020 2:26 am

Hi adesandr,

Thanks for being patient while someone got back to you.

I think the problem is here:
adesandr wrote:
Fri May 01, 2020 1:01 pm
# Additional directorie to search for components
set(EXTRA_COMPONENT_DIRS "${PROJECT_DIR}/../extra_components")
The PROJECT_DIR is not set as a variable in this file, it's only set as a build property (see API for getting build properties.)

If you look closely at the build output log, there should be some error about failing to find directory "/../extra_components".

Suggest the following should work:

Code: Select all

# Additional directory to search for components
set(EXTRA_COMPONENT_DIRS "${CMAKE_SOURCE_DIR}/../extra_components")

Angus

adesandr
Posts: 22
Joined: Sat May 05, 2018 10:51 am

Re: CMakeList build system question

Postby adesandr » Sun May 31, 2020 6:08 pm

Hello,

Thank you very much ESP_Angus, it was the problem.
It's very curious because it works under windows (${PROJECT_DIR}, but not under Linux. Maybe under windows PROJECT_DIR is set in the PATH, i will check.

Problem solved :P

Regards.

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 96 guests