check_function_exists has some shortcomings, which fails to detect
isnan when build against musl libc. The cmake documentation [1]
suggests to prefer check_symbol_exists, which detects isnan/isinf
fine on both glibc and musl.
[1] https://cmake.org/cmake/help/latest/module/CheckFunctionExists.html#command:check_function_exists