Skip to content

Commit

Permalink
Fix for NEON support on Apple M1 processors
Browse files Browse the repository at this point in the history
Fixes #362
  • Loading branch information
rserban committed Feb 9, 2022
1 parent 71e3975 commit 0da8189
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ set(CPACK_PACKAGE_VERSION_PATCH "${CHRONO_VERSION_PATCH}")
# Version as a hexadecimal integer of the form 0x00MMmmPP
set(CH_VERSION 0x00070000)

#-----------------------------------------------------------------------------
# Detect operating system and processor for host and target
#-----------------------------------------------------------------------------
message(STATUS "We are on a ${CMAKE_HOST_SYSTEM_NAME} system")
message(STATUS "The host processor is ${CMAKE_HOST_SYSTEM_PROCESSOR}")
message(STATUS "Building for a ${CMAKE_SYSTEM_NAME} system")
message(STATUS "The target processor is ${CMAKE_SYSTEM_PROCESSOR}")

#-----------------------------------------------------------------------------
# Location of additional CMake scripts
#-----------------------------------------------------------------------------
Expand Down
10 changes: 7 additions & 3 deletions cmake/FindNEON.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} "-dumpversion" OUTPUT_VARIABLE GCC_VERSION_STRING)
if(GCC_VERSION_STRING VERSION_GREATER 4.2 AND NOT APPLE AND NOT CMAKE_CROSSCOMPILING)
SET(NEON_FLAGS "${NEON_FLAGS} -march=native")
message(STATUS "Using CPU native flags for NEON optimization: ${NEON_FLAGS}")
message(STATUS " Trying NEON optimization flags: ${NEON_FLAGS}")
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CROSSCOMPILING)
SET(NEON_FLAGS "${NEON_FLAGS} -march=native")
message(STATUS "Using CPU native flags for NEON optimization: ${NEON_FLAGS}")
if(APPLE)
SET(NEON_FLAGS "${NEON_FLAGS} -mcpu=apple-m1")
else()
SET(NEON_FLAGS "${NEON_FLAGS} -march=native")
endif()
message(STATUS " Trying NEON optimization flags: ${NEON_FLAGS}")
endif()

include(CheckCXXSourceRuns)
Expand Down

0 comments on commit 0da8189

Please sign in to comment.