Browse Source

Configure MinGW to use -O2 instead of -O3 for Release build config.
For some reason CMake/MinGW generator uses -O3 for newer MinGW versions. Explicitly set it to -O2 to prevent crashes on 32-bit mode.
Fix #1765.

Yao Wei Tjong 姚伟忠 8 years ago
parent
commit
c0f6b0dac7
1 changed files with 3 additions and 1 deletions
  1. 3 1
      CMake/Modules/Urho3D-CMake-common.cmake

+ 3 - 1
CMake/Modules/Urho3D-CMake-common.cmake

@@ -701,7 +701,9 @@ else ()
             set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static -static-libgcc -fno-keep-inline-dllexport")
             set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static -static-libgcc -static-libstdc++ -fno-keep-inline-dllexport")
             if (NOT URHO3D_64BIT)
-                # Prevent auto-vectorize optimization when using -O3, unless stack realign is being enforced globally
+                set (CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
+                set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
+                # Prevent auto-vectorize optimization when using -O2, unless stack realign is being enforced globally
                 if (URHO3D_SSE)
                     set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mstackrealign")
                     set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mstackrealign")