Skip to content
Snippets Groups Projects
Commit f39143bc authored by Brecht Van Lommel's avatar Brecht Van Lommel
Browse files

CMake: reduce Neon related output on Intel platforms

* Only try to find sse2neon if Neon detected
* Only run Neon support test once
parent 77bc5510
No related branches found
No related tags found
No related merge requests found
...@@ -901,6 +901,18 @@ if(NOT CMAKE_BUILD_TYPE MATCHES "Release") ...@@ -901,6 +901,18 @@ if(NOT CMAKE_BUILD_TYPE MATCHES "Release")
endif() endif()
endif() endif()
# Test SIMD support, before platform includes to determine if sse2neon is needed.
if(WITH_CPU_SIMD)
set(COMPILER_SSE_FLAG)
set(COMPILER_SSE2_FLAG)
# Test Neon first since macOS Arm can compile and run x86-64 SSE binaries.
TEST_NEON_SUPPORT()
if(NOT SUPPORT_NEON_BUILD)
TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
endif()
endif()
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Main Platform Checks # Main Platform Checks
# #
...@@ -956,16 +968,11 @@ if(WITH_INTERNATIONAL) ...@@ -956,16 +968,11 @@ if(WITH_INTERNATIONAL)
endif() endif()
endif() endif()
# See TEST_SSE_SUPPORT() and TEST_NEON_SUPPORT() for how these are defined. # Enable SIMD support if detected by TEST_SSE_SUPPORT() or TEST_NEON_SUPPORT().
# #
# This is done globally, so that all modules can use it if available, and # This is done globally, so that all modules can use it if available, and
# because these are used in headers used by many modules. # because these are used in headers used by many modules.
if(WITH_CPU_SIMD) if(WITH_CPU_SIMD)
set(COMPILER_SSE_FLAG)
set(COMPILER_SSE2_FLAG)
# Test Neon first since macOS Arm can compile and run x86-64 SSE binaries.
TEST_NEON_SUPPORT()
if(SUPPORT_NEON_BUILD) if(SUPPORT_NEON_BUILD)
# Neon # Neon
if(SSE2NEON_FOUND) if(SSE2NEON_FOUND)
...@@ -974,7 +981,6 @@ if(WITH_CPU_SIMD) ...@@ -974,7 +981,6 @@ if(WITH_CPU_SIMD)
endif() endif()
else() else()
# SSE # SSE
TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
if(SUPPORT_SSE_BUILD) if(SUPPORT_SSE_BUILD)
string(PREPEND PLATFORM_CFLAGS "${COMPILER_SSE_FLAG} ") string(PREPEND PLATFORM_CFLAGS "${COMPILER_SSE_FLAG} ")
add_definitions(-D__SSE__ -D__MMX__) add_definitions(-D__SSE__ -D__MMX__)
......
...@@ -682,11 +682,13 @@ macro(TEST_SSE_SUPPORT ...@@ -682,11 +682,13 @@ macro(TEST_SSE_SUPPORT
endmacro() endmacro()
macro(TEST_NEON_SUPPORT) macro(TEST_NEON_SUPPORT)
if(NOT DEFINED SUPPORT_NEON_BUILD)
include(CheckCXXSourceCompiles) include(CheckCXXSourceCompiles)
check_cxx_source_compiles( check_cxx_source_compiles(
"#include <arm_neon.h> "#include <arm_neon.h>
int main() {return vaddvq_s32(vdupq_n_s32(1));}" int main() {return vaddvq_s32(vdupq_n_s32(1));}"
SUPPORT_NEON_BUILD) SUPPORT_NEON_BUILD)
endif()
endmacro() endmacro()
# Only print message if running CMake first time # Only print message if running CMake first time
......
...@@ -324,7 +324,7 @@ if(WITH_NANOVDB) ...@@ -324,7 +324,7 @@ if(WITH_NANOVDB)
find_package(NanoVDB) find_package(NanoVDB)
endif() endif()
if(WITH_CPU_SIMD) if(WITH_CPU_SIMD AND SUPPORT_NEON_BUILD)
find_package(sse2neon) find_package(sse2neon)
endif() endif()
......
...@@ -285,7 +285,7 @@ if(WITH_NANOVDB) ...@@ -285,7 +285,7 @@ if(WITH_NANOVDB)
endif() endif()
endif() endif()
if(WITH_CPU_SIMD) if(WITH_CPU_SIMD AND SUPPORT_NEON_BUILD)
find_package_wrapper(sse2neon) find_package_wrapper(sse2neon)
endif() endif()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment