Merge pull request #2285 from proydakov/msvc-rtti-compilation-warning-fix

Fixed msvc 2019 nmake compiler warnings with RTTI.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cbf8378..bb5205e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -140,7 +140,12 @@
     endif()
 elseif(MSVC)
     if(NOT ENABLE_RTTI)
-        add_compile_options(/GR-) # Disable RTTI
+        string(FIND "${CMAKE_CXX_FLAGS}" "/GR" MSVC_HAS_GR)
+        if(MSVC_HAS_GR)
+            string(REGEX REPLACE /GR /GR- CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+        else()
+            add_compile_options(/GR-) # Disable RTTI
+        endif()
     endif()
     if(ENABLE_EXCEPTIONS)
         add_compile_options(/EHsc) # Enable Exceptions