diff --git a/circuits/cpp/barretenberg/cpp/cmake/toolchains/aarch64-darwin.cmake b/circuits/cpp/barretenberg/cpp/cmake/toolchains/aarch64-darwin.cmake index a3b8d52fa72..5cf78980483 100644 --- a/circuits/cpp/barretenberg/cpp/cmake/toolchains/aarch64-darwin.cmake +++ b/circuits/cpp/barretenberg/cpp/cmake/toolchains/aarch64-darwin.cmake @@ -1,2 +1,11 @@ set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR aarch64) + +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Clang allows us to cross compile on Mac + # so we explicitly specify the arch to the compiler + # If you just select the arch toolchain and are on an + # x86_64, it will compile for x86_64 mac. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch arm64") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch arm64") +endif() \ No newline at end of file diff --git a/circuits/cpp/barretenberg/cpp/cmake/toolchains/x86_64-darwin.cmake b/circuits/cpp/barretenberg/cpp/cmake/toolchains/x86_64-darwin.cmake index 0aa93407fbd..47b58dcc854 100644 --- a/circuits/cpp/barretenberg/cpp/cmake/toolchains/x86_64-darwin.cmake +++ b/circuits/cpp/barretenberg/cpp/cmake/toolchains/x86_64-darwin.cmake @@ -1,2 +1,11 @@ set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR x86_64) + +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Clang allows us to cross compile on Mac + # so we explicitly specify the arch to the compiler + # If you just select the x86_64 toolchain and are on an + # M1/arm64 mac, it will compile for arm64. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch x86_64") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64") +endif() diff --git a/circuits/cpp/cmake/toolchains/aarch64-darwin.cmake b/circuits/cpp/cmake/toolchains/aarch64-darwin.cmake index 8899c4b1c00..227680938b4 100644 --- a/circuits/cpp/cmake/toolchains/aarch64-darwin.cmake +++ b/circuits/cpp/cmake/toolchains/aarch64-darwin.cmake @@ -1,4 +1,11 @@ set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR aarch64) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch arm64") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch arm64") \ No newline at end of file + +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Clang allows us to cross compile on Mac + # so we explicitly specify the arch to the compiler + # If you just select the arch toolchain and are on an + # x86_64, it will compile for x86_64 mac. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch arm64") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch arm64") +endif() diff --git a/circuits/cpp/cmake/toolchains/x86_64-darwin.cmake b/circuits/cpp/cmake/toolchains/x86_64-darwin.cmake index 535814275ba..47b58dcc854 100644 --- a/circuits/cpp/cmake/toolchains/x86_64-darwin.cmake +++ b/circuits/cpp/cmake/toolchains/x86_64-darwin.cmake @@ -1,4 +1,11 @@ set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR x86_64) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch x86_64") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64") + +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Clang allows us to cross compile on Mac + # so we explicitly specify the arch to the compiler + # If you just select the x86_64 toolchain and are on an + # M1/arm64 mac, it will compile for arm64. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch x86_64") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64") +endif()