[CMake] Enhance llvm_update_compile_flags(name sources) to handle LLVM_REQUIRES_EH...
[oota-llvm.git] / cmake / modules / HandleLLVMOptions.cmake
index 09479561d8aa5ec7b2df1539a5bcce3eac84f4e4..487b2e45808fe53fb67f3e4b2e49b510083c44bf 100644 (file)
@@ -359,3 +359,11 @@ if(NOT CYGWIN AND NOT WIN32)
     append("-ffunction-sections -fdata-sections" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
   endif()
 endif()
+
+if(MSVC)
+  # Remove flags here, for exceptions and RTTI.
+  # Each target property of source proerty should be responsible to control them.
+  # CL.EXE complains to override flags like "/GR /GR-".
+  string(REGEX REPLACE "(^| ) */EH[-cs]+ *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+  string(REGEX REPLACE "(^| ) */GR-? *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+endif()