cd9773beb97bc76a93048bd13c8a67de2d601b31
[oota-llvm.git] / cmake / modules / HandleLLVMOptions.cmake
1 # This CMake module is responsible for interpreting the user defined LLVM_
2 # options and executing the appropriate CMake commands to realize the users'
3 # selections.
4
5 include(HandleLLVMStdlib)
6 include(AddLLVMDefinitions)
7 include(CheckCCompilerFlag)
8 include(CheckCXXCompilerFlag)
9
10 if(NOT LLVM_FORCE_USE_OLD_TOOLCHAIN)
11   if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
12     if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
13       message(FATAL_ERROR "Host GCC version must be at least 4.7!")
14     endif()
15   elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
16     if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
17       message(FATAL_ERROR "Host Clang version must be at least 3.1!")
18     endif()
19
20     # Also test that we aren't using too old of a version of libstdc++ with the
21     # Clang compiler. This is tricky as there is no real way to check the
22     # version of libstdc++ directly. Instead we test for a known bug in
23     # libstdc++4.6 that is fixed in libstdc++4.7.
24     if(NOT LLVM_ENABLE_LIBCXX)
25       set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
26       set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
27       set(CMAKE_REQUIRED_FLAGS "-std=c++0x")
28       if (ANDROID)
29         set(CMAKE_REQUIRED_LIBRARIES "atomic")
30       endif()
31       check_cxx_source_compiles("
32 #include <atomic>
33 std::atomic<float> x(0.0f);
34 int main() { return (float)x; }"
35         LLVM_NO_OLD_LIBSTDCXX)
36       if(NOT LLVM_NO_OLD_LIBSTDCXX)
37         message(FATAL_ERROR "Host Clang must be able to find libstdc++4.7 or newer!")
38       endif()
39       set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
40       set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
41     endif()
42   elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
43     if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17.0)
44       message(FATAL_ERROR "Host Visual Studio must be at least 2012 (MSVC 17.0)")
45     endif()
46   endif()
47 endif()
48
49 if( LLVM_ENABLE_ASSERTIONS )
50   # MSVC doesn't like _DEBUG on release builds. See PR 4379.
51   if( NOT MSVC )
52     add_definitions( -D_DEBUG )
53   endif()
54   # On non-Debug builds cmake automatically defines NDEBUG, so we
55   # explicitly undefine it:
56   if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
57     add_definitions( -UNDEBUG )
58     # Also remove /D NDEBUG to avoid MSVC warnings about conflicting defines.
59     set(REGEXP_NDEBUG "(^| )[/-]D *NDEBUG($| )")
60     string (REGEX REPLACE "${REGEXP_NDEBUG}" " "
61       CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
62     string (REGEX REPLACE "${REGEXP_NDEBUG}" " "
63       CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
64     string (REGEX REPLACE "${REGEXP_NDEBUG}" " "
65       CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
66   endif()
67 else()
68   if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" )
69     if( NOT MSVC_IDE AND NOT XCODE )
70       add_definitions( -DNDEBUG )
71     endif()
72   endif()
73 endif()
74
75 if(WIN32)
76   set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
77   if(CYGWIN)
78     set(LLVM_ON_WIN32 0)
79     set(LLVM_ON_UNIX 1)
80   else(CYGWIN)
81     set(LLVM_ON_WIN32 1)
82     set(LLVM_ON_UNIX 0)
83   endif(CYGWIN)
84   # Maximum path length is 160 for non-unicode paths
85   set(MAXPATHLEN 160)
86 else(WIN32)
87   if(UNIX)
88     set(LLVM_ON_WIN32 0)
89     set(LLVM_ON_UNIX 1)
90     if(APPLE)
91       set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
92     else(APPLE)
93       set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
94     endif(APPLE)
95     # FIXME: Maximum path length is currently set to 'safe' fixed value
96     set(MAXPATHLEN 2024)
97   else(UNIX)
98     MESSAGE(SEND_ERROR "Unable to determine platform")
99   endif(UNIX)
100 endif(WIN32)
101
102 set(EXEEXT ${CMAKE_EXECUTABLE_SUFFIX})
103 set(LTDL_SHLIB_EXT ${CMAKE_SHARED_LIBRARY_SUFFIX})
104
105 # We use *.dylib rather than *.so on darwin.
106 set(LLVM_PLUGIN_EXT ${CMAKE_SHARED_LIBRARY_SUFFIX})
107
108 if(APPLE)
109   # Darwin-specific linker flags for loadable modules.
110   set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
111 endif()
112
113 function(add_flag_or_print_warning flag)
114   check_c_compiler_flag(${flag} C_SUPPORTS_FLAG)
115   check_cxx_compiler_flag(${flag} CXX_SUPPORTS_FLAG)
116   if (C_SUPPORTS_FLAG AND CXX_SUPPORTS_FLAG)
117     message(STATUS "Building with ${flag}")
118     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE)
119     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE)
120   else()
121     message(WARNING "${flag} is not supported.")
122   endif()
123 endfunction()
124
125 function(append value)
126   foreach(variable ${ARGN})
127     set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
128   endforeach(variable)
129 endfunction()
130
131 function(append_if condition value)
132   if (${condition})
133     foreach(variable ${ARGN})
134       set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
135     endforeach(variable)
136   endif()
137 endfunction()
138
139 macro(add_flag_if_supported flag)
140   check_c_compiler_flag(${flag} C_SUPPORTS_FLAG)
141   append_if(C_SUPPORTS_FLAG "${flag}" CMAKE_C_FLAGS)
142   check_cxx_compiler_flag(${flag} CXX_SUPPORTS_FLAG)
143   append_if(CXX_SUPPORTS_FLAG "${flag}" CMAKE_CXX_FLAGS)
144 endmacro()
145
146 if( LLVM_ENABLE_PIC )
147   if( XCODE )
148     # Xcode has -mdynamic-no-pic on by default, which overrides -fPIC. I don't
149     # know how to disable this, so just force ENABLE_PIC off for now.
150     message(WARNING "-fPIC not supported with Xcode.")
151   elseif( WIN32 OR CYGWIN)
152     # On Windows all code is PIC. MinGW warns if -fPIC is used.
153   else()
154     add_flag_or_print_warning("-fPIC")
155
156     if( WIN32 OR CYGWIN)
157       # MinGW warns if -fvisibility-inlines-hidden is used.
158     else()
159       check_cxx_compiler_flag("-fvisibility-inlines-hidden" SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG)
160       append_if(SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG "-fvisibility-inlines-hidden" CMAKE_CXX_FLAGS)
161     endif()
162   endif()
163 endif()
164
165 if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
166   # TODO: support other platforms and toolchains.
167   if( LLVM_BUILD_32_BITS )
168     message(STATUS "Building 32 bits executables and libraries.")
169     add_llvm_definitions( -m32 )
170     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
171     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
172     set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -m32")
173   endif( LLVM_BUILD_32_BITS )
174 endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
175
176 if( XCODE )
177   # For Xcode enable several build settings that correspond to
178   # many warnings that are on by default in Clang but are
179   # not enabled for historical reasons.  For versions of Xcode
180   # that do not support these options they will simply
181   # be ignored.
182   set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_RETURN_TYPE "YES")
183   set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_NEWLINE "YES")
184   set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VALUE "YES")
185   set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VARIABLE "YES")
186   set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_SIGN_COMPARE "YES")
187   set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_FUNCTION "YES")
188   set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED "YES")
189   set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS "YES")
190   set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNINITIALIZED_AUTOS "YES")
191   set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_BOOL_CONVERSION "YES")
192   set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_EMPTY_BODY "YES")
193   set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_ENUM_CONVERSION "YES")
194   set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_INT_CONVERSION "YES")
195   set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_CONSTANT_CONVERSION "YES")
196   set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_NON_VIRTUAL_DESTRUCTOR "YES")
197 endif()
198
199 # On Win32 using MS tools, provide an option to set the number of parallel jobs
200 # to use.
201 if( MSVC_IDE )
202   set(LLVM_COMPILER_JOBS "0" CACHE STRING
203     "Number of parallel compiler jobs. 0 means use all processors. Default is 0.")
204   if( NOT LLVM_COMPILER_JOBS STREQUAL "1" )
205     if( LLVM_COMPILER_JOBS STREQUAL "0" )
206       add_llvm_definitions( /MP )
207     else()
208       if (MSVC10)
209         message(FATAL_ERROR
210           "Due to a bug in CMake only 0 and 1 is supported for "
211           "LLVM_COMPILER_JOBS when generating for Visual Studio 2010")
212       else()
213         message(STATUS "Number of parallel compiler jobs set to " ${LLVM_COMPILER_JOBS})
214         add_llvm_definitions( /MP${LLVM_COMPILER_JOBS} )
215       endif()
216     endif()
217   else()
218     message(STATUS "Parallel compilation disabled")
219   endif()
220 endif()
221
222 if( MSVC )
223   include(ChooseMSVCCRT)
224
225   if( NOT (${CMAKE_VERSION} VERSION_LESS 2.8.11) )
226     # set stack reserved size to ~10MB
227     # CMake previously automatically set this value for MSVC builds, but the
228     # behavior was changed in CMake 2.8.11 (Issue 12437) to use the MSVC default
229     # value (1 MB) which is not enough for us in tasks such as parsing recursive
230     # C++ templates in Clang.
231     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10000000")
232   endif()
233
234   if( MSVC10 )
235     # MSVC 10 will complain about headers in the STL not being exported, but
236     # will not complain in MSVC 11.
237     add_llvm_definitions(
238       -wd4275 # Suppress 'An exported class was derived from a class that was not exported.'
239     )
240   elseif( MSVC11 )
241     add_llvm_definitions(-D_VARIADIC_MAX=10)
242   endif()
243   
244   # Add definitions that make MSVC much less annoying.
245   add_llvm_definitions(
246     # For some reason MS wants to deprecate a bunch of standard functions...
247     -D_CRT_SECURE_NO_DEPRECATE
248     -D_CRT_SECURE_NO_WARNINGS
249     -D_CRT_NONSTDC_NO_DEPRECATE
250     -D_CRT_NONSTDC_NO_WARNINGS
251     -D_SCL_SECURE_NO_DEPRECATE
252     -D_SCL_SECURE_NO_WARNINGS
253
254     # Disabled warnings.
255     -wd4146 # Suppress 'unary minus operator applied to unsigned type, result still unsigned'
256     -wd4180 # Suppress 'qualifier applied to function type has no meaning; ignored'
257     -wd4244 # Suppress ''argument' : conversion from 'type1' to 'type2', possible loss of data'
258     -wd4267 # Suppress ''var' : conversion from 'size_t' to 'type', possible loss of data'
259     -wd4345 # Suppress 'behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized'
260     -wd4351 # Suppress 'new behavior: elements of array 'array' will be default initialized'
261     -wd4355 # Suppress ''this' : used in base member initializer list'
262     -wd4503 # Suppress ''identifier' : decorated name length exceeded, name was truncated'
263     -wd4624 # Suppress ''derived class' : destructor could not be generated because a base class destructor is inaccessible'
264     -wd4800 # Suppress ''type' : forcing value to bool 'true' or 'false' (performance warning)'
265     -wd4291 # Suppress ''declaration' : no matching operator delete found; memory will not be freed if initialization throws an exception'
266     
267     # Promoted warnings.
268     -w14062 # Promote 'enumerator in switch of enum is not handled' to level 1 warning.
269
270     # Promoted warnings to errors.
271     -we4238 # Promote 'nonstandard extension used : class rvalue used as lvalue' to error.
272     )
273
274   # Enable warnings
275   if (LLVM_ENABLE_WARNINGS)
276     add_llvm_definitions( /W4 )
277     if (LLVM_ENABLE_PEDANTIC)
278       # No MSVC equivalent available
279     endif (LLVM_ENABLE_PEDANTIC)
280   endif (LLVM_ENABLE_WARNINGS)
281   if (LLVM_ENABLE_WERROR)
282     add_llvm_definitions( /WX )
283   endif (LLVM_ENABLE_WERROR)
284 elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
285   if (LLVM_ENABLE_WARNINGS)
286     append("-Wall -W -Wno-unused-parameter -Wwrite-strings" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
287
288     # Turn off missing field initializer warnings for gcc to avoid noise from
289     # false positives with empty {}. Turn them on otherwise (they're off by
290     # default for clang).
291     check_cxx_compiler_flag("-Wmissing-field-initializers" CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG)
292     if (CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG)
293       if (CMAKE_COMPILER_IS_GNUCXX)
294         append("-Wno-missing-field-initializers" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
295       else()
296         append("-Wmissing-field-initializers" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
297       endif()
298     endif()
299
300     append_if(LLVM_ENABLE_PEDANTIC "-pedantic -Wno-long-long" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
301     check_cxx_compiler_flag("-Werror -Wcovered-switch-default" CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG)
302     append_if(CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG "-Wcovered-switch-default" CMAKE_CXX_FLAGS)
303     check_c_compiler_flag("-Werror -Wcovered-switch-default" C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG)
304     append_if(C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG "-Wcovered-switch-default" CMAKE_C_FLAGS)
305     append_if(USE_NO_UNINITIALIZED "-Wno-uninitialized" CMAKE_CXX_FLAGS)
306     append_if(USE_NO_MAYBE_UNINITIALIZED "-Wno-maybe-uninitialized" CMAKE_CXX_FLAGS)
307     check_cxx_compiler_flag("-Werror -Wnon-virtual-dtor" CXX_SUPPORTS_NON_VIRTUAL_DTOR_FLAG)
308     append_if(CXX_SUPPORTS_NON_VIRTUAL_DTOR_FLAG "-Wnon-virtual-dtor" CMAKE_CXX_FLAGS)
309   endif (LLVM_ENABLE_WARNINGS)
310   append_if(LLVM_ENABLE_WERROR "-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
311   if (LLVM_ENABLE_CXX1Y)
312     check_cxx_compiler_flag("-std=c++1y" CXX_SUPPORTS_CXX1Y)
313     append_if(CXX_SUPPORTS_CXX1Y "-std=c++1y" CMAKE_CXX_FLAGS)
314   else()
315     check_cxx_compiler_flag("-std=c++11" CXX_SUPPORTS_CXX11)
316     if (CXX_SUPPORTS_CXX11)
317       if (CYGWIN OR MINGW)
318         # MinGW and Cygwin are a bit stricter and lack things like
319         # 'strdup', 'stricmp', etc in c++11 mode.
320         append("-std=gnu++11" CMAKE_CXX_FLAGS)
321       else()
322         append("-std=c++11" CMAKE_CXX_FLAGS)
323       endif()
324     else()
325       message(FATAL_ERROR "LLVM requires C++11 support but the '-std=c++11' flag isn't supported.")
326     endif()
327   endif()
328 endif( MSVC )
329
330 macro(append_common_sanitizer_flags)
331   # Append -fno-omit-frame-pointer and turn on debug info to get better
332   # stack traces.
333   add_flag_if_supported("-fno-omit-frame-pointer")
334   if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND
335       NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
336     add_flag_if_supported("-gline-tables-only")
337   endif()
338   # Use -O1 even in debug mode, otherwise sanitizers slowdown is too large.
339   if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
340     add_flag_if_supported("-O1")
341   endif()
342 endmacro()
343
344 # Turn on sanitizers if necessary.
345 if(LLVM_USE_SANITIZER)
346   if (LLVM_ON_UNIX)
347     if (LLVM_USE_SANITIZER STREQUAL "Address")
348       append_common_sanitizer_flags()
349       add_flag_or_print_warning("-fsanitize=address")
350     elseif (LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?")
351       append_common_sanitizer_flags()
352       add_flag_or_print_warning("-fsanitize=memory")
353       if(LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins")
354         add_flag_or_print_warning("-fsanitize-memory-track-origins")
355       endif()
356     else()
357       message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
358     endif()
359   else()
360     message(WARNING "LLVM_USE_SANITIZER is not supported on this platform.")
361   endif()
362 endif()
363
364 # Turn on -gsplit-dwarf if requested
365 if(LLVM_USE_SPLIT_DWARF)
366   add_llvm_definitions("-gsplit-dwarf")
367 endif()
368
369 add_llvm_definitions( -D__STDC_CONSTANT_MACROS )
370 add_llvm_definitions( -D__STDC_FORMAT_MACROS )
371 add_llvm_definitions( -D__STDC_LIMIT_MACROS )
372
373 # clang doesn't print colored diagnostics when invoked from Ninja
374 if (UNIX AND
375     CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
376     CMAKE_GENERATOR STREQUAL "Ninja")
377   append("-fcolor-diagnostics" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
378 endif()
379
380 # Add flags for add_dead_strip().
381 # FIXME: With MSVS, consider compiling with /Gy and linking with /OPT:REF?
382 # But MinSizeRel seems to add that automatically, so maybe disable these
383 # flags instead if LLVM_NO_DEAD_STRIP is set.
384 if(NOT CYGWIN AND NOT WIN32)
385   if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
386     check_c_compiler_flag("-Werror -fno-function-sections" C_SUPPORTS_FNO_FUNCTION_SECTIONS)
387     if (C_SUPPORTS_FNO_FUNCTION_SECTIONS)
388       # Don't add -ffunction-section if it can be disabled with -fno-function-sections.
389       # Doing so will break sanitizers.
390       check_c_compiler_flag("-Werror -ffunction-sections" C_SUPPORTS_FFUNCTION_SECTIONS)
391       check_cxx_compiler_flag("-Werror -ffunction-sections" CXX_SUPPORTS_FFUNCTION_SECTIONS)
392       append_if(C_SUPPORTS_FFUNCTION_SECTIONS "-ffunction-sections" CMAKE_C_FLAGS)
393       append_if(CXX_SUPPORTS_FFUNCTION_SECTIONS "-ffunction-sections" CMAKE_CXX_FLAGS)
394     endif()
395     check_c_compiler_flag("-Werror -fdata-sections" C_SUPPORTS_FDATA_SECTIONS)
396     check_cxx_compiler_flag("-Werror -fdata-sections" CXX_SUPPORTS_FDATA_SECTIONS)
397     append_if(C_SUPPORTS_FDATA_SECTIONS "-fdata-sections" CMAKE_C_FLAGS)
398     append_if(CXX_SUPPORTS_FDATA_SECTIONS "-fdata-sections" CMAKE_CXX_FLAGS)
399   endif()
400 endif()
401
402 if(CYGWIN OR MINGW)
403   # Prune --out-implib from executables. It doesn't make sense even
404   # with --export-all-symbols.
405   string(REGEX REPLACE "-Wl,--out-implib,[^ ]+ " " "
406     CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE}")
407   string(REGEX REPLACE "-Wl,--out-implib,[^ ]+ " " "
408     CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE}")
409 endif()
410
411 if(MSVC)
412   # Remove flags here, for exceptions and RTTI.
413   # Each target property or source property should be responsible to control
414   # them.
415   # CL.EXE complains to override flags like "/GR /GR-".
416   string(REGEX REPLACE "(^| ) */EH[-cs]+ *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
417   string(REGEX REPLACE "(^| ) */GR-? *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
418 endif()