CMake: Add DISABLE_SSE4 option

NOT recommended. Only if you ABSOLUTELY need it.

The SSE2/legacy build will be a separate download option, and
warn you if you try to run it on a CPU that supports SSE4.
This commit is contained in:
Stenzek
2024-09-23 19:20:14 +10:00
parent d67b826033
commit bfc914aaa9
5 changed files with 23 additions and 13 deletions

View File

@ -5,6 +5,7 @@ option(BUILD_NOGUI_FRONTEND "Build the NoGUI frontend" OFF)
option(BUILD_QT_FRONTEND "Build the Qt frontend" ON)
option(BUILD_REGTEST "Build regression test runner" OFF)
option(BUILD_TESTS "Build unit tests" OFF)
option(DISABLE_SSE4 "Build with SSE4 instructions disabled, reduces performance" OFF)
if(LINUX OR BSD)
option(ENABLE_X11 "Support X11 window system" ON)

View File

@ -38,8 +38,7 @@ It does **not** use the LSB subdirectories of bin, share, etc, so you should dis
endif()
if(NOT IS_SUPPORTED_COMPILER)
message(WARNING "
*************** UNSUPPORTED CONFIGURATION ***************
message(WARNING "*************** UNSUPPORTED CONFIGURATION ***************
You are not compiling DuckStation with a supported compiler.
It may not even build successfully.
DuckStation only supports the Clang and MSVC compilers.
@ -48,11 +47,18 @@ No support will be provided, continue at your own risk.
endif()
if(WIN32)
message(WARNING "
*************** UNSUPPORTED CONFIGURATION ***************
message(WARNING "*************** UNSUPPORTED CONFIGURATION ***************
You are compiling DuckStation with CMake on Windows.
It may not even build successfully.
DuckStation only supports MSBuild on Windows.
No support will be provided, continue at your own risk.
*********************************************************")
endif()
if(CPU_ARCH_X64 AND DISABLE_SSE4)
message(WARNING "*********************** WARNING ***********************
SSE4 instructions are disabled. This will result in
reduced performance. You should not enable this option
unless you have a pre-2008 CPU.
*******************************************************")
endif()

View File

@ -69,7 +69,7 @@ function(detect_architecture)
CMAKE_SIZEOF_VOID_P EQUAL 8)
message(STATUS "Building x86_64 binaries.")
set(CPU_ARCH_X64 TRUE PARENT_SCOPE)
if(NOT MSVC OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(NOT MSVC OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT DISABLE_SSE4)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1" PARENT_SCOPE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1" PARENT_SCOPE)
endif()