Skip to content

Commit

Permalink
Avoid -march=native on Macs with M1 (#1648)
Browse files Browse the repository at this point in the history
This flag causes issues on M1 Macs, as clang does not support this flag on this platform. Instead, use -march-apple-m1.
  • Loading branch information
Jonathan Archer II committed Mar 11, 2022
1 parent 93a5cd2 commit a792752
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ endif()
######## Platform-specific options
if(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOMINMAX") # Disable min/max macros in windef.h
elseif(APPLE AND (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm.*" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64.*"))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=apple-m1") # Clang on ARM-based Macs does not support -march=native
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()

######## Compiler-specific options
Expand All @@ -89,7 +93,7 @@ else()

set(CMAKE_CXX_FLAGS_DEBUG "-pedantic -O0 -g -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Og -g")
set(CMAKE_CXX_FLAGS_RELEASE "-funroll-loops -O${RELEASE_OPT_LEVEL} -march=native -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-funroll-loops -O${RELEASE_OPT_LEVEL} -DNDEBUG")
endif()

include_directories(${CMAKE_CURRENT_SOURCE_DIR}
Expand Down

0 comments on commit a792752

Please sign in to comment.