CMake: #include <math.h> and link against -lm when checking if lrint is available
The check for lrint in cmake\OpusConfig.cmake doesn't do its job properly and ends up silently dumping the following error into cmake errors.txt. Libopusfile does this check correctly though. Determining if the function lrint exists failed with the following output: Change Dir: /mnt/c/py/miniaudio/_skbuild/linux-x86_64-3.8/cmake-build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/ninja cmTC_939d2 && [1/2] Building C object CMakeFiles/cmTC_939d2.dir/CheckFunctionExists.c.o
main': CheckFunctionExists.c:(.text+0x14): undefined reference to lrint'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
can you share repro?
C:\py\git>wsl keith@keith-pc:/mnt/c/py/git$ git clone https://github.com/xiph/opus Cloning into 'opus'... remote: Enumerating objects: 30861, done. remote: Counting objects: 100% (41/41), done. remote: Compressing objects: 100% (40/40), done. remote: Total 30861 (delta 19), reused 21 (delta 1), pack-reused 30820 Receiving objects: 100% (30861/30861), 9.67 MiB | 1.54 MiB/s, done. Resolving deltas: 100% (24407/24407), done. Updating files: 100% (414/414), done. keith@keith-pc:/mnt/c/py/git$ keith@keith-pc:/mnt/c/py/git$ cd opus keith@keith-pc:/mnt/c/py/git/opus$ mkdir build keith@keith-pc:/mnt/c/py/git/opus$ cd build keith@keith-pc:/mnt/c/py/git/opus/build$ cmake -G Ninja .. -- Found Git: /usr/bin/git (found version "2.25.1") -- Opus package version from git repo: 1.3.1-101-g66d060c7 -- Opus project version: 1.3.1 -- The C compiler identification is GNU 9.3.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Setting build type to 'Release' as none was specified and no CFLAGS was exported. -- Looking for floor in m -- Looking for floor in m - found -- Performing Test VLA_SUPPORTED -- Performing Test VLA_SUPPORTED -- success -- Looking for alloca.h -- Looking for alloca.h - found -- Looking for alloca -- Looking for alloca - found -- Looking for lrintf -- Looking for lrintf - not found -- Looking for lrint -- Looking for lrint - not found -- Looking for cpuid.h -- Looking for cpuid.h - found -- Check SIMD support by compiler -- Looking for xmmintrin.h -- Looking for xmmintrin.h - found -- Performing Test SSE1_SUPPORTED -- Performing Test SSE1_SUPPORTED - Success -- Looking for emmintrin.h -- Looking for emmintrin.h - found -- Performing Test SSE2_SUPPORTED -- Performing Test SSE2_SUPPORTED - Success -- Looking for smmintrin.h -- Looking for smmintrin.h - found -- Performing Test SSE4_1_SUPPORTED -- Performing Test SSE4_1_SUPPORTED - Success -- Looking for immintrin.h -- Looking for immintrin.h - found -- Performing Test AVX_SUPPORTED -- Performing Test AVX_SUPPORTED - Success -- Performing Test FAST_MATH_SUPPORTED -- Performing Test FAST_MATH_SUPPORTED - Success -- Performing Test STACK_PROTECTOR_SUPPORTED -- Performing Test STACK_PROTECTOR_SUPPORTED - Success -- Performing Test HIDDEN_VISIBILITY_SUPPORTED -- Performing Test HIDDEN_VISIBILITY_SUPPORTED - Success -- Performing Test Wall_SUPPORTED -- Performing Test Wall_SUPPORTED - Success -- Performing Test W_SUPPORTED -- Performing Test W_SUPPORTED - Success -- Performing Test Wstrictprototypes_SUPPORTED -- Performing Test Wstrictprototypes_SUPPORTED - Success -- Performing Test Wextra_SUPPORTED -- Performing Test Wextra_SUPPORTED - Success -- Performing Test Wcastalign_SUPPORTED -- Performing Test Wcastalign_SUPPORTED - Success -- Performing Test Wnestedexterns_SUPPORTED -- Performing Test Wnestedexterns_SUPPORTED - Success -- Performing Test Wshadow_SUPPORTED -- Performing Test Wshadow_SUPPORTED - Success -- The following features have been enabled:
- OPUS_ENABLE_FLOAT_API, compile with the floating point API (for machines with float library).
- OPUS_HARDENING, run-time checks that are cheap and safe for use in production.
- OPUS_INSTALL_PKG_CONFIG_MODULE, install pkg-config module.
- OPUS_INSTALL_CMAKE_CONFIG_MODULE, install CMake package config module.
- OPUS_VAR_ARRAYS, use variable length arrays for stack arrays.
- OPUS_STACK_PROTECTOR, use stack protection.
- OPUS_FORTIFY_SOURCE, add protection against buffer overflows.
- OPUS_X86_MAY_HAVE_SSE, does runtime check for SSE1 support.
- OPUS_X86_MAY_HAVE_SSE2, does runtime check for SSE2 support.
- OPUS_X86_MAY_HAVE_SSE4_1, does runtime check for SSE4.1 support.
- OPUS_X86_MAY_HAVE_AVX, does runtime check for AVX support.
- OPUS_X86_PRESUME_SSE, assume target CPU has SSE1 support (override runtime check).
- OPUS_X86_PRESUME_SSE2, assume target CPU has SSE2 support (override runtime check).
-- The following OPTIONAL packages have been found:
- Git
-- The following features have been disabled:
- OPUS_BUILD_SHARED_LIBRARY, build shared library.
- OPUS_BUILD_TESTING, build tests.
- OPUS_CUSTOM_MODES, enable non-Opus modes, e.g. 44.1 kHz & 2^n frames.
- OPUS_BUILD_PROGRAMS, build programs.
- OPUS_DISABLE_INTRINSICS, disable all intrinsics optimizations.
- OPUS_FIXED_POINT, compile as fixed-point (for machines without a fast enough FPU).
- OPUS_FLOAT_APPROX, enable floating point approximations (Ensure your platform supports IEEE 754 before enabling).
- OPUS_ASSERTIONS, additional software error checking.
- OPUS_FUZZING, causes the encoder to make random decisions (do not use in production).
- OPUS_CHECK_ASM, enable bit-exactness checks between optimized and c implementations.
- OPUS_FIXED_POINT_DEBUG, debug fixed-point implementation.
- OPUS_USE_ALLOCA, use alloca for stack arrays (on non-C99 compilers).
- OPUS_NONTHREADSAFE_PSEUDOSTACK, use a non threadsafe pseudostack when neither variable length arrays or alloca is supported.
- OPUS_FAST_MATH, enable fast math (unsupported and discouraged use, as code is not well tested with this build option).
- OPUS_X86_PRESUME_SSE4_1, assume target CPU has SSE4.1 support (override runtime check).
- OPUS_X86_PRESUME_AVX, assume target CPU has AVX support (override runtime check).
-- Configuring done -- Generating done -- Build files have been written to: /mnt/c/py/git/opus/build keith@keith-pc:/mnt/c/py/git/opus/build$
I pushed change for this, you can check if it works