Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Fix compilation error on Apple Silicon #1176

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,23 @@ set (fasttext_VERSION_MINOR 1)

include_directories(fasttext)

set(CMAKE_CXX_FLAGS " -pthread -std=c++11 -funroll-loops -O3 -march=native")
if(APPLE)
# on macOS "uname -m" returns the architecture (x86_64 or arm64)
execute_process(
COMMAND uname -m
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

command uname-apple-script

RESULT_VARIABLE result
OUTPUT_VARIABLE FASTTEXT_OSX_NATIVE_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(FASTTEXT_OSX_NATIVE_ARCHITECTURE STREQUAL "arm64")
set(CMAKE_CXX_FLAGS " -pthread -std=c++11 -funroll-loops -O3")
else()
set(CMAKE_CXX_FLAGS " -pthread -std=c++11 -funroll-loops -O3 -march=native")
endif()
else()
set(CMAKE_CXX_FLAGS " -pthread -std=c++11 -funroll-loops -O3 -march=native")
endif()

set(HEADER_FILES
src/args.h
Expand Down