PIO Init CMake failures in CLion after PIO update on my ESP8266 project

I ran PlatformIO update for my ESP8266 project, which updated Espressif8266 to v3.0.0 (and maybe other stuff that I didn’t notice at the time). Now, when I do a PIO Init, I get the following errors for all my targets:

CMake Error at CMakeLists.txt:33 (add_executable):
  C_STANDARD is set to invalid value '17'

This references the following line at the bottom of the CMakeLists.txt file:

add_executable(Z_DUMMY_TARGET ${SRC_LIST})

I’ve never really understood what the Z_DUMMY_TARGET is.
I tried re-creating my project from scratch in a new directory and invalidating CLion caches, but I still get the same error.

Is anyone else having this problem, or can someone offer some advice on how I can resolve it?
Many thanks!

Well the C standard is C17 though.


And that also exists as a valid standard.

Regarding simliar issues of CMake not recognizing C++17 e.g. here indicates that CMake probably has to be updated to recognize it.

Are you running the latest version of CLion? When you go into File → Settings → Buid,Execution,Deployment → Toolchains, what does it show for “CMake Version”?

Does it help if you grab the latest CMake 3.20.4 ZIP version of it at Download | CMake and point CLion to it? (Change ‘Bundled’ to ‘Custom’)

Okay well 3.20.4 willy not actually work. When you look at C_STANDARD — CMake 3.25.2 Documentation it says

Supported values are 90, 99 and 11.

When you turn the version to git-master in the upper left corner it will say

Supported values are 90, 99, 11, 17, 23.

So C17 (and C23) support in CMake is extremely bleeding-edge now. Let me see where you can grab such a development version.

Ahh, they’re at Index of /files/dev, posted right at the bottom of the initial CMake download page I posted. You should be able to e.g. grab cmake-3.21.20210619-gb8039a7-windows-x86_64.zip. Let me try.

1 Like

Yeah that works for me. Created a new ESP8266 project, and as soon as you create a .c file in the project and refresh the CMake project, you get

I went ahead and downloaded the git-master version from the link above for my OS and pointed to it in CLion. It will warn about the version…

but after reloading the CMake project yet again with the new CMake…

it actually works fine :slight_smile:

Arduino-ESP8266 is also pretty much the only project I know of using C17 and a very new compiler, so you shouldn’t have problems with other projects…

EDIT: Note that I’ve also set up my CMake Toolchain for C:\Users\<user>\.platformio\packages\toolchain-xtensa\bin.

1 Like

I’m on a Mac, so I installed: cmake-3.21.20210619-gb8039a7-macos-universal.dmg
This fixed it for me also - PIO init works and compiled ok :slight_smile:

Thanks so much for the quick replies Max!

I also downloaded CMake 3.21.x and it works now. I also had to modify a setting for it to work properly.
open File | Settings | Languages & Frameworks | C/C++ | Clangd* and append ,–target=riscv32 to the end of clangd diagnostics options.

Here is why: Clangd error on placement new operator – IDEs Support (IntelliJ Platform) | JetBrains

1 Like

when using ESP8266 the standard is automatically set to C17 and the error is still present, no matter if I update CMAKE.
can someone from platformio fix this please?

Arduino-ESP8266 using C17 with CLion by default not having a CMake version that supports this C language version is not something that can be fixed by PlatformIO, but rather CLion. Can you open a bug report in https://youtrack.jetbrains.com/issues/CPP?