From e6ef26f33d5f2db2a82346bead201976694d3c5c Mon Sep 17 00:00:00 2001 From: Harry van Haaren Date: Sun, 22 Nov 2015 09:45:41 +0000 Subject: [PATCH] -#106 ARCH check in CMake, removes -msse for arm This commit adds an architecture check to CMake, detecting if we're running on x86_64 or not. If not, disable the sse instructions. This can be improved to handle i686 and some ARM optimization. --- src/CMakeLists.txt | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aff53d4..01c9a20 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,8 @@ +# Detect platform +EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE) +message( STATUS "Architecture: ${ARCHITECTURE}" ) + # Find depend libraries find_package(PkgConfig) @@ -36,16 +40,22 @@ IF(BUILD_TESTS) ADD_DEFINITIONS(-DBUILD_TESTS) ADD_DEFINITIONS(-DBUILD_COVERAGE_TEST) - SET(CMAKE_CXX_FLAGS "-g -Wall -Wextra -Wno-unused-variable -fprofile-arcs -ftest-coverage") - SET(CMAKE_C_FLAGS "-g -Wall -Wextra -W -Wno-unused-variable -fprofile-arcs -ftest-coverage") + SET(CMAKE_CXX_FLAGS " -g -Wall -Wextra -Wno-unused-variable -fprofile-arcs -ftest-coverage ") + SET(CMAKE_C_FLAGS " -g -Wall -Wextra -W -Wno-unused-variable -fprofile-arcs -ftest-coverage ") SET(CMAKE_EXE_LINKER_FLAGS "-fprofile-arcs -ftest-coverage") ENDIF(BUILD_TESTS) IF(RELEASE_BUILD) - SET(CMAKE_CXX_FLAGS "-g -Wall -Wno-unused-variable -msse2 -mfpmath=sse -ffast-math") - SET(CMAKE_C_FLAGS "-g -Wall -W -Wno-unused-variable -msse2 -mfpmath=sse -ffast-math") + SET(CMAKE_CXX_FLAGS " -g -Wall -Wno-unused-variable ") + SET(CMAKE_C_FLAGS " -g -Wall -W -Wno-unused-variable ") ENDIF(RELEASE_BUILD) +if( ${ARCHITECTURE} STREQUAL "x86_64" ) + set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS}"-msse2" ) + set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}"-msse2" ) +else() + # Can set i686 / ARM stuff here +endif() # Add all files FILE(GLOB sources *.cxx avtk/*.cxx cjson/*.c controller/*.cxx dsp/*.cxx observer/*.cxx state/*.cxx tests/*.cxx)