CMAKE_SYSTEM_NAME wrong when using esp-idf in custom cmake project

geoff.dudds
Posts: 1
Joined: Sun Mar 10, 2024 9:11 pm

CMAKE_SYSTEM_NAME wrong when using esp-idf in custom cmake project

Postby geoff.dudds » Sun Mar 10, 2024 9:38 pm

I am trying use pure cmake to build a hello-world.
I am following the documentation "Using ESP-IDF in Custom CMake Projects" and example "idf_as_lib":
https://docs.espressif.com/projects/esp ... e-projects
https://github.com/espressif/esp-idf/bl ... eLists.txt

I am getting an error about the build system not being set correctly.

Code: Select all

[proc] Executing command: /opt/esp/tools/cmake/3.24.0/bin/cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/opt/esp/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp-elf-gcc -DCMAKE_CXX_COMPILER:FILEPATH=/opt/esp/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp-elf-g++ -S/workspaces/dce-firmware-app -B/workspaces/dce-firmware-app/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is GNU 13.2.0
[cmake] -- The CXX compiler identification is GNU 13.2.0
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: /opt/esp/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp-elf-gcc - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: /opt/esp/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp-elf-g++ - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Found Git: /usr/bin/git (found version "2.34.1") 
[cmake] -- Checking Python dependencies...
[cmake] Python requirements are satisfied.
[cmake] Requirement files:
[cmake]  - /opt/esp/idf/tools/requirements/requirements.core.txt
[cmake] Python being checked: /opt/esp/python_env/idf5.3_py3.10_env/bin/python
[cmake] -- Project sdkconfig file /workspaces/dce-firmware-app/sdkconfig
[cmake] -- Compiler supported targets: xtensa-esp-elf
[cmake] -- cmake system type: Linux
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "/workspaces/dce-firmware-app/build/CMakeFiles/CMakeOutput.log".
[cmake] CMake Error at /opt/esp/idf/components/xtensa/project_include.cmake:21 (message):
[cmake]   Internal error, toolchain has not been set correctly by project (or an
[cmake]   invalid CMakeCache.txt file has been generated somehow)
[cmake] Call Stack (most recent call first):
[cmake]   /opt/esp/idf/tools/cmake/build.cmake:400 (include)
[cmake]   /opt/esp/idf/tools/cmake/build.cmake:624 (__build_process_project_includes)
[cmake]   CMakeLists.txt:13 (idf_build_process)
[cmake] 
[cmake] 
[proc] The command: /opt/esp/tools/cmake/3.24.0/bin/cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/opt/esp/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp-elf-gcc -DCMAKE_CXX_COMPILER:FILEPATH=/opt/esp/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp-elf-g++ -S/workspaces/dce-firmware-app -B/workspaces/dce-firmware-app/build -G Ninja exited with code: 1
My top level (and only) CMakeList.txt file looks like this:

Code: Select all

# For more information about build system see
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
cmake_minimum_required(VERSION 3.5)

project(dce)

# Include CMake file that provides ESP-IDF CMake build system APIs.
include($ENV{IDF_PATH}/tools/cmake/idf.cmake)

# Include ESP-IDF components in the build, may be thought as an equivalent of
# add_subdirectory() but with some additional processing and magic for ESP-IDF build
# specific build processes.
idf_build_process("esp32"
    COMPONENTS freertos esptool_py
    SDKCONFIG ${CMAKE_CURRENT_LIST_DIR}/sdkconfig
    BUILD_DIR ${CMAKE_BINARY_DIR})

add_executable(${CMAKE_PROJECT_NAME}.elf ./main/main.cpp)

# Create the project executable and plainly link the newlib component to it using
# its alias, idf::newlib.
target_link_libraries(${CMAKE_PROJECT_NAME}.elf idf::newlib)

# Let the build system know what the project executable is to attach more targets, dependencies, etc.
idf_build_executable(${CMAKE_PROJECT_NAME}.elf)
It appears that the cmake variable "CMAKE_SYSTEM_NAME" is set to "Linux" when cmake reaches "project_include.cmake". It is expecting "Generic".
Has anyone else had this problem before?

A few details:
- I am espressif's devcontainer & dockerfile image ("espressif/idf")
- The hello world was building when I used idf.py

thanks,

Who is online

Users browsing this forum: No registered users and 86 guests