Add -march=native for compilers that support it

This commit is contained in:
Mustafa Al-Bassam 2018-08-22 19:33:22 +01:00
parent 01cd769606
commit 817d2c90b9
1 changed files with 5 additions and 0 deletions

View File

@ -28,6 +28,11 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
check_cxx_compiler_flag("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
check_cxx_compiler_flag("/O2" CXX_FLAG_O2)
check_cxx_compiler_flag("/Oy" CXX_FLAG_Oy)