From 82d93a8697c8f5521b5f1e45f7e865cb7fc4afef Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 16 Nov 2021 21:20:00 -0300 Subject: [PATCH] Update build instructions for Skia m96 & Apple Silicon (#2451) --- CMakeLists.txt | 25 ++++++++++++++----------- INSTALL.md | 29 +++++++++++++++++++++++++++-- third_party/CMakeLists.txt | 2 +- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3119661d2..71d9f4b98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,8 +31,9 @@ set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/laf/cmake/cxx project(aseprite C CXX) if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") - # As we compile with CMAKE_OSX_DEPLOYMENT_TARGET=10.7, we have to - # explicitly say that we want to use libc++ instead of the GNU libstdc++ + # As we compile with CMAKE_OSX_DEPLOYMENT_TARGET=10.9, we have to + # explicitly say that we want to use libc++ instead of the GNU + # libstdc++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") endif() @@ -277,15 +278,7 @@ include_directories(${FREETYPE_INCLUDE_DIRS}) if(USE_SHARED_HARFBUZZ) find_package(HarfBuzz) else() - if(LAF_BACKEND STREQUAL "skia") - # Use the Skia harfbuzz (it's a modified version with C++11 - # mutexes). - add_definitions(-DHAVE_CONFIG_OVERRIDE_H=1) - set(HARFBUZZ_LIBRARIES ${SKIA_HARFBUZZ_LIBRARY}) - set(HARFBUZZ_INCLUDE_DIRS - ${SKIA_DIR}/third_party/harfbuzz - ${SKIA_DIR}/third_party/externals/harfbuzz/src) - else() + if(NOT LAF_BACKEND STREQUAL "skia") set(HARFBUZZ_LIBRARIES harfbuzz) set(HARFBUZZ_INCLUDE_DIRS ${HARFBUZZ_DIR}/src) endif() @@ -348,6 +341,16 @@ set(LAF_WITH_TESTS ${ENABLE_TESTS} CACHE BOOL "Enable LAF tests") set(UNDO_TESTS ${ENABLE_TESTS} CACHE BOOL "Enable undo tests") add_subdirectory(laf) + +# Use the Skia harfbuzz (it's a modified version with C++11 mutexes). +if(LAF_BACKEND STREQUAL "skia") + add_definitions(-DHAVE_CONFIG_OVERRIDE_H=1) + set(HARFBUZZ_LIBRARIES ${SKIA_HARFBUZZ_LIBRARY}) + set(HARFBUZZ_INCLUDE_DIRS + ${SKIA_DIR}/third_party/harfbuzz + ${SKIA_DIR}/third_party/externals/harfbuzz/src) +endif() + add_subdirectory(src) ###################################################################### diff --git a/INSTALL.md b/INSTALL.md index 38f593ebc..3ed97a1ad 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -163,7 +163,7 @@ Run `cmake` with the following parameters and then `ninja`: -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_OSX_ARCHITECTURES=x86_64 \ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 \ - -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk \ + -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk \ -DLAF_BACKEND=skia \ -DSKIA_DIR=$HOME/deps/skia \ -DSKIA_LIBRARY_DIR=$HOME/deps/skia/out/Release-x64 \ @@ -175,9 +175,28 @@ Run `cmake` with the following parameters and then `ninja`: In this case, `$HOME/deps/skia` is the directory where Skia was compiled or downloaded. Make sure that `CMAKE_OSX_SYSROOT` is pointing to the correct SDK directory (in this case -`/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk`), +`/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk`), but it could be different in your Mac. +### Apple Silicon + +If you running macOS on an ARM64/AArch64/Apple Silicon Mac (e.g. M1), +you can compile a native ARM64 version of Aseprite following the same +steps as above but when we call `cmake`, we have some differences: + + cmake \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_OSX_ARCHITECTURES=arm64 \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \ + -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk \ + -DLAF_BACKEND=skia \ + -DSKIA_DIR=$HOME/deps/skia \ + -DSKIA_LIBRARY_DIR=$HOME/deps/skia/out/Release-arm64 \ + -DSKIA_LIBRARY=$HOME/deps/skia/out/Release-arm64/libskia.a \ + -DPNG_ARM_NEON:STRING=on \ + -G Ninja \ + .. + ### Issues with Retina displays If you have a Retina display, check the following issue: @@ -204,6 +223,12 @@ Run `cmake` with the following parameters and then `ninja`: In this case, `$HOME/deps/skia` is the directory where Skia was compiled or uncompressed. +### GCC compiler + +In case that you are using the pre-compiled Skia version, you will +need to use the Clang compiler to compile Aseprite. Only if you +compile Skia with GCC, you will be able to compile Aseprite with GCC. + # Using shared third party libraries If you don't want to use the embedded code of third party libraries diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 893bb4879..95e897a84 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -90,7 +90,7 @@ if(NOT USE_SHARED_FREETYPE) endif() endif() -if(NOT USE_SHARED_HARFBUZZ) +if(NOT USE_SHARED_HARFBUZZ AND NOT LAF_BACKEND STREQUAL "skia") if(NOT USE_SHARED_FREETYPE) set(ENV{FREETYPE_DIR} ${FREETYPE_DIR}) endif()