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()