PlatformIO Community

Esp-idf compile no CMAKE_C_COMPILER

I’ve installed esp-idf and I’m trying to compile example build_system/cmake/idf_as_lib
and I got the error in the ESP-IDF CMD which not allow me to compile that example. The same problem is in Visual Studio Code.

Probably I should set environment path CMAKE_C_COMPILER but I don’t know what should I point.
I’ve installed CMAKE on my windows

My actual environment paths:
IDF_PYTHON_ENV_PATH → C:\esp\tools.espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe
IDF_TOOLS_PATH → C:\esp\tools.espressif
IDF_PATH → C:\esp\esp-idf

C:\esp\esp-idf\examples\build_system\cmake\idf_as_lib>idf.py build
Executing action: all (aliases: build)
Running cmake in directory c:\esp\esp-idf\examples\build_system\cmake\idf_as_lib\build
Executing "cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DESP_PLATFORM=1 -DCCACHE_ENABLE=1 c:\esp\esp-idf\examples\build_system\cmake\idf_as_lib"...
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:3 (project):
  No CMAKE_C_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!
See also "C:/esp/esp-idf/examples/build_system/cmake/idf_as_lib/build/CMakeFiles/CMakeOutput.log".
See also "C:/esp/esp-idf/examples/build_system/cmake/idf_as_lib/build/CMakeFiles/CMakeError.log".
cmake failed with exit code 1

CMakeList


project(idf_as_lib C)

if("${TARGET}" STREQUAL "esp32")
    # Include for ESP-IDF build system functions
    include($ENV{IDF_PATH}/tools/cmake/idf.cmake)
    # Create idf::esp32 and idf::freertos static libraries
    idf_build_process(esp32
                    # try and trim the build; additional components
                    # will be included as needed based on dependency tree
                    #
                    # although esptool_py does not generate static library,
                    # processing the component is needed for flashing related
                    # targets and file generation
                    COMPONENTS esp32 freertos esptool_py
                    SDKCONFIG ${CMAKE_CURRENT_LIST_DIR}/sdkconfig
                    BUILD_DIR ${CMAKE_BINARY_DIR})
else()
    # Create stubs for esp32 and freertos, stub::esp32 and stub::freertos
    add_subdirectory(stubs/esp32)
    add_subdirectory(stubs/freertos)
    add_subdirectory(stubs/spi_flash)
endif()

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(elf_file ${CMAKE_PROJECT_NAME}.elf)
add_executable(${elf_file} main.c)

# Link the static libraries to the executable
if("${TARGET}" STREQUAL "esp32")
    target_link_libraries(${elf_file} idf::esp32 idf::freertos idf::spi_flash)
    # Attach additional targets to the executable file for flashing,
    # linker script generation, partition_table generation, etc.
    idf_build_executable(${elf_file})
else()
    target_link_libraries(${elf_file} stub::esp32 stub::freertos stub::spi_flash)
endif()

This forum is intended for developers who use PlatformIO for ESP-IDF. See examples platform-espressif32/examples at develop · platformio/platform-espressif32 · GitHub

For the idf.py, please forward your question to ESP-IDF - ESP32 Forum