Skip to content
Snippets Groups Projects
Verified Commit a80e9e95 authored by Marcus Asteborg's avatar Marcus Asteborg Committed by Mark Harris
Browse files

cmake - fix lrintf, lrint detection


This commit addresses the issues of not finding lrintf and lrint. We
switch to check_symbol_exists instead per cmake documentation. Also
make sure to link math lib for detection for nix.

For MSVC the issue for non x86 builds was that the standard was set to
default which is 199409L. This resulted in not using lrintf even that
it was found. To address this we set the C standard to C11 and it will
only apply to newer versions of MSVC where the /std flag is supported.

Signed-off-by: default avatarMark Harris <mark.hsj@gmail.com>
parent f1b08800
No related branches found
No related tags found
No related merge requests found
......@@ -9,16 +9,18 @@ configure_file(cmake/config.h.cmake.in config.h @ONLY)
add_definitions(-DHAVE_CONFIG_H)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY C_STANDARD 99)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
# For compilers that have no notion of a C standard level,
# such as Microsoft Visual C++ before VS 16.7,
# this property has no effect.
set(CMAKE_C_STANDARD 11)
else()
set(CMAKE_C_STANDARD 99)
endif()
include(CheckLibraryExists)
check_library_exists(m floor "" HAVE_LIBM)
if(HAVE_LIBM)
list(APPEND OPUS_REQUIRED_LIBRARIES m)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
include(CFeatureCheck)
......@@ -35,9 +37,18 @@ else()
check_symbol_exists(alloca "stdlib.h;malloc.h" USE_ALLOCA_SUPPORTED)
endif()
include(CheckFunctionExists)
check_function_exists(lrintf HAVE_LRINTF)
check_function_exists(lrint HAVE_LRINT)
include(CMakePushCheckState)
cmake_push_check_state(RESET)
include(CheckLibraryExists)
check_library_exists(m floor "" HAVE_LIBM)
if(HAVE_LIBM)
list(APPEND OPUS_REQUIRED_LIBRARIES m)
set(CMAKE_REQUIRED_LIBRARIES m)
endif()
check_symbol_exists(lrintf "math.h" HAVE_LRINTF)
check_symbol_exists(lrint "math.h" HAVE_LRINT)
cmake_pop_check_state()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(i[0-9]86|x86|X86|amd64|AMD64|x86_64)")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment