summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-09-18 10:00:51 -0400
committerCMake Topic Stage <kwrobot@kitware.com>2015-09-18 10:00:51 -0400
commite3ace61212db5c960132ef0868f49cf05fe1c021 (patch)
treeeec9428aeaaa0b2c026ba51ac7cd800ba98bd27e /Modules
parent418f08d029e35f1776810d3ff3488e702004b023 (diff)
parent7235334a2f1b9a627cc1cdbc701ae0768b6e32c3 (diff)
downloadcmake-e3ace61212db5c960132ef0868f49cf05fe1c021.tar.gz
Merge topic 'compute-default-dialect'
7235334a Project: Determine default language dialect for the compiler.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeCCompiler.cmake.in1
-rw-r--r--Modules/CMakeCCompilerId.c.in11
-rw-r--r--Modules/CMakeCXXCompiler.cmake.in1
-rw-r--r--Modules/CMakeCXXCompilerId.cpp.in10
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake5
-rw-r--r--Modules/Compiler/AppleClang-C.cmake5
-rw-r--r--Modules/Compiler/AppleClang-CXX.cmake6
-rw-r--r--Modules/Compiler/Clang-C.cmake9
-rw-r--r--Modules/Compiler/Clang-CXX.cmake7
-rw-r--r--Modules/Compiler/GNU-C.cmake10
-rw-r--r--Modules/Compiler/GNU-CXX.cmake5
-rw-r--r--Modules/Compiler/SunPro-CXX.cmake7
12 files changed, 62 insertions, 15 deletions
diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in
index 86cd894505..2ad2f34ea1 100644
--- a/Modules/CMakeCCompiler.cmake.in
+++ b/Modules/CMakeCCompiler.cmake.in
@@ -2,6 +2,7 @@ set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@")
set(CMAKE_C_COMPILER_ARG1 "@CMAKE_C_COMPILER_ARG1@")
set(CMAKE_C_COMPILER_ID "@CMAKE_C_COMPILER_ID@")
set(CMAKE_C_COMPILER_VERSION "@CMAKE_C_COMPILER_VERSION@")
+set(CMAKE_C_STANDARD_COMPUTED_DEFAULT "@CMAKE_C_STANDARD_COMPUTED_DEFAULT@")
set(CMAKE_C_COMPILE_FEATURES "@CMAKE_C_COMPILE_FEATURES@")
set(CMAKE_C90_COMPILE_FEATURES "@CMAKE_C90_COMPILE_FEATURES@")
set(CMAKE_C99_COMPILE_FEATURES "@CMAKE_C99_COMPILE_FEATURES@")
diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in
index 09ae50936d..b224007807 100644
--- a/Modules/CMakeCCompilerId.c.in
+++ b/Modules/CMakeCCompilerId.c.in
@@ -24,6 +24,17 @@ char const* qnxnto = "INFO" ":" "qnxnto[]";
@CMAKE_C_COMPILER_ID_PLATFORM_CONTENT@
@CMAKE_C_COMPILER_ID_ERROR_FOR_TEST@
+const char* info_language_dialect_default = "INFO" ":" "dialect_default["
+#if !defined(__STDC_VERSION__)
+ "90"
+#elif __STDC_VERSION__ >= 201000L
+ "11"
+#elif __STDC_VERSION__ >= 199901L
+ "99"
+#else
+#endif
+"]";
+
/*--------------------------------------------------------------------------*/
#ifdef ID_VOID_MAIN
diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in
index af79a31bb3..c6582a7681 100644
--- a/Modules/CMakeCXXCompiler.cmake.in
+++ b/Modules/CMakeCXXCompiler.cmake.in
@@ -2,6 +2,7 @@ set(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@")
set(CMAKE_CXX_COMPILER_ARG1 "@CMAKE_CXX_COMPILER_ARG1@")
set(CMAKE_CXX_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@")
set(CMAKE_CXX_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@")
+set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "@CMAKE_CXX_STANDARD_COMPUTED_DEFAULT@")
set(CMAKE_CXX_COMPILE_FEATURES "@CMAKE_CXX_COMPILE_FEATURES@")
set(CMAKE_CXX98_COMPILE_FEATURES "@CMAKE_CXX98_COMPILE_FEATURES@")
set(CMAKE_CXX11_COMPILE_FEATURES "@CMAKE_CXX11_COMPILE_FEATURES@")
diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in
index cc3ab49aba..d467507665 100644
--- a/Modules/CMakeCXXCompilerId.cpp.in
+++ b/Modules/CMakeCXXCompilerId.cpp.in
@@ -23,6 +23,16 @@ char const* qnxnto = "INFO" ":" "qnxnto[]";
@CMAKE_CXX_COMPILER_ID_PLATFORM_CONTENT@
@CMAKE_CXX_COMPILER_ID_ERROR_FOR_TEST@
+const char* info_language_dialect_default = "INFO" ":" "dialect_default["
+#if __cplusplus >= 201402L
+ "14"
+#elif __cplusplus >= 201103L
+ "11"
+#else
+ "98"
+#endif
+"]";
+
/*--------------------------------------------------------------------------*/
int main(int argc, char* argv[])
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index c699315ec9..81f4ae6acf 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -102,6 +102,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}" PARENT_SCOPE)
set(CMAKE_${lang}_SIMULATE_ID "${CMAKE_${lang}_SIMULATE_ID}" PARENT_SCOPE)
set(CMAKE_${lang}_SIMULATE_VERSION "${CMAKE_${lang}_SIMULATE_VERSION}" PARENT_SCOPE)
+ set(CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT "${CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT}" PARENT_SCOPE)
endfunction()
include(CMakeCompilerIdDetection)
@@ -487,6 +488,9 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
if("${info}" MATCHES "INFO:qnxnto\\[\\]")
set(COMPILER_QNXNTO 1)
endif()
+ if("${info}" MATCHES "INFO:dialect_default\\[([^]\"]*)\\]")
+ set(CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT "${CMAKE_MATCH_1}")
+ endif()
endforeach()
# Construct compiler version from components if needed.
@@ -590,6 +594,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
set(CMAKE_${lang}_SIMULATE_VERSION "${CMAKE_${lang}_SIMULATE_VERSION}" PARENT_SCOPE)
set(CMAKE_EXECUTABLE_FORMAT "${CMAKE_EXECUTABLE_FORMAT}" PARENT_SCOPE)
set(COMPILER_QNXNTO "${COMPILER_QNXNTO}" PARENT_SCOPE)
+ set(CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT "${CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT}" PARENT_SCOPE)
endfunction()
#-----------------------------------------------------------------------------
diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake
index 10454f6492..1db7d9ee88 100644
--- a/Modules/Compiler/AppleClang-C.cmake
+++ b/Modules/Compiler/AppleClang-C.cmake
@@ -13,7 +13,10 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0)
endif()
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0)
- set(CMAKE_C_STANDARD_DEFAULT 99)
+ if (NOT CMAKE_C_STANDARD_COMPUTED_DEFAULT)
+ message(FATAL_ERROR "CMAKE_C_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_C_COMPILER_ID} (${CMAKE_C_COMPILER}) version ${CMAKE_C_COMPILER_VERSION}")
+ endif()
+ set(CMAKE_C_STANDARD_DEFAULT ${CMAKE_C_STANDARD_COMPUTED_DEFAULT})
endif()
macro(cmake_record_c_compile_features)
diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake
index 1ba8a7743a..031851a895 100644
--- a/Modules/Compiler/AppleClang-CXX.cmake
+++ b/Modules/Compiler/AppleClang-CXX.cmake
@@ -23,9 +23,13 @@ elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
endif()
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0)
- set(CMAKE_CXX_STANDARD_DEFAULT 98)
+ if (NOT CMAKE_CXX_STANDARD_COMPUTED_DEFAULT)
+ message(FATAL_ERROR "CMAKE_CXX_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) version ${CMAKE_CXX_COMPILER_VERSION}")
+ endif()
+ set(CMAKE_CXX_STANDARD_DEFAULT ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT})
endif()
+
macro(cmake_record_cxx_compile_features)
macro(_get_appleclang_features std_version list)
record_compiler_features(CXX "${std_version}" ${list})
diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake
index 548d0a5960..ef3a46a3c2 100644
--- a/Modules/Compiler/Clang-C.cmake
+++ b/Modules/Compiler/Clang-C.cmake
@@ -17,10 +17,11 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4)
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
endif()
-if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.6)
- set(CMAKE_C_STANDARD_DEFAULT 11)
-elseif(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4)
- set(CMAKE_C_STANDARD_DEFAULT 99)
+if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4)
+ if (NOT CMAKE_C_STANDARD_COMPUTED_DEFAULT)
+ message(FATAL_ERROR "CMAKE_C_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_C_COMPILER_ID} (${CMAKE_C_COMPILER}) version ${CMAKE_C_COMPILER_VERSION}")
+ endif()
+ set(CMAKE_C_STANDARD_DEFAULT ${CMAKE_C_STANDARD_COMPUTED_DEFAULT})
endif()
macro(cmake_record_c_compile_features)
diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake
index 84b2c741dd..fcc731901f 100644
--- a/Modules/Compiler/Clang-CXX.cmake
+++ b/Modules/Compiler/Clang-CXX.cmake
@@ -31,8 +31,11 @@ elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y")
endif()
-if(UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
- set(CMAKE_CXX_STANDARD_DEFAULT 98)
+if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
+ if (NOT CMAKE_CXX_STANDARD_COMPUTED_DEFAULT)
+ message(FATAL_ERROR "CMAKE_CXX_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) version ${CMAKE_CXX_COMPILER_VERSION}")
+ endif()
+ set(CMAKE_CXX_STANDARD_DEFAULT ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT})
endif()
macro(cmake_record_cxx_compile_features)
diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake
index 031ab7364f..5c68b1ed73 100644
--- a/Modules/Compiler/GNU-C.cmake
+++ b/Modules/Compiler/GNU-C.cmake
@@ -22,12 +22,14 @@ elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6)
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu1x")
endif()
-if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0)
- set(CMAKE_C_STANDARD_DEFAULT 11)
-elseif(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4)
- set(CMAKE_C_STANDARD_DEFAULT 90)
+if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4)
+ if (NOT CMAKE_C_STANDARD_COMPUTED_DEFAULT)
+ message(FATAL_ERROR "CMAKE_C_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_C_COMPILER_ID} (${CMAKE_C_COMPILER}) version ${CMAKE_C_COMPILER_VERSION}")
+ endif()
+ set(CMAKE_C_STANDARD_DEFAULT ${CMAKE_C_STANDARD_COMPUTED_DEFAULT})
endif()
+
macro(cmake_record_c_compile_features)
macro(_get_gcc_features std_version list)
record_compiler_features(C "${std_version}" ${list})
diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake
index 2dc02f0c06..cbb0293133 100644
--- a/Modules/Compiler/GNU-CXX.cmake
+++ b/Modules/Compiler/GNU-CXX.cmake
@@ -35,7 +35,10 @@ elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
endif()
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4)
- set(CMAKE_CXX_STANDARD_DEFAULT 98)
+ if (NOT CMAKE_CXX_STANDARD_COMPUTED_DEFAULT)
+ message(FATAL_ERROR "CMAKE_CXX_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) version ${CMAKE_CXX_COMPILER_VERSION}")
+ endif()
+ set(CMAKE_CXX_STANDARD_DEFAULT ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT})
endif()
macro(cmake_record_cxx_compile_features)
diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake
index e0c02d9331..ff68ee957e 100644
--- a/Modules/Compiler/SunPro-CXX.cmake
+++ b/Modules/Compiler/SunPro-CXX.cmake
@@ -36,8 +36,11 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13)
set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=c++11")
endif()
-if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13)
- set(CMAKE_CXX_STANDARD_DEFAULT 98)
+if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13)
+ if (NOT CMAKE_CXX_STANDARD_COMPUTED_DEFAULT)
+ message(FATAL_ERROR "CMAKE_CXX_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) version ${CMAKE_CXX_COMPILER_VERSION}")
+ endif()
+ set(CMAKE_CXX_STANDARD_DEFAULT ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT})
endif()
macro(cmake_record_cxx_compile_features)