CMake enable_language directive causes errors in Espressif32 ESP-IDF project

Hello,

I am trying to compile an ESP32 (ESP-IDF) project.

The failed output text:

CMake Error at CMakeLists.txt:3 (enable_language):
  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.


CMake Error at CMakeLists.txt:3 (enable_language):
  No CMAKE_CXX_COMPILER could be found.

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


CMake Error at CMakeLists.txt:3 (enable_language):
  No CMAKE_ASM_COMPILER could be found.

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

May I receive guidance on this issue?
I’ve tried clearing Intellisense index, removing and reinstall PlatformIO VSCode add-on, removing .pio directory. No recourse.

Did you try completely removing C:\Users\<user>\.platformio and rebuild the project?

PlatformIO runs, with the ESP-IDF framework, natively on Windows too. Can you give that a try?

I’ve tried it on Windows natively. No, it doesn’t work. Exactly same Cmake errors.

Edit: if I remove framework = espidf from platform.ini, I do not get any CMake errors and project configures successfully. Obviously I cannot compile then, as the project lacks ESP-IDF dependencies. I suppose the issue is on this command?

Does it work with @6.3.2?

Tried it. No it doesn’t.

Also not with a blank new ESP-IDF project as created by the “New Project” dialog in PIO Home?

The blank project works and compiles.

I have solved the issue.

For future reference,
The mistake was adding enable_language(C CXX ASM) CMake directive into root CMakeLists.txt file. For some reason that causes catastrophic errors. With default ESP-IDF project structure with no PlatformIO, this should work.

Removing it from root and adding to src/ directory’s CMakeLists.txt (or other configured base directory, I presume, as you can change it in platformio.ini) solved the issue.