From 817d2c90b97323476049b008465cd74efe2830e7 Mon Sep 17 00:00:00 2001 From: Mustafa Al-Bassam Date: Wed, 22 Aug 2018 19:33:22 +0100 Subject: [PATCH] Add -march=native for compilers that support it --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 041deb6..5ef59d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)