Skip to content

Commit

Permalink
[build] Modify default SIMD option for Visual Studio as well
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed Oct 13, 2016
1 parent a5c3d43 commit 16b562b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
8 changes: 0 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,6 @@ if(MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DART_RUNTIME_LIBRARY}d /Zi /Gy /W1 /EHsc")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${DART_RUNTIME_LIBRARY} /Zi /GL /Gy /W1 /EHsc")
endif(NOT DART_MSVC_DEFAULT_OPTIONS)
if(DART_ENABLE_SIMD)
add_definitions(/arch:SSE2 /arch:AVX /arch:AVX2)
# /arch:SSE2 option is effective only for x86 but not for x64 since it's
# enabled for x64 by default. The option will be ignored on x64 with a
# warning message. If anyone knows how to detect the system's architecture
# in CMake time, then I would gratefully apply these options differently
# depending on the architectures.
endif()

elseif(CMAKE_COMPILER_IS_GNUCXX)

Expand Down
15 changes: 13 additions & 2 deletions dart/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,19 @@ target_link_libraries(
)

# Build DART with all available SIMD instructions
if(DART_ENABLE_SIMD AND NOT MSVC)
target_compile_options(dart PUBLIC -march=native)
if(DART_ENABLE_SIMD)
if(MSVC)
target_compile_options(dart PUBLIC /arch:SSE2 /arch:AVX /arch:AVX2)
# /arch:SSE2 option is effective only for x86 but not for x64 since it's
# enabled for x64 by default. The option will be ignored on x64 with a
# warning message. If anyone knows how to detect the system's architecture
# in CMake time, then I would gratefully apply these options differently
# depending on the architectures.
elseif(CMAKE_COMPILER_IS_GNUCXX)
target_compile_options(dart PUBLIC -march=native)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
target_compile_options(dart PUBLIC -march=native)
endif()
endif()

# Default component
Expand Down

0 comments on commit 16b562b

Please sign in to comment.