From e8e1ffefa9f703df226609ed569dd5b99e0ca20f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20La=C3=ADns?= Date: Wed, 5 Feb 2020 23:35:02 +0000 Subject: [PATCH] cmake: enable choosing CPU extesions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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 --- CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23e1554a3..a2adcc84f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,7 @@ option(ENABLE_SRSENB "Build srsENB application" ON) option(ENABLE_SRSEPC "Build srsEPC application" ON) option(ENABLE_5GNR "Build with 5G-NR components" 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_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_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) 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) @@ -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") endif (USE_GLIBC_IPV6) - find_package(SSE) + if (AUTO_DETECT_ISA) + find_package(SSE) + endif (AUTO_DETECT_ISA) 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") else (HAVE_AVX2)