From 45cad0ff78e3e9da63798373432e3791be735f0d Mon Sep 17 00:00:00 2001 From: Vladimir K Date: Sun, 29 Mar 2020 19:12:43 -0700 Subject: [PATCH] cmake: Avoid try_run when cross-compiling --- cmake/modules/FindCPUflags.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmake/modules/FindCPUflags.cmake b/cmake/modules/FindCPUflags.cmake index 461fe74..49cfb44 100644 --- a/cmake/modules/FindCPUflags.cmake +++ b/cmake/modules/FindCPUflags.cmake @@ -282,7 +282,12 @@ elseif(ARCHITECTURE_ARM) if(C_MSVC) try_run(RUN_NEON COMPILE_NEON "${CMAKE_BINARY_DIR}/tmp" "${TEST_DIR}/test_arm_neon.cxx" COMPILE_DEFINITIONS /O0) else() - try_run(RUN_NEON COMPILE_NEON "${CMAKE_BINARY_DIR}/tmp" "${TEST_DIR}/test_arm_neon.cxx" COMPILE_DEFINITIONS -mfpu=neon -O0) + if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_SYSTEM_PROCESSOR}) + try_run(RUN_NEON COMPILE_NEON "${CMAKE_BINARY_DIR}/tmp" "${TEST_DIR}/test_arm_neon.cxx" COMPILE_DEFINITIONS -mfpu=neon -O0) + else() + try_compile(COMPILE_NEON "${CMAKE_BINARY_DIR}/tmp" "${TEST_DIR}/test_arm_neon.cxx" COMPILE_DEFINITIONS -mfpu=neon -O0) + set(RUN_NEON 0) + endif() endif() if(COMPILE_NEON AND RUN_NEON EQUAL 0) set(HAS_NEON ON CACHE BOOL "Architecture has NEON SIMD enabled")