[opus] Opus cmake build

Marcus Asteborg xnorpx at outlook.com
Mon Apr 15 17:23:40 UTC 2019


Hi Mark,

Thanks for more feedback,

I will create tasks in the OPUS github page for this to improve the CMake integration as I don't have bandwidth to fix all these things asap.

It is CMake best practices to only build either static or dynamic library. If the library consumer needs both then do a dual build.

Regarding testing only tests that was depending on the exported API in shared lib was built hence only 2 vs 4 for static lib.
The small unitttests was not added by choice but can ofc be added. Added task for this.

The reason for the difference between BUILD_TESTING and OPUS_BUILD_PROGRAMS is that BUILD_TESTING is a ctest variable while OPUS_ is our own defined.
I agree that the printout should be fixed to reflect the option prefix OPUS_ for all the OPUS_ specific options. Added task for this.

Added three separate tasks for the options.

I don't have a ARM based Linux device so I cannot test the warning issue, but I created a task for it for anyone with a Linux ARM device to pick up.

The platform I tested the CMake integration on was (for other flavors one need to use toolchain files):

  *
Windows:
     *
X86
     *
X64
     *
ARM
  *   Linux (Ubuntu):
     *   X64
  *   Mac OSX:
     *   X64
  *   Android:
     *   X86
  *   Android
     *   ARM

https://github.com/xiph/opus/issues/120
https://github.com/xiph/opus/issues/121​
https://github.com/xiph/opus/issues/122​
https://github.com/xiph/opus/issues/123​
https://github.com/xiph/opus/issues/124​
https://github.com/xiph/opus/issues/125​
https://github.com/xiph/opus/issues/126​
https://github.com/xiph/opus/issues/127

//Marcus

________________________________
From: Mark Harris <markh.sj at gmail.com> on behalf of Mark Harris <mark.hsj at gmail.com>
Sent: Saturday, April 13, 2019 22:12
To: Marcus Asteborg
Cc: Jean-Marc Valin; opus at xiph.org
Subject: Re: [opus] Opus cmake build

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:
> -DBUILD_PROGRAMS=ON

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:

      BUILD_PROGRAMS

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xiph.org/pipermail/opus/attachments/20190415/15f29f53/attachment.html>


More information about the opus mailing list