Blob Blame History Raw
From: Nathan Whitehorn <nwhitehorn@physics.ucla.edu>
Date: Thu, 4 Apr 2019 11:11:47 -0700
Subject: [PATCH] Add CMake infrastructure for Opus module.


diff --git a/CMakeLists.txt b/CMakeLists.txt
index b5c4aa92..d58d3ea1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,6 +34,7 @@ ADD_DEFINITIONS(-DSEMS_APP_NAME=\\\"sems\\\")
 
 MESSAGE(STATUS "Configuring ${CMAKE_PROJECT_NAME} v. ${SEMS_VERSION}")
 
+OPTION(SEMS_USE_OPUS          "Build with Opus" OFF)
 OPTION(SEMS_USE_SPANDSP       "Build with spandsp" OFF)
 OPTION(SEMS_USE_LIBSAMPLERATE "Build with libsamplerate" OFF)
 OPTION(SEMS_USE_ZRTP          "Build with ZRTP" OFF)
@@ -97,6 +98,14 @@ ELSE(SEMS_USE_SPANDSP)
 	MESSAGE(STATUS "Using spandsp: NO (default)")
 ENDIF(SEMS_USE_SPANDSP)
 
+# compile with Opus codec?
+IF(SEMS_USE_OPUS)
+	FIND_PACKAGE(Opus REQUIRED)
+	MESSAGE(STATUS "Using Opus: YES")
+ELSE(SEMS_USE_OPUS)
+	MESSAGE(STATUS "Using Opus: NO (default)")
+ENDIF(SEMS_USE_OPUS)
+
 # compile with sample rate conversion from secret rabbit code?
 # (see http://www.mega-nerd.com/SRC/)
 IF(SEMS_USE_LIBSAMPLERATE)
diff --git a/cmake/FindOpus.cmake b/cmake/FindOpus.cmake
new file mode 100644
index 00000000..6f9a6352
--- /dev/null
+++ b/cmake/FindOpus.cmake
@@ -0,0 +1,17 @@
+FIND_PATH(OPUS_INCLUDE_DIR opus/opus.h)
+FIND_LIBRARY(OPUS_LIBRARIES NAMES opus)
+
+IF(OPUS_INCLUDE_DIR AND OPUS_LIBRARIES)
+	SET(OPUS_FOUND TRUE)
+ENDIF(OPUS_INCLUDE_DIR AND OPUS_LIBRARIES)
+
+IF(OPUS_FOUND)
+	IF (NOT Opus_FIND_QUIETLY)
+		MESSAGE(STATUS "Found Opus includes:	${OPUS_INCLUDE_DIR}/opus/opus.h")
+		MESSAGE(STATUS "Found Opus library: ${OPUS_LIBRARIES}")
+	ENDIF (NOT Opus_FIND_QUIETLY)
+ELSE(OPUS_FOUND)
+	IF (Opus_FIND_REQUIRED)
+		MESSAGE(FATAL_ERROR "Could NOT find opus development files")
+	ENDIF (Opus_FIND_REQUIRED)
+ENDIF(OPUS_FOUND)
diff --git a/core/plug-in/CMakeLists.txt b/core/plug-in/CMakeLists.txt
index 0be6e536..bed8c024 100644
--- a/core/plug-in/CMakeLists.txt
+++ b/core/plug-in/CMakeLists.txt
@@ -14,7 +14,9 @@ IF(SEMS_USE_ILBC)
 ENDIF(SEMS_USE_ILBC)
 #ADD_SUBDIRECTORY (isac)
 ADD_SUBDIRECTORY (l16)
-#ADD_SUBDIRECTORY (opus)
+IF(SEMS_USE_OPUS)
+	ADD_SUBDIRECTORY (opus)
+ENDIF(SEMS_USE_OPUS)
 ADD_SUBDIRECTORY (session_timer)
 #ADD_SUBDIRECTORY (silk)
 IF(SPEEX_FOUND)
diff --git a/core/plug-in/opus/CMakeLists.txt b/core/plug-in/opus/CMakeLists.txt
new file mode 100644
index 00000000..0c6cfa32
--- /dev/null
+++ b/core/plug-in/opus/CMakeLists.txt
@@ -0,0 +1,9 @@
+set (opus_SRCS
+opus.c
+)
+
+#module_cflags  = -ansi # -DNOFPU
+
+SET(sems_module_name opus)
+SET(sems_module_libs opus)
+INCLUDE(${CMAKE_SOURCE_DIR}/cmake/module.rules.txt)