|
45 | 45 | # each other (i.e. only one may be present). |
46 | 46 | # |
47 | 47 |
|
48 | | -if (NOT CMAKE_CXX_COMPILER_LOADED) |
| 48 | +if(NOT CMAKE_CXX_COMPILER_LOADED) |
49 | 49 | message(FATAL_ERROR "CheckCXX11Features modules only works if language CXX is enabled") |
50 | | -endif () |
51 | | - |
52 | | -# |
53 | | -### Check for needed compiler flags |
54 | | -# |
55 | | -include(CheckCXXCompilerFlag) |
56 | | -check_cxx_compiler_flag("-std=c++11" _HAS_CXX11_FLAG) |
57 | | -if (NOT _HAS_CXX11_FLAG) |
58 | | - check_cxx_compiler_flag("-std=c++0x" _HAS_CXX0X_FLAG) |
59 | | -endif () |
60 | | - |
61 | | -set(HAS_CXX11_SUPPORT FALSE) |
62 | | -if (_HAS_CXX11_FLAG OR _HAS_CXX0X_FLAG) |
63 | | - set(HAS_CXX11_SUPPORT TRUE) |
64 | | - add_definitions(-DHAS_CXX11) |
65 | 50 | endif() |
66 | 51 |
|
67 | | -if (_HAS_CXX11_FLAG) |
68 | | - set(CXX11_COMPILER_FLAGS "-std=c++11") |
69 | | -elseif (_HAS_CXX0X_FLAG) |
70 | | - set(CXX11_COMPILER_FLAGS "-std=c++0x") |
71 | | -endif () |
72 | | - |
73 | 52 | function(cxx11_check_feature FEATURE_NAME RESULT_VAR) |
74 | | - if (NOT DEFINED ${RESULT_VAR}) |
| 53 | + if(NOT DEFINED ${RESULT_VAR}) |
75 | 54 | set(_bindir "${CMAKE_CURRENT_BINARY_DIR}/check_cxx11/cxx11_${FEATURE_NAME}") |
76 | 55 |
|
77 | 56 | set(_location "${PROJECT_SOURCE_DIR}/cmake/compilers/CheckCXX11Features") |
@@ -129,28 +108,53 @@ function(cxx11_check_feature FEATURE_NAME RESULT_VAR) |
129 | 108 | endif (${RESULT_VAR}) |
130 | 109 | set(${RESULT_VAR} ${${RESULT_VAR}} CACHE INTERNAL "C++11 support for ${_LOG_NAME}") |
131 | 110 | set(feature_list ${feature_list} CACHE INTERNAL "") |
132 | | - endif (NOT DEFINED ${RESULT_VAR}) |
| 111 | + endif(NOT DEFINED ${RESULT_VAR}) |
133 | 112 | endfunction(cxx11_check_feature) |
134 | 113 |
|
135 | | -cxx11_check_feature("__func__" HAS_CXX11_FUNC) |
136 | | -cxx11_check_feature("auto" HAS_CXX11_AUTO) |
137 | | -cxx11_check_feature("auto_ret_type" HAS_CXX11_AUTO_RET_TYPE) |
138 | | -cxx11_check_feature("class_override_final" HAS_CXX11_CLASS_OVERRIDE) |
139 | | -cxx11_check_feature("constexpr" HAS_CXX11_CONSTEXPR) |
140 | | -cxx11_check_feature("cstdint" HAS_CXX11_CSTDINT_H) |
141 | | -cxx11_check_feature("decltype" HAS_CXX11_DECLTYPE) |
142 | | -cxx11_check_feature("initializer_list" HAS_CXX11_INITIALIZER_LIST) |
143 | | -cxx11_check_feature("lambda" HAS_CXX11_LAMBDA) |
144 | | -cxx11_check_feature("long_long" HAS_CXX11_LONG_LONG) |
145 | | -cxx11_check_feature("nullptr" HAS_CXX11_NULLPTR) |
146 | | -cxx11_check_feature("regex" HAS_CXX11_LIB_REGEX) |
147 | | -cxx11_check_feature("rvalue-references" HAS_CXX11_RVALUE_REFERENCES) |
148 | | -cxx11_check_feature("sizeof_member" HAS_CXX11_SIZEOF_MEMBER) |
149 | | -cxx11_check_feature("static_assert" HAS_CXX11_STATIC_ASSERT) |
150 | | -cxx11_check_feature("variadic_templates" HAS_CXX11_VARIADIC_TEMPLATES) |
| 114 | +# Compilation of Boost uncovers some bugs with Intel's support for C++11 |
| 115 | +# For Intel compilers older that 14.0.0 continue using -std=gnu++98 |
| 116 | +if(CMAKE_CXX_COMPILER_ID MATCHES Intel) |
| 117 | + execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE ICPC_VERSION) |
| 118 | +endif() |
151 | 119 |
|
152 | | -# Print list of supported features |
153 | | -message(STATUS "Found following supported C++11 features:") |
154 | | -foreach(FEATURE ${feature_list}) |
155 | | - message (STATUS " ${FEATURE}") |
156 | | -endforeach() |
| 120 | +if(ICPC_VERSION VERSION_LESS 14.0.0) |
| 121 | + message(STATUS "Buggy compiler support for C++11. Using older standard.") |
| 122 | +else() |
| 123 | + # Check which compiler flag is valid for the C++11 standard |
| 124 | + include(CheckCXXCompilerFlag) |
| 125 | + check_cxx_compiler_flag("-std=c++11" _HAS_CXX11_FLAG) |
| 126 | + set(CXX11_COMPILER_FLAGS "-std=c++11") |
| 127 | + if(NOT _HAS_CXX11_FLAG) |
| 128 | + check_cxx_compiler_flag("-std=c++0x" _HAS_CXX0X_FLAG) |
| 129 | + set(CXX11_COMPILER_FLAGS "-std=c++0x") |
| 130 | + endif() |
| 131 | + |
| 132 | + set(HAS_CXX11_SUPPORT FALSE) |
| 133 | + if(_HAS_CXX11_FLAG OR _HAS_CXX0X_FLAG) |
| 134 | + set(HAS_CXX11_SUPPORT TRUE) |
| 135 | + add_definitions(-DHAS_CXX11) |
| 136 | + endif() |
| 137 | + |
| 138 | + cxx11_check_feature("__func__" HAS_CXX11_FUNC) |
| 139 | + cxx11_check_feature("auto" HAS_CXX11_AUTO) |
| 140 | + cxx11_check_feature("auto_ret_type" HAS_CXX11_AUTO_RET_TYPE) |
| 141 | + cxx11_check_feature("class_override_final" HAS_CXX11_CLASS_OVERRIDE) |
| 142 | + cxx11_check_feature("constexpr" HAS_CXX11_CONSTEXPR) |
| 143 | + cxx11_check_feature("cstdint" HAS_CXX11_CSTDINT_H) |
| 144 | + cxx11_check_feature("decltype" HAS_CXX11_DECLTYPE) |
| 145 | + cxx11_check_feature("initializer_list" HAS_CXX11_INITIALIZER_LIST) |
| 146 | + cxx11_check_feature("lambda" HAS_CXX11_LAMBDA) |
| 147 | + cxx11_check_feature("long_long" HAS_CXX11_LONG_LONG) |
| 148 | + cxx11_check_feature("nullptr" HAS_CXX11_NULLPTR) |
| 149 | + cxx11_check_feature("regex" HAS_CXX11_LIB_REGEX) |
| 150 | + cxx11_check_feature("rvalue-references" HAS_CXX11_RVALUE_REFERENCES) |
| 151 | + cxx11_check_feature("sizeof_member" HAS_CXX11_SIZEOF_MEMBER) |
| 152 | + cxx11_check_feature("static_assert" HAS_CXX11_STATIC_ASSERT) |
| 153 | + cxx11_check_feature("variadic_templates" HAS_CXX11_VARIADIC_TEMPLATES) |
| 154 | + |
| 155 | + # Print list of supported features |
| 156 | + message(STATUS "Found following supported C++11 features:") |
| 157 | + foreach(FEATURE ${feature_list}) |
| 158 | + message (STATUS " ${FEATURE}") |
| 159 | + endforeach() |
| 160 | +endif() |
0 commit comments