CLion exporter adds -std=c++11 also on .c files

I have been testing the new Clion exporter (why just not call it cmake exporter? :slight_smile: ) generates following compile options

target_compile_options (APP PRIVATE

I have some modules with .c files and -std=c++11 is invalid on macOS clang (but I assume any compiler would complain) for .C or Objective C files.

Because we envision a future CMake exporter being much more general. See the discussion here:

Does the invalid flag cause a warning or an error?

Thanks for the pointer , I have been missing that thread!

Yes, the invalid flag cause a compile error because CMake tries to add -std=C++11 to regular C files.
I have tested it compiling manually (I don’t have CLion) but I think that the error will be just the same on compiling with CLion.

target_compile_options(TARGET PRIVATE -std=c++11) is not the proper way to get C++11 support, especially since the C compiler doesn’t know what that option means and fails.

You should use the following instead:

set_target_properties(TARGET PROPERTIES
  CXX_EXTENSIONS OFF # to get -std=c++11 instead of -std=gnu++11
1 Like

Thanks, that’s saved me a bit of research :slight_smile:

This is now fixed on the develop branch.

Excellent! :smile: