Browse Source

Only initialize the URHO3D_DEFAULT_SSE variable only once.

Yao Wei Tjong 姚伟忠 10 years ago
parent
commit
0e4ba63687
2 changed files with 15 additions and 17 deletions
  1. 14 16
      CMake/Modules/Urho3D-CMake-common.cmake
  2. 1 1
      Docs/GettingStarted.dox

+ 14 - 16
CMake/Modules/Urho3D-CMake-common.cmake

@@ -86,25 +86,23 @@ cmake_dependent_option (URHO3D_NETWORK "Enable networking support" TRUE "NOT EMS
 cmake_dependent_option (URHO3D_DATABASE_ODBC "Enable Database support with ODBC, requires vendor-specific ODBC driver" FALSE "NOT IOS AND NOT ANDROID AND NOT EMSCRIPTEN" FALSE)
 option (URHO3D_PHYSICS "Enable physics support" TRUE)
 option (URHO3D_URHO2D "Enable 2D graphics and physics support" TRUE)
-if (MINGW AND NOT DEFINED URHO3D_SSE)
-    # Certain MinGW versions fail to compile SSE code. This is the initial guess for known "bad" version range, and can be tightened later
-    execute_process (COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION ERROR_QUIET)
-    if (GCC_VERSION VERSION_LESS 4.9.1)
-        message (WARNING "Disabling SSE by default due to MinGW version. It is recommended to upgrade to MinGW with GCC >= 4.9.1. You can also try to re-enable SSE with CMake option -DURHO3D_SSE=1, but this may result in compile errors.")
+if (NOT DEFINED URHO3D_DEFAULT_SSE)
+    # Set the default to true for all the platforms that support SSE except the following
+    set (URHO3D_DEFAULT_SSE TRUE)
+    if (MINGW)
+        # Certain MinGW versions fail to compile SSE code. This is the initial guess for known "bad" version range, and can be tightened later
+        execute_process (COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION ERROR_QUIET)
+        if (GCC_VERSION VERSION_LESS 4.9.1)
+            message (WARNING "Disabling SSE by default due to MinGW version. It is recommended to upgrade to MinGW with GCC >= 4.9.1. You can also try to re-enable SSE with CMake option -DURHO3D_SSE=1, but this may result in compile errors.")
+            set (URHO3D_DEFAULT_SSE FALSE)
+        endif ()
+    elseif (EMSCRIPTEN)
+        # In Emscripten, default to false for targeting SSE2, since the SIMD.js specification is not yet widely adopted in browsers
         set (URHO3D_DEFAULT_SSE FALSE)
-    else ()
-        set (URHO3D_DEFAULT_SSE TRUE)
     endif ()
-else ()
-    if (EMSCRIPTEN)
-        # In Emscripten, default to false for targeting SSE2, since the SIMD.js specification is not yet widely adopted in browsers.
-        set (URHO3D_DEFAULT_SSE FALSE)
-    else()
-        # In other platforms, we can safely default to enabling SSE2.
-        set (URHO3D_DEFAULT_SSE TRUE)
-    endif()
+    set (URHO3D_DEFAULT_SSE ${URHO3D_DEFAULT_SSE} CACHE INTERNAL "Default value for URHO3D_SSE build option")
 endif ()
-cmake_dependent_option (URHO3D_SSE "Enable SSE instruction set (Intel platform only including Android on Intel Atom)" ${URHO3D_DEFAULT_SSE} "NOT ARM" FALSE)
+cmake_dependent_option (URHO3D_SSE "Enable SSE2 instruction set (HTML5 and Intel platforms only including Android on Intel Atom)" ${URHO3D_DEFAULT_SSE} "NOT ARM" FALSE)
 if (CMAKE_PROJECT_NAME STREQUAL Urho3D)
     cmake_dependent_option (URHO3D_LUAJIT_AMALG "Enable LuaJIT amalgamated build (LuaJIT only)" FALSE "URHO3D_LUAJIT" FALSE)
     cmake_dependent_option (URHO3D_SAFE_LUA "Enable Lua C++ wrapper safety checks (Lua/LuaJIT only)" FALSE "URHO3D_LUA OR URHO3D_LUAJIT" FALSE)

+ 1 - 1
Docs/GettingStarted.dox

@@ -91,7 +91,7 @@ A number of build options can be defined when invoking the build scripts or when
 |URHO3D_PCH           |1|Enable PCH support|
 |URHO3D_DATABASE_ODBC |0|Enable Database support with ODBC, requires vendor-specific ODBC driver|
 |URHO3D_DATABASE_SQLITE|0|Enable Database support with SQLite embedded|
-|URHO3D_SSE           |1|Enable SSE2 instruction set (Intel platform only including Android on Intel Atom)|
+|URHO3D_SSE           |1|Enable SSE2 instruction set (HTML5 and Intel platforms only including Android on Intel Atom)|
 |URHO3D_MINIDUMPS     |1|Enable minidumps on crash (VS only)|
 |URHO3D_FILEWATCHER   |1|Enable filewatcher support|
 |URHO3D_PACKAGING     |*|Enable resources packaging support, on Emscripten default to 1, on other platforms default to 0|