Skip to content

Commit

Permalink
Allow arm64 build ion macOS by using toolchain file apple.cmake and e…
Browse files Browse the repository at this point in the history
…xporting an EVN-Variable OTR_OSX_ARCH=arm64

I build with after cloning the repo

cd opentrack
export OTR_OSX_ARCH=arm64 ; cmake --toolchain ./cmake/apple.cmake -S . -B build
cd build
make install
  • Loading branch information
Matteo Ceruti committed Aug 31, 2023
1 parent b04381b commit cb26f1a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cmake/apple.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
set(CMAKE_BUILD_TYPE_INIT RELEASE)

set(CMAKE_CXX_FLAGS "-arch x86_64 -stdlib=libc++" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS "-arch x86_64" CACHE STRING "" FORCE)
if("$ENV{OTR_OSX_ARCH}" STREQUAL "arm64")
set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "" FORCE)
set(opentrack-intel FALSE)
else()
set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "" FORCE)
set(opentrack-intel TRUE)
endif()

set(CMAKE_CXX_FLAGS "-stdlib=libc++" CACHE STRING "" FORCE)

set(CMAKE_C_FLAGS_RELEASE "-ffast-math -O3 -flto -g" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE " ${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "" FORCE)

set(cmake-link-common "-stdlib=libc++ -arch x86_64")
set(cmake-link-common "-stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "${cmake-link-common} -Wl,-stack_size,0x4000000" CACHE STRING "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS ${cmake-link-common} CACHE STRING "" FORCE)
set(CMAKE_MODULE_LINKER_FLAGS ${cmake-link-common} CACHE STRING "" FORCE)
Expand Down
2 changes: 2 additions & 0 deletions gui/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ static void set_fp_mask()
#endif

#ifdef __APPLE__
#if defined __i386__ || defined __x86_64__
fesetenv(FE_DFL_DISABLE_SSE_DENORMS_ENV);
#endif
#endif

#ifdef _WIN32
# ifdef __clang__
Expand Down

0 comments on commit cb26f1a

Please sign in to comment.