summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorRaphael Kubo da Costa <rakuco@FreeBSD.org>2015-09-15 16:31:12 +0200
committerBrad King <brad.king@kitware.com>2015-09-15 10:51:54 -0400
commitffa6f057b4ae07c9dc7b9e1d12ecc0a2e19333a1 (patch)
tree3a18a85325fb2d883b0019a629ef9d69149dd5e8 /CMakeLists.txt
parentcda189356e7e0a897377c3d7ed02ea3a3ad1de5a (diff)
downloadcmake-ffa6f057b4ae07c9dc7b9e1d12ecc0a2e19333a1.tar.gz
Avoid using C11 to build CMake if _Thread_local support is broken
Support for C11's _Thread_local was introduced in GCC in the 4.9 series, even though we make the C11 compiler flags available in CMake with GCC >= 4.6. FreeBSD's runetype.h uses _Thread_local, which causes CMake's own build to fail when using GCC < 4.9 and -std=gnu11: /usr/include/runetype.h:92:22: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'const' extern _Thread_local const _RuneLocale *_ThreadRuneLocale; Add a test for _Thread_local support and only build CMake itself with C11 support if it works. Bug: http://www.cmake.org/Bug/view.php?id=15741
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt7
1 files changed, 6 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5e13a7e0f4..94d138c3b5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,7 +38,12 @@ endif()
# Use most-recent available language dialects with GNU and Clang
if(NOT DEFINED CMAKE_C_STANDARD AND NOT CMake_NO_C_STANDARD)
- set(CMAKE_C_STANDARD 11)
+ include(${CMake_SOURCE_DIR}/Source/Checks/cm_c11_thread_local.cmake)
+ if(NOT CMake_C11_THREAD_LOCAL_BROKEN)
+ set(CMAKE_C_STANDARD 11)
+ else()
+ set(CMAKE_C_STANDARD 99)
+ endif()
endif()
if(NOT DEFINED CMAKE_CXX_STANDARD AND NOT CMake_NO_CXX_STANDARD)
include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx14_cstdio.cmake)