cmake: enable choosing CPU extesions

`AUTO_DETECT_ISA` will disable the resolution of the SSE packages
and the user will have to manually set `HAVE_{AVX,AVX2,SSE}`.

Solves #453

Signed-off-by: Filipe Laíns <lains@archlinux.org>
master
Filipe Laíns 5 years ago committed by Andre Puschmann
parent db91e9e772
commit e8e1ffefa9

@ -67,6 +67,7 @@ option(ENABLE_SRSENB "Build srsENB application" ON)
option(ENABLE_SRSEPC "Build srsEPC application" ON) option(ENABLE_SRSEPC "Build srsEPC application" ON)
option(ENABLE_5GNR "Build with 5G-NR components" OFF) option(ENABLE_5GNR "Build with 5G-NR components" OFF)
option(DISABLE_SIMD "disable simd instructions" OFF) option(DISABLE_SIMD "disable simd instructions" OFF)
option(AUTO_DETECT_ISA "Autodetect supported ISA extensions" ON)
option(ENABLE_GUI "Enable GUI (using srsGUI)" ON) option(ENABLE_GUI "Enable GUI (using srsGUI)" ON)
option(ENABLE_UHD "Enable UHD" ON) option(ENABLE_UHD "Enable UHD" ON)
@ -329,7 +330,10 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
ADD_C_COMPILER_FLAG_IF_AVAILABLE("-Wno-unused-but-set-variable" HAVE_WNO_UNUSED_BUT_SET_VARIABLE) ADD_C_COMPILER_FLAG_IF_AVAILABLE("-Wno-unused-but-set-variable" HAVE_WNO_UNUSED_BUT_SET_VARIABLE)
ADD_CXX_COMPILER_FLAG_IF_AVAILABLE("-Wno-unused-but-set-variable" HAVE_WNO_UNUSED_BUT_SET_VARIABLE) ADD_CXX_COMPILER_FLAG_IF_AVAILABLE("-Wno-unused-but-set-variable" HAVE_WNO_UNUSED_BUT_SET_VARIABLE)
find_package(SSE) if (AUTO_DETECT_ISA)
find_package(SSE)
endif (AUTO_DETECT_ISA)
if (HAVE_AVX2) if (HAVE_AVX2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${GCC_ARCH} -mfpmath=sse -mavx2 -DLV_HAVE_AVX2 -DLV_HAVE_AVX -DLV_HAVE_SSE") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${GCC_ARCH} -mfpmath=sse -mavx2 -DLV_HAVE_AVX2 -DLV_HAVE_AVX -DLV_HAVE_SSE")
else (HAVE_AVX2) else (HAVE_AVX2)
@ -380,7 +384,9 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_GLIBC_IPV6") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_GLIBC_IPV6")
endif (USE_GLIBC_IPV6) endif (USE_GLIBC_IPV6)
find_package(SSE) if (AUTO_DETECT_ISA)
find_package(SSE)
endif (AUTO_DETECT_ISA)
if (HAVE_AVX2) if (HAVE_AVX2)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=${GCC_ARCH} -mfpmath=sse -mavx2 -DLV_HAVE_AVX2 -DLV_HAVE_AVX -DLV_HAVE_SSE") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=${GCC_ARCH} -mfpmath=sse -mavx2 -DLV_HAVE_AVX2 -DLV_HAVE_AVX -DLV_HAVE_SSE")
else (HAVE_AVX2) else (HAVE_AVX2)

Loading…
Cancel
Save