Skip to content

Commit 791982a

Browse files
authored
Merge pull request #261 from ew1abz/dev
cmake: Avoid try_run when cross-compiling
2 parents adebd06 + 45cad0f commit 791982a

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
@@ -354,7 +354,12 @@ elseif(ARCHITECTURE_ARM)
354354
if(C_MSVC)
355355
try_run(RUN_NEON COMPILE_NEON "${CMAKE_BINARY_DIR}/tmp" "${TEST_DIR}/test_arm_neon.cxx" COMPILE_DEFINITIONS /O0)
356356
else()
357-
try_run(RUN_NEON COMPILE_NEON "${CMAKE_BINARY_DIR}/tmp" "${TEST_DIR}/test_arm_neon.cxx" COMPILE_DEFINITIONS -mfpu=neon -O0)
357+
if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_SYSTEM_PROCESSOR})
358+
try_run(RUN_NEON COMPILE_NEON "${CMAKE_BINARY_DIR}/tmp" "${TEST_DIR}/test_arm_neon.cxx" COMPILE_DEFINITIONS -mfpu=neon -O0)
359+
else()
360+
try_compile(COMPILE_NEON "${CMAKE_BINARY_DIR}/tmp" "${TEST_DIR}/test_arm_neon.cxx" COMPILE_DEFINITIONS -mfpu=neon -O0)
361+
set(RUN_NEON 0)
362+
endif()
358363
endif()
359364
if(COMPILE_NEON AND RUN_NEON EQUAL 0)
360365
set(HAS_NEON ON CACHE BOOL "Architecture has NEON SIMD enabled")

0 commit comments

Comments
 (0)