[cmake-developers] [PATCH] Features: Only enable C11 support on GCC >= 4.9.

Stephen Kelly steveire at gmail.com
Mon Sep 14 13:16:24 EDT 2015


Raphael Kubo da Costa wrote:

> Adjust the GCC feature detection code to only consider C11 support to
> exist on GCC >= 4.9.

If you do that you must remove the definition of 
CMAKE_CXX11_STANDARD_COMPILE_OPTION for GNU < 4.8.1 too.

IOW, this patch is not correct, and should not be merged.

According to

 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203066

sys/cdefs.h requires that if you use -std=c11, your compiler must have the 
c_thread_local feature. Therefore, you must not use -std=c11 with GNU < 4.9.

So, because of the apparent requirement of the FreeBSD header, if you build 
cmake with GNU < 4.9, you must configure it with CMake_NO_C_STANDARD=TRUE.

Of course, the actual bug is in sys/cdefs.h as comment #2 in 

 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203066

describes.

The __STDC_VERSION__ macro on its own (just like the __cplusplus macro on 
its own) is not suitable for feature testing. You must check the compiler 
vendor and version (or use SD-6 for C++).

Comment #3 in 

 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203066

seems strange to me, as it assumes that changing Ports packages is 
sufficient to solving the problem. Should third parties be able to build 
their code on FreeBSD? If so, then a compiler vendor and version check in 
sys/cdefs.h is the right thing to do, and I recommend getting that done.

So, in summary, there is no bug in CMake, but either your package needs to 
change (to add CMake_NO_C_STANDARD=TRUE), or sys/cdefs.h needs to change, or 
both.

Thanks,

Steve.




More information about the cmake-developers mailing list