From c904b676a85e3f42408b423524125068622f05e4 Mon Sep 17 00:00:00 2001 From: Doron Avi-guy Date: Tue, 28 Dec 2021 14:36:10 +0200 Subject: [PATCH 1/2] - adding ARCHITECTURE support to support apple m1 compiliation --- CMakeLists.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a97a9c960..726b36a0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,7 +95,15 @@ option(TONLIB_ENABLE_JNI "Use \"ON\" to enable JNI-compatible TonLib API.") option(TON_USE_ASAN "Use \"ON\" to enable AddressSanitizer." OFF) option(TON_USE_TSAN "Use \"ON\" to enable ThreadSanitizer." OFF) option(TON_USE_UBSAN "Use \"ON\" to enable UndefinedBehaviorSanitizer." OFF) -set(TON_ARCH "native" CACHE STRING "Architecture, will be passed to -march=") + +EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE ) +set(TON_ARCH "native") + +if (ARCHITECTURE MATCHES "arm64") + set(TON_ARCH "apple-m1") + set(CMAKE_CXX_STANDARD 14) +endif() + if (TON_USE_ABSEIL) message("Add abseil-cpp") @@ -204,7 +212,7 @@ find_package(Threads REQUIRED) find_package(ZLIB REQUIRED) if (TON_ARCH AND NOT MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${TON_ARCH}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=${TON_ARCH}") endif() if (THREADS_HAVE_PTHREAD_ARG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") From 5b9345263efdb78a9723c4f11409eced14912a71 Mon Sep 17 00:00:00 2001 From: Doron Avi-guy Date: Tue, 28 Dec 2021 14:41:44 +0200 Subject: [PATCH 2/2] tidy up --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 726b36a0d..67553c303 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,9 +95,8 @@ option(TONLIB_ENABLE_JNI "Use \"ON\" to enable JNI-compatible TonLib API.") option(TON_USE_ASAN "Use \"ON\" to enable AddressSanitizer." OFF) option(TON_USE_TSAN "Use \"ON\" to enable ThreadSanitizer." OFF) option(TON_USE_UBSAN "Use \"ON\" to enable UndefinedBehaviorSanitizer." OFF) - +set(TON_ARCH "native" CACHE STRING "Architecture, will be passed to -march=") EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE ) -set(TON_ARCH "native") if (ARCHITECTURE MATCHES "arm64") set(TON_ARCH "apple-m1")