From 6d7a5e68b61a3cc929996b627b7e37a04c295761 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Sat, 23 Mar 2024 07:23:45 +0800 Subject: [PATCH] CMakeLists: fix GCC flags Fixes: https://github.com/nmslib/hnswlib/issues/547 --- CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index be0d40f0..9a23be25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,17 @@ if(HNSWLIB_EXAMPLES) endif() endif() elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - SET( CMAKE_CXX_FLAGS "-Ofast -lrt -std=c++11 -DHAVE_CXX0X -march=native -fpic -w -fopenmp -ftree-vectorize -ftree-vectorizer-verbose=0" ) + SET( CMAKE_CXX_FLAGS "-Ofast -std=c++11 -DHAVE_CXX0X -fpic -w -fopenmp -ftree-vectorize -ftree-vectorizer-verbose=0" ) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc|powerpc") + SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=native" ) + message("set -mtune=native flag") + else() + SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native" ) + message("set -march=native flag") + endif() + if(NOT APPLE) + SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lrt" ) + endif() elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") SET( CMAKE_CXX_FLAGS "/O2 -DHAVE_CXX0X /W1 /openmp /EHsc" ) endif()