Build is failing on MacOS (apple m1)

With default setting of Make file I was getting the following error:
clang: error: the clang compiler does not support ‘-march=native’
Then someone from the community also experience an issue with this and solution was provided by changing -march=native to -mcpu=apple-a14, but that landed me on another issue which is omp.h not found. After researching for quite a long time I found out this error is caused of clang incompatibility on apple-m1.

Task :buildJniLib FAILED
Consolidate compiler generated dependencies of target NonMetricSpaceLib
[ 88%] Built target NonMetricSpaceLib
Consolidate compiler generated dependencies of target opensearchknn_common
[ 94%] Built target opensearchknn_common
Consolidate compiler generated dependencies of target opensearchknn_nmslib
[100%] Built target opensearchknn_nmslib
[ 2%] Building CXX object external/faiss/faiss/CMakeFiles/faiss.dir/AutoTune.cpp.o
In file included from /Users/harisalam/Documents/k-NN/jni/external/faiss/faiss/AutoTune.cpp:34:
In file included from /Users/harisalam/Documents/k-NN/jni/external/faiss/faiss/IndexHNSW.h:14:
/Users/harisalam/Documents/k-NN/jni/external/faiss/faiss/impl/HNSW.h:16:10: fatal error: ‘omp.h’ file not found
#include <omp.h>
^~~~~~~
1 error generated.
make[3]: *** [external/faiss/faiss/CMakeFiles/faiss.dir/AutoTune.cpp.o] Error 1
make[2]: *** [external/faiss/faiss/CMakeFiles/faiss.dir/all] Error 2
make[1]: *** [CMakeFiles/opensearchknn_faiss.dir/rule] Error 2
make: *** [opensearchknn_faiss] Error 2

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:buildJniLib’.

Process ‘command ‘make’’ finished with non-zero exit value 2