tests: link against libm if necessary
@@ -53,7 +53,17 @@ else()
unset(orig_req_libs)
endif()
-find_library(LIBM m)
+check_function_exists(fegetround FEGETROUND_EXISTS)
+if(NOT FEGETROUND_EXISTS)
+ unset(FEGETROUND_EXISTS CACHE)
+ list(APPEND CMAKE_REQUIRED_LIBRARIES m)
+ check_function_exists(fegetround FEGETROUND_EXISTS)
+ if(FEGETROUND_EXISTS)
+ set(NEED_LIBM True)
+ else()
+ message(FATAL_ERROR "Unable to find fegetround")
+ endif()
+endif(NOT FEGETROUND_EXISTS)
set_property(TARGET munit PROPERTY C_STANDARD "99")
if("${CLOCK_GETTIME_EXISTS}")
@@ -121,8 +131,8 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${extra_cflags}")
add_executable(run-tests test.c test-common.c)
target_link_libraries(run-tests munit simde-test-no-native simde-test-native)
-if(LIBM)
- target_link_libraries(run-tests ${LIBM})
+if(NEED_LIBM)
+ target_link_libraries(run-tests m)
endif()
if (NOT DISABLE_X86)
foreach(tst "/x86/mmx" "/x86/sse" "/x86/sse2" "/x86/sse3" "/x86/ssse3" "/x86/sse4.1" "/x86/sse4.2" "/x86/avx" "/x86/avx2")
