Skip to content

Commit

Permalink
Merge pull request #98 from cpp-best-practices/native-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya authored Mar 7, 2022
2 parents 592ba69 + 49f6cdc commit d73c1d1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Optimization.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ macro(enable_interprocedural_optimization project_name)
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()

0 comments on commit d73c1d1

Please sign in to comment.