From d14c1f13d88fdbfb4f38acab2ab2d4918bd41f30 Mon Sep 17 00:00:00 2001 From: lizzie Date: Thu, 8 Oct 2026 12:41:37 +0000 Subject: [PATCH] [cmake] Add M1 to BUILD_PRESET, more proper tuning Signed-off-by: lizzie --- CMakeLists.txt | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f647204a4b..0b60be6ed1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -322,47 +322,42 @@ endif() # Build/optimization presets if (CXX_GCC OR CXX_CLANG) - if (ARCHITECTURE_x86_64) + # GCC/clang will -mtune=generic by default + if ("${YUZU_BUILD_PRESET}" STREQUAL "native") + add_compile_options( + $<$:-march=native> + $<$:-mtune=native>) + elseif (ARCHITECTURE_x86_64) # See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html # Generic supports Pentium Pro instruction set and above # TODO: if a value is unknown, pass that as march and mtune set(YUZU_BUILD_PRESET "custom" CACHE STRING "Build preset to use. One of: custom, generic, v3, zen2, zen4, native") - if (${YUZU_BUILD_PRESET} STREQUAL "generic") - set(march x86-64) - set(mtune generic) + add_compile_options($<$:-march=x86-64>) elseif (${YUZU_BUILD_PRESET} STREQUAL "v3") - set(march x86-64-v3) - set(mtune generic) + add_compile_options($<$:-march=x86-64-v3>) elseif (${YUZU_BUILD_PRESET} STREQUAL "zen2") - set(march znver2) - set(mtune znver2) + add_compile_options( + $<$:-march=znver2> + $<$:-mtune=znver4>) elseif (${YUZU_BUILD_PRESET} STREQUAL "zen4") - set(march znver4) - set(mtune znver4) + add_compile_options( + $<$:-march=znver4> + $<$:-mtune=znver4>) endif() elseif(ARCHITECTURE_arm64) # See https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html - set(YUZU_BUILD_PRESET "custom" CACHE STRING "Build preset to use. One of: custom, generic, optimized, armv9, native") - set(mtune generic) + set(YUZU_BUILD_PRESET "custom" CACHE STRING "Build preset to use. One of: custom, generic, optimized, armv9, m1, native") if (${YUZU_BUILD_PRESET} STREQUAL "generic") - set(march armv8-a) + add_compile_options($<$:-march=armv8-a>) elseif (${YUZU_BUILD_PRESET} STREQUAL "optimized") - set(march armv8.2-a+lse+rcpc) + add_compile_options($<$:-march=armv8.2-a+lse+rcpc>) elseif (${YUZU_BUILD_PRESET} STREQUAL "armv9") - set(march armv9-a) + add_compile_options($<$:-march=armv9-a>) + elseif (${YUZU_BUILD_PRESET} STREQUAL "m1") + add_compile_options($<$:-mcpu=apple-m1>) endif() endif() - - if ("${YUZU_BUILD_PRESET}" STREQUAL "native") - set(march native) - set(mtune native) - endif() - - if (DEFINED march AND DEFINED mtune) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${march} -mtune=${mtune}") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=${march} -mtune=${mtune}") - endif() endif() # Configure C++ standard