Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Improve CMake handling of sse2 and sse3 (#14757)
Browse files Browse the repository at this point in the history
Fix #14304 where CFLAGS were overriden instead of appended to.
  • Loading branch information
larroy authored and apeforest committed Apr 25, 2019
1 parent 3d3803e commit 97e09f2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ else(MSVC)
# For cross compilation, we can't rely on the compiler which accepts the flag, but mshadow will
# add platform specific includes not available in other arches
if(USE_SSE)
check_cxx_compiler_flag("-msse3" SUPPORT_MSSE3)
check_cxx_compiler_flag("-msse2" SUPPORT_MSSE2)
else()
set(SUPPORT_MSSE2 FALSE)
Expand All @@ -134,14 +135,15 @@ else(MSVC)
set(SUPPORT_F16C FALSE)
endif()
if(SUPPORT_F16C)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mf16c")
message(STATUS "F16C enabled")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mf16c")
else()
add_definitions(-DMSHADOW_USE_F16C=0)
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_C_FLAGS "-Wall -Wno-unknown-pragmas -Wno-sign-compare")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-unknown-pragmas -Wno-sign-compare")
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES ".*Clang$")
set(CMAKE_C_FLAGS "-Wno-braced-scalar-init")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-braced-scalar-init")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g")
Expand All @@ -152,7 +154,9 @@ else(MSVC)
add_definitions(-DNDEBUG=1)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
endif()
if(SUPPORT_MSSE2)
if(SUPPORT_MSSE3)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3")
elseif(SUPPORT_MSSE2)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
endif()
set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
Expand Down Expand Up @@ -403,8 +407,8 @@ if(USE_OPENCV)
endif()
include_directories(SYSTEM ${OpenCV_INCLUDE_DIRS})
list(APPEND mxnet_LINKER_LIBS ${OpenCV_LIBS})
message(STATUS " OpenCV_LIBS=${OpenCV_LIBS}")
message(STATUS "OpenCV ${OpenCV_VERSION} found (${OpenCV_CONFIG_PATH})")
message(STATUS " OpenCV_LIBS=${OpenCV_LIBS}")
add_definitions(-DMXNET_USE_OPENCV=1)
else(USE_OPENCV)
message(STATUS "OpenCV Disabled")
Expand Down

0 comments on commit 97e09f2

Please sign in to comment.