Skip to content

Commit

Permalink
fix macos arm64 build
Browse files Browse the repository at this point in the history
  • Loading branch information
DBraun committed Nov 5, 2023
1 parent c4a012f commit 958bafe
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ set(ALL_FILES
# faust libraries

# Include directories for libfaust
if(NOT FAUST_DIR)
if (NOT DEFINED FAUST_DIR)
set(FAUST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/faust")
endif()
include_directories(${FAUST_DIR}/architecture)
include_directories(${FAUST_DIR}/compiler)
include_directories(${FAUST_DIR}/compiler/utils)

if (NOT LIBFAUST_DIR)
if (NOT DEFINED LIBFAUST_DIR)
if(MSVC)
set(LIBFAUST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libfaust/win64/Release")
elseif(APPLE)
set(LIBFAUST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libfaust/darwin-x64/Release")
message( FATAL_ERROR "LIBFAUST_DIR must be set on macOS." )
else()
set(LIBFAUST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libfaust/ubuntu-x86_64/Release")
endif()
Expand Down
19 changes: 17 additions & 2 deletions build_unix.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
if [ "$(uname)" = "Darwin" ]; then
if [[ $(uname -m) == 'arm64' ]]; then
export LIBFAUST_DIR=$PWD/thirdparty/libfaust/darwin-arm64/Release
else
export LIBFAUST_DIR=$PWD/thirdparty/libfaust/darwin-x64/Release
fi
else
export LIBFAUST_DIR=$PWD/thirdparty/libfaust/ubuntu-x86_64/Release
fi

# todo: if able to build macOS universal:
# CMAKE_OSX_ARCHITECTURES=arm64;x86_64
# export LIBFAUST_DIR=$PWD/thirdparty/libfaust/darwin-universal/Release

# Build libsndfile
cd thirdparty/libsndfile
cmake -Bbuild $CMAKEOPTS -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_FLAGS="-fPIC" -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX="./install"

cmake -Bbuild $CMAKEOPTS -DCMAKE_OSX_ARCHITECTURES=$CMAKE_OSX_ARCHITECTURES -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_FLAGS="-fPIC" -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX="./install"
cmake --build build --config Release
cmake --build build --target install
cd ../..

# Build FaucK
cmake -Bbuild $CMAKEOPTS -DCMAKE_VERBOSE_MAKEFILE=ON
cmake -Bbuild $CMAKEOPTS -DCMAKE_OSX_ARCHITECTURES=$CMAKE_OSX_ARCHITECTURES -DCMAKE_VERBOSE_MAKEFILE=ON -DLIBFAUST_DIR="$LIBFAUST_DIR"
cmake --build build --config Release
cmake --build build --config Release --target install

Expand Down
5 changes: 5 additions & 0 deletions thirdparty/libfaust/make_macos_universal_libfaust.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# copy arm64 into universal just to use the headers
cp -r darwin-arm64 darwin-universal

# combine the static libfaust.a from x64 and arm64 into a universal library.
lipo darwin-x64/Release/lib/libfaust.a darwin-arm64/Release/lib/libfaust.a -create -output darwin-universal/Release/lib/libfaust.a

0 comments on commit 958bafe

Please sign in to comment.