Skip to content

Commit

Permalink
Only emit SIMD compiler flags on x86-based platforms
Browse files Browse the repository at this point in the history
Enabling the SSE4.2 or AVX SIMD flags on non-x86 based platforms will
result in a compilation error stating that the -msse4.2 and -mavx flags
cannot be found. This patch causes the flags to only be emitted on x86-based
platforms.

Signed-off-by: jmather-sesi <54645798+jmather-sesi@users.noreply.github.com>
  • Loading branch information
jmather-sesi committed Jul 18, 2023
1 parent f81d1aa commit c68dccb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,16 @@ endif()
# Configure SIMD. AVX implies SSE 4.2.

if(OPENVDB_SIMD STREQUAL "AVX")
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-mavx>")
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-msse4.2>")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-mavx>")
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-msse4.2>")
endif()
add_compile_definitions("$<$<COMPILE_LANGUAGE:CXX>:OPENVDB_USE_AVX>")
add_compile_definitions("$<$<COMPILE_LANGUAGE:CXX>:OPENVDB_USE_SSE42>")
elseif(OPENVDB_SIMD STREQUAL "SSE42")
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-msse4.2>")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-msse4.2>")
endif()
add_compile_definitions("$<$<COMPILE_LANGUAGE:CXX>:OPENVDB_USE_SSE42>")
endif()

Expand Down

0 comments on commit c68dccb

Please sign in to comment.