summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-05-02 12:24:00 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-05-02 12:24:06 (GMT)
commita9e48968bb0f6b3919cb4ae3f00379631b98df5d (patch)
treeaab0464b4858ecd1172a006fd5188aa08161370b
parent4804c7f30ff659420cc0be5491bb77faa47a2f0c (diff)
parent9b97cb5562317ecb6fe65e6185eb6fda2b0ad7d7 (diff)
downloadCMake-a9e48968bb0f6b3919cb4ae3f00379631b98df5d.zip
CMake-a9e48968bb0f6b3919cb4ae3f00379631b98df5d.tar.gz
CMake-a9e48968bb0f6b3919cb4ae3f00379631b98df5d.tar.bz2
Merge topic 'add-language-standards-to-more-compilers'
9b97cb55 PGI: Add language standards for PGI daae564d Cray: Add language standards for the Cray compiler 25e83ce5 CompileFeatures: Let STD compile options be a list 1de70845 Compilers: Add common macros to be used by various compilers Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !784
-rw-r--r--Modules/Compiler/CMakeCommonCompilerMacros.cmake62
-rw-r--r--Modules/Compiler/Cray-C.cmake21
-rw-r--r--Modules/Compiler/Cray-CXX.cmake19
-rw-r--r--Modules/Compiler/Cray.cmake10
-rw-r--r--Modules/Compiler/PGI-C.cmake13
-rw-r--r--Modules/Compiler/PGI-CXX.cmake19
-rw-r--r--Modules/Compiler/PGI.cmake2
-rw-r--r--Source/cmLocalGenerator.cxx6
8 files changed, 151 insertions, 1 deletions
diff --git a/Modules/Compiler/CMakeCommonCompilerMacros.cmake b/Modules/Compiler/CMakeCommonCompilerMacros.cmake
new file mode 100644
index 0000000..cb365d6
--- /dev/null
+++ b/Modules/Compiler/CMakeCommonCompilerMacros.cmake
@@ -0,0 +1,62 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+# This module is shared by multiple languages and compilers; use include guard
+if (__COMPILER_CMAKE_COMMON_COMPILER_MACROS)
+ return()
+endif ()
+set(__COMPILER_CMAKE_COMMON_COMPILER_MACROS 1)
+
+
+# Check that a compiler's language standard is properly detected
+# Parameters:
+# lang - Language to check
+# stdver1 - Minimum version to set a given default for
+# std1 - Default to use for compiler ver >= stdver1
+# stdverN - Minimum version to set a given default for
+# stdN - Default to use for compiler ver >= stdverN
+#
+# The order of stdverN stdN pairs passed as arguments is expected to be in
+# monotonically increasing version order.
+#
+# Note:
+# This macro can be called with multiple version / std pairs to convey that
+# newer compiler versions may use a newer standard default.
+#
+# Example:
+# To specify that compiler version 6.1 and newer defaults to C++11 while
+# 4.8 <= ver < 6.1 default to C++98, you would call:
+#
+# __compiler_check_default_language_standard(CXX 4.8 98 6.1 11)
+#
+macro(__compiler_check_default_language_standard lang stdver1 std1)
+ set(__std_ver_pairs "${stdver1};${std1};${ARGN}")
+ string(REGEX REPLACE " *; *" " " __std_ver_pairs "${__std_ver_pairs}")
+ string(REGEX MATCHALL "[^ ]+ [^ ]+" __std_ver_pairs "${__std_ver_pairs}")
+
+ # If the compiler version is below the threshold of even having CMake
+ # support for language standards, then don't bother.
+ if (CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL "${stdver1}")
+ if (NOT CMAKE_${lang}_COMPILER_FORCED)
+ if (NOT CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT)
+ message(FATAL_ERROR "CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_${lang}_COMPILER_ID} (${CMAKE_${lang}_COMPILER}) version ${CMAKE_${lang}_COMPILER_VERSION}")
+ endif ()
+ set(CMAKE_${lang}_STANDARD_DEFAULT ${CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT})
+ else ()
+ list(REVERSE __std_ver_pairs)
+ foreach (__std_ver_pair IN LISTS __std_ver_pairs)
+ string(REGEX MATCH "([^ ]+) (.+)" __std_ver_pair "${__std_ver_pair}")
+ set(__stdver ${CMAKE_MATCH_1})
+ set(__std ${CMAKE_MATCH_2})
+ if (CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL __stdver AND
+ NOT DEFINED CMAKE_${lang}_STANDARD_DEFAULT)
+ # Compiler id was forced so just guess the default standard level.
+ set(CMAKE_${lang}_STANDARD_DEFAULT ${__std})
+ endif ()
+ unset(__std)
+ unset(__stdver)
+ endforeach ()
+ endif ()
+ endif ()
+ unset(__std_ver_pairs)
+endmacro()
diff --git a/Modules/Compiler/Cray-C.cmake b/Modules/Compiler/Cray-C.cmake
index 675560c..87ce20f 100644
--- a/Modules/Compiler/Cray-C.cmake
+++ b/Modules/Compiler/Cray-C.cmake
@@ -1 +1,22 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+include(Compiler/Cray)
+
set(CMAKE_C_VERBOSE_FLAG "-v")
+
+string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
+string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG")
+
+if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1)
+ set(CMAKE_C90_STANDARD_COMPILE_OPTION -h noc99,conform)
+ set(CMAKE_C90_EXTENSION_COMPILE_OPTION -h noc99,gnu)
+ set(CMAKE_C99_STANDARD_COMPILE_OPTION -h c99,conform)
+ set(CMAKE_C99_EXTENSION_COMPILE_OPTION -h c99,gnu)
+ if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.5)
+ set(CMAKE_C11_STANDARD_COMPILE_OPTION -h std=c11,conform)
+ set(CMAKE_C11_EXTENSION_COMPILE_OPTION -h std=c11,gnu)
+ endif ()
+endif ()
+
+__compiler_check_default_language_standard(C 8.1 99)
diff --git a/Modules/Compiler/Cray-CXX.cmake b/Modules/Compiler/Cray-CXX.cmake
index 9fb191c..8506c094 100644
--- a/Modules/Compiler/Cray-CXX.cmake
+++ b/Modules/Compiler/Cray-CXX.cmake
@@ -1 +1,20 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+include(Compiler/Cray)
+
set(CMAKE_CXX_VERBOSE_FLAG "-v")
+
+string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
+string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -DNDEBUG")
+
+if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1)
+ set(CMAKE_CXX98_STANDARD_COMPILE_OPTION -h conform)
+ set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -h gnu)
+ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.4)
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION -h std=c++11)
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -h std=c++11,gnu)
+ endif ()
+endif ()
+
+__compiler_check_default_language_standard(CXX 8.1 98)
diff --git a/Modules/Compiler/Cray.cmake b/Modules/Compiler/Cray.cmake
new file mode 100644
index 0000000..8fe8eeb
--- /dev/null
+++ b/Modules/Compiler/Cray.cmake
@@ -0,0 +1,10 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+# This module is shared by multiple languages; use include blocker.
+if(__COMPILER_CRAY)
+ return()
+endif()
+set(__COMPILER_CRAY 1)
+
+include(Compiler/CMakeCommonCompilerMacros)
diff --git a/Modules/Compiler/PGI-C.cmake b/Modules/Compiler/PGI-C.cmake
index 85d6e7e..a24e554 100644
--- a/Modules/Compiler/PGI-C.cmake
+++ b/Modules/Compiler/PGI-C.cmake
@@ -2,3 +2,16 @@ include(Compiler/PGI)
__compiler_pgi(C)
string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG")
+
+if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.10)
+ set(CMAKE_C90_STANDARD_COMPILE_OPTION -c89)
+ set(CMAKE_C90_EXTENSION_COMPILE_OPTION -c89)
+ set(CMAKE_C99_STANDARD_COMPILE_OPTION -c99)
+ set(CMAKE_C99_EXTENSION_COMPILE_OPTION -c99)
+ if (CMAKE_C_COMPILER_VERSION VERSION_CREATER_EQUAL 15.3)
+ set(CMAKE_C11_STANDARD_COMPILE_OPTION -c11)
+ set(CMAKE_C11_EXTENSION_COMPILE_OPTION -c11)
+ endif ()
+endif ()
+
+__compiler_check_default_language_standard(C 12.10 90)
diff --git a/Modules/Compiler/PGI-CXX.cmake b/Modules/Compiler/PGI-CXX.cmake
index 896e298..abc7349 100644
--- a/Modules/Compiler/PGI-CXX.cmake
+++ b/Modules/Compiler/PGI-CXX.cmake
@@ -2,3 +2,22 @@ include(Compiler/PGI)
__compiler_pgi(CXX)
string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -DNDEBUG")
+
+if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.10)
+ set(CMAKE_CXX98_STANDARD_COMPILE_OPTION -A)
+ set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION --gnu_extensions)
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.10)
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION --c++11 -A)
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION --c++11 --gnu_extensions)
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.7)
+ set(CMAKE_CXX14_STANDARD_COMPILE_OPTION --c++14 -A)
+ set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION --c++14 --gnu_extensions)
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.1)
+ set(CMAKE_CXX17_STANDARD_COMPILE_OPTION --c++17 -A)
+ set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION --c++17 --gnu_extensions)
+ endif()
+ endif()
+ endif()
+endif()
+
+__compiler_check_default_language_standard(CXX 12.10 98)
diff --git a/Modules/Compiler/PGI.cmake b/Modules/Compiler/PGI.cmake
index cc76deb..bdabeba 100644
--- a/Modules/Compiler/PGI.cmake
+++ b/Modules/Compiler/PGI.cmake
@@ -8,6 +8,8 @@ if(__COMPILER_PGI)
endif()
set(__COMPILER_PGI 1)
+include(Compiler/CMakeCommonCompilerMacros)
+
macro(__compiler_pgi lang)
# Feature flags.
set(CMAKE_${lang}_VERBOSE_FLAG "-v")
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 8ce158b..0ab6e89 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1497,7 +1497,11 @@ void cmLocalGenerator::AddCompilerRequirementFlag(
"does not know the compile flags to use to enable it.";
this->IssueMessage(cmake::FATAL_ERROR, e.str());
} else {
- this->AppendFlagEscape(flags, opt);
+ std::vector<std::string> optVec;
+ cmSystemTools::ExpandListArgument(opt, optVec);
+ for (size_t i = 0; i < optVec.size(); ++i) {
+ this->AppendFlagEscape(flags, optVec[i]);
+ }
}
return;
}