shithub: opus

Download patch

ref: c487f53ca59507d6d511aca4a3edc1d768633d19
parent: 93b373e884915e802188cec844a7dda2fa184ebc
author: Davide Beatrici <davidebeatrici@gmail.com>
date: Tue Oct 1 02:08:04 EDT 2019

CMake: add option to set BUILD_SHARED_LIBS variable

From https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html:

"Global flag to cause add_library() to create shared libraries if on.

If present and true, this will cause all libraries to be built shared unless the library was explicitly added as a static library. This variable is often added to projects as an option() so that each user of a project can decide if they want to build the project using shared or static libraries."

Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca>

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,6 +18,7 @@
 project(Opus LANGUAGES C VERSION ${PROJECT_VERSION})
 include(opus_buildtype.cmake)
 
+option(OPUS_BUILD_SHARED_LIBRARY "Build shared library" OFF)
 option(OPUS_STACK_PROTECTOR "Use stack protection" ON)
 option(OPUS_USE_ALLOCA "Use alloca for stack arrays (on non-C99 compilers)" OFF)
 option(OPUS_CUSTOM_MODES "Enable non-Opus modes, e.g. 44.1 kHz & 2^n frames"
@@ -37,6 +38,11 @@
 include(GNUInstallDirs)
 include(CMakeDependentOption)
 include(FeatureSummary)
+
+if(OPUS_BUILD_SHARED_LIBRARY)
+  # Global flag to cause add_library() to create shared libraries if on.
+  set(BUILD_SHARED_LIBS ON)
+endif()
 
 if(OPUS_STACK_PROTECTOR)
   if(NOT MSVC) # GC on by default on MSVC