Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Werner <stewreo@gmail.com>2020-07-16 10:25:55 +0300
committerStefan Werner <stewreo@gmail.com>2020-07-16 10:37:38 +0300
commit9715ad5acad9a42b65efd64b6c7fbe157f949bfb (patch)
tree9a68c332ede76d239ee45e970171df6864bf4633 /build_files/cmake
parentad4928a1710fe96749484b3823513d3f7c5624aa (diff)
macOS: Support arm64 architecture.
Enabling all `make deps` dependencies with the exception of Embree and OIDN. After that, Blender can be compiled on an Apple Silicon Mac just like on any Intel based Mac. There are still compiler warnings that need to be investigated and there are probably a couple of bug still to be discovered and to be fixed. Most patches to the dependencies are simple and are about disabling SSE and setting the proper architecture to compiile for. Notable exception is Python, where I back ported a yet to be accepted PR for upstream Python: https://github.com/python/cpython/pull/21249 Cross compiling or buliding a Universal Binary is not supported yet. The minimum macOS target version for x86_64 remains at 10.13, the target for arm64 is 11.00. Differential Revision: https://developer.blender.org/D8236
Diffstat (limited to 'build_files/cmake')
-rw-r--r--build_files/cmake/platform/platform_apple.cmake16
-rw-r--r--build_files/cmake/platform/platform_apple_xcode.cmake21
2 files changed, 28 insertions, 9 deletions
diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake
index b24d7734423..a80b0b56901 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -20,7 +20,11 @@
# Libraries configuration for Apple.
-set(MACOSX_DEPLOYMENT_TARGET "10.13")
+if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
+ set(MACOSX_DEPLOYMENT_TARGET 11.00)
+else()
+ set(MACOSX_DEPLOYMENT_TARGET 10.13)
+endif()
macro(find_package_wrapper)
# do nothing, just satisfy the macro
@@ -378,6 +382,12 @@ if(WITH_CYCLES_OSL)
endif()
endif()
+if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
+ set(WITH_CYCLES_EMBREE OFF)
+ set(WITH_OPENIMAGEDENOISE OFF)
+ set(WITH_CPU_SSE OFF)
+endif()
+
if(WITH_CYCLES_EMBREE)
find_package(Embree 3.8.0 REQUIRED)
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Xlinker -stack_size -Xlinker 0x100000")
@@ -439,8 +449,8 @@ if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR CMAKE_OSX_ARCHITECTURES MATCHES "
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ftree-vectorize -fvariable-expansion-in-unroller")
endif()
else()
- set(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
- set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
+ set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic -fno-strict-aliasing")
+ set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -fno-strict-aliasing")
endif()
if(${XCODE_VERSION} VERSION_EQUAL 5 OR ${XCODE_VERSION} VERSION_GREATER 5)
diff --git a/build_files/cmake/platform/platform_apple_xcode.cmake b/build_files/cmake/platform/platform_apple_xcode.cmake
index 434c2ee31b9..3a43ca317dd 100644
--- a/build_files/cmake/platform/platform_apple_xcode.cmake
+++ b/build_files/cmake/platform/platform_apple_xcode.cmake
@@ -21,8 +21,10 @@
# Xcode and system configuration for Apple.
if(NOT CMAKE_OSX_ARCHITECTURES)
- set(CMAKE_OSX_ARCHITECTURES x86_64 CACHE STRING
- "Choose the architecture you want to build Blender for: i386, x86_64 or ppc"
+ execute_process(COMMAND uname -m OUTPUT_VARIABLE ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
+ message(STATUS "Detected native architecture ${ARCHITECTURE}.")
+ set(CMAKE_OSX_ARCHITECTURES ${ARCHITECTURE} CACHE STRING
+ "Choose the architecture you want to build Blender for: arm64 or x86_64"
FORCE)
endif()
@@ -129,14 +131,21 @@ if(${CMAKE_GENERATOR} MATCHES "Xcode")
endif()
unset(OSX_SDKROOT)
+
# 10.13 is our min. target, if you use higher sdk, weak linking happens
+if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
+ set(OSX_MIN_DEPLOYMENT_TARGET 11.00)
+else()
+ set(OSX_MIN_DEPLOYMENT_TARGET 10.13)
+endif()
+
if(CMAKE_OSX_DEPLOYMENT_TARGET)
- if(${CMAKE_OSX_DEPLOYMENT_TARGET} VERSION_LESS 10.13)
- message(STATUS "Setting deployment target to 10.13, lower versions are not supported")
- set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "" FORCE)
+ if(${CMAKE_OSX_DEPLOYMENT_TARGET} VERSION_LESS ${OSX_MIN_DEPLOYMENT_TARGET})
+ message(STATUS "Setting deployment target to ${OSX_MIN_DEPLOYMENT_TARGET}, lower versions are not supported")
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "${OSX_MIN_DEPLOYMENT_TARGET}" CACHE STRING "" FORCE)
endif()
else()
- set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "" FORCE)
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "${OSX_MIN_DEPLOYMENT_TARGET}" CACHE STRING "" FORCE)
endif()
if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode")