[opus] Opus cmake build

Mark Harris mark.hsj at gmail.com
Sun Apr 14 05:12:51 UTC 2019

Hi Marcus,

Thanks for the fixes.  I did some more cmake build testing and
encountered a few issues:

The option -DFORTIFY_SOURCE=2 should be -D_FORTIFY_SOURCE=2, as the
macro has a leading underscore.  In the autotools build it defines this
if it is not already defined (m4/ax_add_fortify_source.m4).

When custom modes are not enabled, the cmake build is nevertheless
installing the include file opus_custom.h.  This file is specific to
custom modes and should only be installed if custom modes were enabled.

It appears that the documentation is not being built or installed by the
cmake build; the autotools build builds and installs the documentation
by default unless configured with --disable-doc.

The option -DBUILD_SHARED_LIBS=ON causes a shared library to be built,
however it then does not build a static library.  The autotools build
builds both by default, although --disable-shared or --disable-static
may be used to disable them.  Normally an installation would have both.
 How can both be built with cmake?  Is it it necessary to build twice?

When configured with -DBUILD_TESTING=ON, ctest runs only 2 tests if
-DBUILD_SHARED_LIBS=ON was also used, or 4 tests without that option.
How would someone run all 14 of the tests that are run using the
autotools "make check"?  I wouldn't expect fewer tests to be run when
shared libraries are built; the autotools build runs all tests
regardless of whether a shared library, static library, or both are built.

>  For programs use:

I tried the option -DBUILD_PROGRAMS=ON that you mentioned, but it still
said that BUILD_PROGRAMS was disabled:

  -- The following features have been disabled:

   * USE_ALLOCA, Use alloca for stack arrays (on non-C99 compilers)
   * CUSTOM_MODES, Enable non-Opus modes, e.g. 44.1 kHz & 2^n frames
   * BUILD_PROGRAMS, Build programs
   * FIXED_POINT, compile as fixed-point (for machines without a fast
enough FPU)
   * X86_PRESUME_SSE4_1, assume target CPU has SSE4_1 support
   * X86_PRESUME_AVX, assume target CPU has AVX support

  -- Configuring done
  -- Generating done
  CMake Warning:
    Manually-specified variables were not used by the project:


By looking through CMakeLists.txt I figured out that I need to specify
-DOPUS_BUILD_PROGRAMS=ON.  Is it possible to make BUILD_TESTING and
BUILD_PROGRAMS consistent?  Also the output of cmake is misleading, as
it says BUILD_PROGRAMS not OPUS_BUILD_PROGRAMS.  For some settings it is
even worse; for example it says FLOAT_API but the actual -D option that
needs to be used to change that setting is -DOPUS_ENABLE_FLOAT_API=OFF.
 Can these be made consistent as well?

There also seems to be several configure options (see ./configure
--help) that have no equivalent, including --enable-assertions,
--disable-asm, --disable-intrinsics, --with-NE10, and rare options like
--disable-rfc8251, --disable-hardening, --enable-fixed-point-debug,
--enable-float-approx, --enable-fuzzing, and --enable-check-asm.

I tried a cmake build on a non-x86 Linux host but encountered numerous
warnings of the form:
  celt/float_cast.h:129:10: warning: #warning "Don't have the functions
lrint() and lrintf ()." [-Wcpp]
  celt/float_cast.h:130:10: warning: #warning "Replacing these functions
with a standard C cast." [-Wcpp]

The host does have both the lrint and lrintf functions; the problem is
that cmake did not define either HAVE_LRINT or HAVE_LRINTF.

 - Mark

More information about the opus mailing list