As of version 3.3.1, CMake sets CMAKE_C11_STANDARD_COMPILE_OPTION and CMAKE_C11_EXTENSION_COMPILE_OPTION for GCC >= 4.7, and checks for C11 features for GCC >= 4.6. It also means CMake itself will be built with -std=gnu11 if GCC >= 4.7 is used.
However, GCC only has full C11 support with the 4.9 release according to https://gcc.gnu.org/wiki/C11Status. Specifically, support for C11's _Thread_local is only present on GCC >= 4.9. This combination makes CMake fail to build with GCC 4.7 and 4.8 on FreeBSD, as runetype.h uses _Thread_local and the fact that -std=gnu11 is passed makes it not be a typedef or define for something else that would work. Adjust the GCC feature detection code to only consider C11 support to exist on GCC >= 4.9. Bug: http://www.cmake.org/Bug/view.php?id=15741 --- Modules/Compiler/GNU-C-FeatureTests.cmake | 7 +------ Modules/Compiler/GNU-C.cmake | 7 ++----- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/Modules/Compiler/GNU-C-FeatureTests.cmake b/Modules/Compiler/GNU-C-FeatureTests.cmake index b3fe33f..c7f5050 100644 --- a/Modules/Compiler/GNU-C-FeatureTests.cmake +++ b/Modules/Compiler/GNU-C-FeatureTests.cmake @@ -1,12 +1,7 @@ set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 404") -# GNU 4.7 correctly sets __STDC_VERSION__ to 201112L, but GNU 4.6 sets it -# to 201000L. As the former is strictly greater than the latter, test only -# for the latter. If in the future CMake learns about a C feature which was -# introduced with GNU 4.7, that should test for the correct version, similar -# to the distinction between __cplusplus and __GXX_EXPERIMENTAL_CXX0X__ tests. -set(GNU46_C11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201000L") +set(GNU49_C11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L") set(_cmake_feature_test_c_static_assert "${GNU46_C11}") # Since 4.4 at least: set(GNU44_C99 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L") diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake index 031ab73..f1036db 100644 --- a/Modules/Compiler/GNU-C.cmake +++ b/Modules/Compiler/GNU-C.cmake @@ -14,12 +14,9 @@ if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") endif() -if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) +if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") -elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) - set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c1x") - set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu1x") endif() if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) @@ -34,7 +31,7 @@ macro(cmake_record_c_compile_features) endmacro() set(_result 0) - if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) + if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9) _get_gcc_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES) endif() if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) -- 2.5.2 -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers