-#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.
This commit is contained in:
Harry van Haaren 2015-11-22 09:45:41 +00:00
parent a6f5c797ad
commit e6ef26f33d

View file

@ -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)