From 49f6cdcd664f177c796a217522d59c8b059ecc2a Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 5 Mar 2022 22:55:28 -0800 Subject: [PATCH] fix: enable native optimization only on x64 --- src/Optimization.cmake | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Optimization.cmake b/src/Optimization.cmake index 2e9063dd..0b4681c5 100644 --- a/src/Optimization.cmake +++ b/src/Optimization.cmake @@ -11,10 +11,14 @@ macro(enable_interprocedural_optimization) endmacro() macro(enable_native_optimization project_name) - message(STATUS "Enabling the optimizations specific to the current build machine (less portable)") - if(MSVC) - target_compile_options(${project_name} INTERFACE /arch:native) - else() - target_compile_options(${project_name} INTERFACE -march=native) + detect_architecture(_arch) + if("${_arch}" STREQUAL "x64") + message(STATUS "Enabling the optimizations specific to the current build machine (less portable)") + if(MSVC) + # TODO It seems it only accepts the exact instruction set like AVX https://docs.microsoft.com/en-us/cpp/build/reference/arch-x64 + # target_compile_options(${project_name} INTERFACE /arch:native) + else() + target_compile_options(${project_name} INTERFACE -march=native) + endif() endif() endmacro()