Skip to content

Commit 45cad0f

Browse files
committed
cmake: Avoid try_run when cross-compiling
1 parent cab47cf commit 45cad0f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cmake/modules/FindCPUflags.cmake

+6-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,12 @@ elseif(ARCHITECTURE_ARM)
282282
if(C_MSVC)
283283
try_run(RUN_NEON COMPILE_NEON "${CMAKE_BINARY_DIR}/tmp" "${TEST_DIR}/test_arm_neon.cxx" COMPILE_DEFINITIONS /O0)
284284
else()
285-
try_run(RUN_NEON COMPILE_NEON "${CMAKE_BINARY_DIR}/tmp" "${TEST_DIR}/test_arm_neon.cxx" COMPILE_DEFINITIONS -mfpu=neon -O0)
285+
if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_SYSTEM_PROCESSOR})
286+
try_run(RUN_NEON COMPILE_NEON "${CMAKE_BINARY_DIR}/tmp" "${TEST_DIR}/test_arm_neon.cxx" COMPILE_DEFINITIONS -mfpu=neon -O0)
287+
else()
288+
try_compile(COMPILE_NEON "${CMAKE_BINARY_DIR}/tmp" "${TEST_DIR}/test_arm_neon.cxx" COMPILE_DEFINITIONS -mfpu=neon -O0)
289+
set(RUN_NEON 0)
290+
endif()
286291
endif()
287292
if(COMPILE_NEON AND RUN_NEON EQUAL 0)
288293
set(HAS_NEON ON CACHE BOOL "Architecture has NEON SIMD enabled")

0 commit comments

Comments
 (0)