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