Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split SSE cmake option. Use more descriptive names. #191

Merged
merged 6 commits into from
Nov 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,43 @@ else()
endif()

# Whether to enable SSE
option(FCL_USE_SSE "Whether FCL should SSE instructions" ON)
set (SSE_FLAGS "")
option(FCL_USE_X64_SSE "Whether FCL should x64 SSE instructions" ON)
if (FCL_USE_X64_SSE)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(SSE_FLAGS -mfpmath=sse -msse -msse2 -msse3 -mssse3)
elseif(MSVC)
# Win64 will add the flag automatically
if("$CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
set(SSE_FLAGS /arch:SSE2)
endif()
endif()
add_compile_options(${SSE_FLAGS})
endif()

option(FCL_USE_HOST_NATIVE_ARCH "Whether FCL should use cflags from the host used to compile" OFF)
if (FCL_USE_HOST_NATIVE_ARCH)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
else()
message(WARNING "FCL_USE_HOST_NATIVE_ARCH is only supported in Linux. No effect.")
endif()
endif()

# DEPRECATED: old cmake option. Not strictly correct from the semantic point of view
# it was activating march=native, not only SSE
option(FCL_USE_SSE "(deprecated) Whether FCL should SSE instructions" OFF)
if(FCL_USE_SSE)
set(FCL_HAVE_SSE TRUE)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
message(WARNING "FCL_USE_SSE is deprecated please use: FCL_USE_X64_SSE or FCL_USE_HOST_NATIVE_ARCH. "
"If you want to replicate the previous behaviour use FCL_USE_HOST_NATIVE_ARCH")
add_definitions(-march=native)
elseif(MSVC)
add_definitions(/arch:SSE2)
# Win64 will add the flag automatically
if("$CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
add_definitions(/arch:SSE2)
endif()
endif()
endif()

Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ else()
add_library(${PROJECT_NAME} SHARED ${FCL_HEADERS} ${FCL_SOURCE_CODE})
endif()

# Be sure to pass to the consumer the set of SIMD used in the compilation
target_compile_options(${PROJECT_NAME} PUBLIC ${SSE_FLAGS})

set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${FCL_VERSION}
SOVERSION ${FCL_ABI_VERSION})
Expand Down