diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1fd40e741fb874ca33eddf8362834b964828cd8d..3d147075c049db4f210a83496649f7c227ed1f95 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -314,6 +314,11 @@ if(COMPILER_SUPPORT_NEON AND OPUS_USE_NEON)
   endif()
 endif()
 
+target_compile_definitions(opus
+                           PRIVATE
+                           $<$<BOOL:${HAVE_LRINT}>:HAVE_LRINT>
+                           $<$<BOOL:${HAVE_LRINTF}>:HAVE_LRINTF>)
+
 install(TARGETS opus
         EXPORT OpusTargets
         ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
diff --git a/opus_config.cmake b/opus_config.cmake
index a0bfd5839c8bba1bd447eb34e3a23049129eb4bf..8d4283c0d36138870fa33caaea97672b27cc631f 100644
--- a/opus_config.cmake
+++ b/opus_config.cmake
@@ -16,6 +16,10 @@ if(HAVE_LIBM)
   list(APPEND OPUS_REQUIRED_LIBRARIES m)
 endif()
 
+include(CheckFunctionExists)
+check_function_exists(lrintf HAVE_LRINTF)
+check_function_exists(lrint HAVE_LRINT)
+
 if(CMAKE_SYSTEM_PROCESSOR MATCHES "(i[0-9]86|x86|X86|amd64|AMD64|x86_64)")
   if(CMAKE_SIZEOF_VOID_P EQUAL 8)
     set(OPUS_CPU_X64 1)