cmake: sse flags were being defined in 2 different places

This commit is contained in:
Campbell Barton
2011-10-01 18:29:40 +00:00
parent 9a88524f68
commit 622e8ee363
2 changed files with 21 additions and 26 deletions

View File

@@ -273,7 +273,7 @@ if(WITH_PYTHON_MODULE)
set(WITH_HEADLESS ON) set(WITH_HEADLESS ON)
endif() endif()
TEST_SSE_SUPPORT() TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
# don't store paths to libs for portable distrobution # don't store paths to libs for portable distrobution
if(WITH_INSTALL_PORTABLE) if(WITH_INSTALL_PORTABLE)
@@ -1128,34 +1128,17 @@ endif()
# See TEST_SSE_SUPPORT() for how this is defined. # See TEST_SSE_SUPPORT() for how this is defined.
if(WITH_RAYOPTIMIZATION) if(WITH_RAYOPTIMIZATION)
if(CMAKE_COMPILER_IS_GNUCC)
set(_sse "-msse")
set(_sse2 "-msse2")
elseif(MSVC)
set(_sse "/arch:SSE")
set(_sse2 "/arch:SSE2")
elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
set(_sse) # icc only has sse2
set(_sse2 "-xSSE2")
else()
message(WARNING "SSE flags for this compiler: '${CMAKE_C_COMPILER_ID}' not known")
set(_sse)
set(_sse2)
endif()
if(SUPPORT_SSE_BUILD) if(SUPPORT_SSE_BUILD)
set(PLATFORM_CFLAGS " ${_sse} ${PLATFORM_CFLAGS}") set(PLATFORM_CFLAGS " ${COMPILER_SSE_FLAG} ${PLATFORM_CFLAGS}")
add_definitions(-D__SSE__ -D__MMX__) add_definitions(-D__SSE__ -D__MMX__)
endif() endif()
if(SUPPORT_SSE2_BUILD) if(SUPPORT_SSE2_BUILD)
set(PLATFORM_CFLAGS " ${_sse2} ${PLATFORM_CFLAGS}") set(PLATFORM_CFLAGS " ${COMPILER_SSE2_FLAG} ${PLATFORM_CFLAGS}")
add_definitions(-D__SSE2__) add_definitions(-D__SSE2__)
if(NOT SUPPORT_SSE_BUILD) # dont double up if(NOT SUPPORT_SSE_BUILD) # dont double up
add_definitions(-D__MMX__) add_definitions(-D__MMX__)
endif() endif()
endif() endif()
unset(_sse)
unset(_sse2)
endif() endif()

View File

@@ -325,18 +325,30 @@ macro(setup_liblinks
endif() endif()
endmacro() endmacro()
macro(TEST_SSE_SUPPORT) macro(TEST_SSE_SUPPORT
_sse_flags
_sse2_flags)
include(CheckCSourceRuns) include(CheckCSourceRuns)
# message(STATUS "Detecting SSE support") # message(STATUS "Detecting SSE support")
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_REQUIRED_FLAGS "-msse -msse2") set(${_sse_flags} "-msse")
set(${_sse2_flags} "-msse2")
elseif(MSVC) elseif(MSVC)
set(CMAKE_REQUIRED_FLAGS "/arch:SSE2") # TODO, SSE 1 ? set(${_sse_flags} "/arch:SSE")
set(${_sse2_flags} "/arch:SSE2")
elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
set(CMAKE_REQUIRED_FLAGS "-xSSE2") set(${_sse_flags}) # icc only has sse2
set(${_sse2_flags} "-xSSE2")
else() else()
message(STATUS "Compiler: '${CMAKE_C_COMPILER_ID}' has no SSE flags defiend for it!") message(WARNING "SSE flags for this compiler: '${CMAKE_C_COMPILER_ID}' not known")
set(_sse_flags)
set(_sse2_flags)
endif()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_REQUIRED_FLAGS ${_sse_flags} ${_sse2_flags})
endif() endif()
if(NOT DEFINED ${SUPPORT_SSE_BUILD}) if(NOT DEFINED ${SUPPORT_SSE_BUILD})