Initial cmake config for freebeacon.
authorhobbes1069 <hobbes1069@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 17 Dec 2015 19:10:11 +0000 (19:10 +0000)
committerhobbes1069 <hobbes1069@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 17 Dec 2015 19:10:11 +0000 (19:10 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2550 01035d8c-6547-0410-b346-abe4f91aad63

freebeacon/CMakeLists.txt [new file with mode: 0644]
freebeacon/cmake/BuildCodec2.cmake [new file with mode: 0644]
freebeacon/cmake/BuildPortaudio.cmake [new file with mode: 0644]
freebeacon/cmake/BuildSamplerate.cmake [new file with mode: 0644]
freebeacon/cmake/BuildSndfile.cmake [new file with mode: 0644]
freebeacon/cmake/FindPortaudio.cmake [new file with mode: 0644]

diff --git a/freebeacon/CMakeLists.txt b/freebeacon/CMakeLists.txt
new file mode 100644 (file)
index 0000000..dbb6657
--- /dev/null
@@ -0,0 +1,257 @@
+#
+# Freebeacon
+#
+# CMake configuration contributed by Richard Shaw (KF5OIM)
+# Please report questions, comments, problems, or patches to the freetel
+# mailing list: https://lists.sourceforge.net/lists/listinfo/freetel-codec2
+#
+
+cmake_minimum_required(VERSION 2.8)
+
+# Prevent in-source builds to protect automake/autoconf config.
+# If an in-source build is attempted, you will still need to clean up a few
+# files manually.
+set(CMAKE_DISABLE_SOURCE_CHANGES ON)
+set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
+if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
+  message(FATAL_ERROR "In-source builds in ${CMAKE_BINARY_DIR} are not "   
+   "allowed, please remove ./CMakeCache.txt and ./CMakeFiles/, create a "
+   "separate build directory and run cmake from there.")
+endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
+
+# Set local module path.
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
+
+project(freebeacon C)
+
+#
+# Set version and generate version.h
+#
+set(FREEBEACON_VERSION_MAJOR 0)
+set(FREEBEACON_VERSION_MINOR 1)
+set(FREEBEACON_VERSION_PATCH FALSE)
+set(FREEBEACON_VERSION ${FREEBEACON_VERSION_MAJOR}.${FREEBEACON_VERSION_MINOR})
+if(FREEBEACON_VERSION_PATCH)
+    set(FREEBEACON_VERSION ${FREEBEACON_VERSION}.${FREEBEACON_VERSION_PATCH})
+endif()
+set(FREEBEACON_VERSION_SUFFIX "devel")
+if(FREEBEACON_VERSION_SUFFIX)
+    set(FREEBEACON_VERSION_STRING "${FREEBEACON_VERSION} ${FREEBEACON_VERSION_SUFFIX}")
+else()
+    set(FREEBEACON_VERSION_STRING "${FREEBEACON_VERSION}")
+endif()
+message(STATUS "freebeacon version: ${FREEBEACON_VERSION_STRING}")
+#configure_file(cmake/version.h.in version.h @ONLY)
+
+# Set default build type
+if(NOT CMAKE_BUILD_TYPE)
+    set(CMAKE_BUILD_TYPE "Release")
+    message(STATUS "Build type not specified, defaulting to ${CMAKE_BUILD_TYPE}")
+endif(NOT CMAKE_BUILD_TYPE)
+
+
+# Work around for not using a svn working copy.
+find_program(SVNVERSION_PATH svnversion)
+if(SVNVERSION_PATH)
+    execute_process(COMMAND ${SVNVERSION_PATH} .
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+        RESULT_VARIABLE SVN_REVISION_RESULT
+        OUTPUT_VARIABLE SVN_CURRENT_REVISION
+        ERROR_QUIET
+    )
+else()
+    set(SVN_REVISION_RESULT 1)
+endif()
+if(SVN_REVISION_RESULT EQUAL 0)
+string(STRIP ${SVN_CURRENT_REVISION} SVN_REVISION)
+add_definitions(-DSVN_REVISION="${SVN_REVISION}")
+else()
+add_definitions(-DSVN_REVISION="Unversioned directory")
+endif()
+
+
+# Set default build flags.
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fPIC -pie -Wl,-z,relro -Wl,-z,now")
+
+#
+# Setup cmake options
+#
+set(CMAKE_VERBOSE_MAKEFILE TRUE CACHE BOOL "Verbose makefile.")
+set(USE_STATIC_DEPS FALSE CACHE BOOL 
+    "Download and build static libraries instead of system libraries.")
+set(USE_STATIC_PORTAUDIO FALSE CACHE BOOL 
+    "Download and build static portaudio instead of the system library.")
+set(USE_STATIC_SNDFILE FALSE CACHE BOOL
+    "Download and build static sndfile instead of the system library.")
+set(USE_STATIC_SAMPLERATE FALSE CACHE BOOL
+    "Download and build static samplerate instead of the system library.")
+set(USE_STATIC_CODEC2 FALSE CACHE BOOL
+    "Download and build static codec2 instead of the system library.")
+#set(USE_STATIC_SPEEXDSP TRUE CACHE BOOL
+#    "Download and build static speex instead of the system library.")
+
+if(USE_STATIC_DEPS)
+    set(USE_STATIC_PORTAUDIO TRUE FORCE)
+    set(USE_STATIC_SNDFILE TRUE FORCE)
+    set(USE_STATIC_SAMPLERATE TRUE FORCE)
+    set(USE_STATIC_CODEC2 TRUE FORCE)
+endif(USE_STATIC_DEPS)
+
+#
+# Various hacks and work arounds for building under MinGW.
+#
+if(MINGW)
+    message(STATUS "System is MinGW.")
+    # Setup HOST variable.
+    include(cmake/MinGW.cmake)
+    # This sets up the exe icon for windows under mingw.
+    set(RES_FILES "")
+    set(RES_FILES "${CMAKE_SOURCE_DIR}/contrib/freedv.rc")
+    set(CMAKE_RC_COMPILER_INIT windres)
+    enable_language(RC)
+    set(CMAKE_RC_COMPILE_OBJECT
+        "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
+    include(InstallRequiredSystemLibraries)
+endif(MINGW)
+
+# Math library is automatic on MinGW
+if(UNIX)
+    set(CMAKE_REQUIRED_INCLUDES math.h)
+    set(CMAKE_REQUIRED_LIBRARIES m)
+endif(UNIX)
+
+# Find some standard headers and functions.
+include(CheckIncludeFiles)
+check_include_files("stdlib.h" HAVE_STDLIB_H)
+
+include(CheckTypeSize)
+check_type_size("int" SIZEOF_INT)
+
+# requires patching to find config.h as it current looks in the
+# source directory and the generated file goes in the binary directory.
+#configure_file ("${PROJECT_SOURCE_DIR}/cmake/config.h.in"
+#                "${PROJECT_BINARY_DIR}/config.h" )
+#include_directories(${PROJECT_BINARY_DIR})
+#add_definitions(-DHAVE_CONFIG_H)
+
+# Pthread Library
+find_package(Threads REQUIRED)
+message(STATUS "Threads library flags: ${CMAKE_THREAD_LIBS_INIT}")
+
+#
+# Find codec2
+#
+if(NOT USE_STATIC_CODEC2)
+    message(STATUS "Looking for codec2...")
+    # 'CONFIG' removed due to incompatibility with cmake version
+    # in Ubuntu 12.04 (Precise) -- Stuart Longland
+    find_package(codec2 QUIET)
+    if(codec2_FOUND)
+        get_target_property(CODEC2_LIBRARY codec2 LOCATION)
+        message(STATUS "  codec2 library: ${CODEC2_LIBRARY}")
+        message(STATUS "  codec2 headers: ${codec2_INCLUDE_DIRS}")
+    else()
+        # Try to find manually
+        find_path(CODEC2_INCLUDE_DIRS codec2.h
+                  PATH_SUFFIXES codec2)
+        find_library(CODEC2_LIBRARY NAMES codec2)
+        if(CODEC2_LIBRARY AND CODEC2_INCLUDE_DIRS)
+            message(STATUS "  codec2 library: ${CODEC2_LIBRARY}")
+            message(STATUS "  codec2 headers: ${CODEC2_INCLUDE_DIRS}")
+            list(APPEND FREEBEACON_LINK_LIBS ${CODEC2_LIBRARY})
+            include_directories(${CODEC2_INCLUDE_DIRS})
+        else()
+            message(FATAL_ERROR "codec2 library not found.
+Linux: 
+Codec2 may not be in your distribution so build yourself or use the cmake option to build statically into freebeacon.
+Windws:
+It's easiest to use the cmake option: USE_STATIC_CODEC2"
+        )
+        endif()
+    endif()
+else(NOT USE_STATIC_CODEC2)
+    message(STATUS "Will attempt static build of codec2.")
+    include(cmake/BuildCodec2.cmake)
+endif(NOT USE_STATIC_CODEC2)
+
+#
+# Find or build portaudio Library
+#
+if(NOT USE_STATIC_PORTAUDIO)
+    message(STATUS "Looking for portaudio...")
+    find_package(Portaudio REQUIRED)
+    if(PORTAUDIO_FOUND)
+        message(STATUS "  portaudio library: ${PORTAUDIO_LIBRARIES}")
+        message(STATUS "  portaudio headers: ${PORTAUDIO_INCLUDE_DIRS}")
+        list(APPEND FREEBEACON_LINK_LIBS ${PORTAUDIO_LIBRARIES})
+        include_directories(${PORTAUDIO_INCLUDE_DIRS})
+    else()
+        message(FATAL_ERROR "portaudio library not found.
+On Linux systems try installing:
+    portaudio-devel  (RPM based systems)
+    libportaudio-dev (DEB based systems)
+On Windows it's easiest to use the cmake option: USE_STATIC_PORTAUDIO"
+        )
+    endif()
+    if(NOT ${PORTAUDIO_VERSION} EQUAL 19)
+        message(WARNING "Portaudio versions other than 19 are known to have issues. You have been warned!")
+    endif()
+else(NOT USE_STATIC_PORTAUDIO)
+    message(STATUS "Will attempt static build of portaudio.")
+    include(cmake/BuildPortaudio.cmake)
+endif(NOT USE_STATIC_PORTAUDIO)
+
+#
+# Samplerate Library
+#
+if(NOT USE_STATIC_SAMPLERATE)
+    message(STATUS "Looking for samplerate...")
+    find_library(LIBSAMPLERATE samplerate)
+    find_path(LIBSAMPLERATE_INCLUDE_DIR samplerate.h)
+    message(STATUS "  samplerate library: ${LIBSAMPLERATE}")
+    message(STATUS "  samplerate headers: ${LIBSAMPLERATE_INCLUDE_DIR}")
+    if(LIBSAMPLERATE AND LIBSAMPLERATE_INCLUDE_DIR)
+        list(APPEND FREEBEACON_LINK_LIBS ${LIBSAMPLERATE})
+        include_directories(${LIBSAMPLERATE_INCLUDE_DIR})
+    else(LIBSTAMPLERATE AND LIBSAMPLERATE_INCLUDE_DIR)
+        message(FATAL_ERROR "samplerate library not found.
+On Linux systems try installing:
+    samplerate-devel  (RPM based systems)
+    libsamplerate-dev (DEB based systems)
+On Windows it's easiest to use the cmake option: USE_STATIC_SAMPLERATE"
+        )
+    endif(LIBSAMPLERATE AND LIBSAMPLERATE_INCLUDE_DIR)
+else(NOT USE_STATIC_SAMPLERATE)
+    message(STATUS "Will attempt static build of samplerate.")
+    include(cmake/BuildSamplerate.cmake)
+endif(NOT USE_STATIC_SAMPLERATE)
+
+#    
+# sndfile Library
+#
+if(NOT USE_STATIC_SNDFILE)
+    message(STATUS "Looking for sndfile...")
+    find_library(LIBSNDFILE sndfile)
+    find_path(LIBSNDFILE_INCLUDE_DIR sndfile.h)
+    message(STATUS "  sndfile library: ${LIBSNDFILE}")
+    message(STATUS "  sndfile headers: ${LIBSNDFILE_INCLUDE_DIR}")
+    if(LIBSNDFILE AND LIBSNDFILE_INCLUDE_DIR)
+        list(APPEND FREEBEACON_LINK_LIBS ${LIBSNDFILE})
+    else(LIBSNDFILE AND LIBSNDFILE_INCLUDE_DIR)
+        message(FATAL_ERROR "sndfile library not found.
+On Linux systems try installing:
+    libsndfile-devel (RPM based systems)
+    libsndfile-dev   (DEB based systems)
+On Windows it's easiest to use the cmake option: USE_STATIC_SNDFILE"
+        )
+    endif(LIBSNDFILE AND LIBSNDFILE_INCLUDE_DIR)
+else(NOT USE_STATIC_SNDFILE)
+    message(STATUS "Will attempt static build of sndfile.")
+    include(cmake/BuildSndfile.cmake)
+endif(NOT USE_STATIC_SNDFILE)
+
+add_executable(freebeacon freebeacon.c)
+target_link_libraries(freebeacon ${FREEBEACON_LINK_LIBS})
+if(FREEBEACON_STATIC_DEPS)
+    add_dependencies(freebeacon ${FREEBEACON_STATIC_DEPS})
+endif()
diff --git a/freebeacon/cmake/BuildCodec2.cmake b/freebeacon/cmake/BuildCodec2.cmake
new file mode 100644 (file)
index 0000000..588b316
--- /dev/null
@@ -0,0 +1,25 @@
+set(SPEEXDSP_CMAKE_ARGS -DBUILD_SHARED_LIBS=FALSE -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/external/dist)
+
+if(USE_STATIC_SPEEXDSP)
+    list(APPEND SPEEXDSP_CMAKE_ARGS 
+        -DSPEEXDSP_LIBRARIES=${CMAKE_BINARY_DIR}/external/dist/lib/libspeexdsp.a
+        -DSPEEXDSP_INCLUDE_DIR=${CMAKE_BINARY_DIR}/external/dist/include)
+endif()
+
+set(CODEC2_CMAKE_ARGS -DUNITTEST=FALSE)
+
+if(CMAKE_CROSSCOMPILING)
+    set(CODEC2_CMAKE_ARGS ${CODEC2_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE})
+endif()
+
+include(ExternalProject)
+ExternalProject_Add(codec2
+   SVN_REPOSITORY https://svn.code.sf.net/p/freetel/code/codec2-dev
+   CMAKE_ARGS ${CODEC2_CMAKE_ARGS} ${SPEEXDSP_CMAKE_ARGS}
+   INSTALL_COMMAND ""
+)
+set(CODEC2_LIBRARIES
+    ${CMAKE_BINARY_DIR}/codec2-prefix/src/codec2-build/src/libcodec2.a)
+include_directories(${CMAKE_BINARY_DIR}/codec2-prefix/src/codec2/src)
+list(APPEND FREEDV_LINK_LIBS ${CODEC2_LIBRARIES})
+list(APPEND FREEDV_STATIC_DEPS codec2)
diff --git a/freebeacon/cmake/BuildPortaudio.cmake b/freebeacon/cmake/BuildPortaudio.cmake
new file mode 100644 (file)
index 0000000..cc33d06
--- /dev/null
@@ -0,0 +1,52 @@
+set(PORTAUDIO_TARBALL "pa_stable_v19_20111121")
+
+# required linking libraries on linux. Not sure about windows.
+find_library(ALSA_LIBRARIES asound)
+
+if(UNIX AND NOT ALSA_LIBRARIES)
+    message(ERROR "Could not find alsa library which is required for portaudio.
+On Linux systems try installing:
+    alsa-lib-devel  (RPM based systems)
+    libasound2-dev  (DEB based systems)"
+    )
+endif()
+
+# Make sure that configure knows what system we're using when cross-compiling.
+if(MINGW AND CMAKE_CROSSCOMPILING)
+    include(cmake/MinGW.cmake)
+    set(CONFIGURE_COMMAND ./configure --build=${HOST} --host=${HOST} --target=${HOST} --enable-cxx --without-jack --disable-shared --prefix=${CMAKE_BINARY_DIR}/external/dist)
+else()
+    set(CONFIGURE_COMMAND ./configure --enable-cxx --without-jack --disable-shared --prefix=${CMAKE_BINARY_DIR}/external/dist)
+endif()
+
+include(ExternalProject)
+ExternalProject_Add(portaudio
+    URL http://www.portaudio.com/archives/${PORTAUDIO_TARBALL}.tgz
+    BUILD_IN_SOURCE 1
+    INSTALL_DIR external/dist
+    CONFIGURE_COMMAND ${CONFIGURE_COMMAND}
+    BUILD_COMMAND $(MAKE)
+    INSTALL_COMMAND $(MAKE) install
+)
+if(WIN32)
+    set(PORTAUDIO_LIBRARIES 
+        ${CMAKE_BINARY_DIR}/external/dist/lib/libportaudio.a
+        ${CMAKE_BINARY_DIR}/external/dist/lib/libportaudiocpp.a
+)
+else(WIN32)
+    find_library(RT rt)
+    find_library(ASOUND asound)
+    set(PORTAUDIO_LIBRARIES
+        ${CMAKE_BINARY_DIR}/external/dist/lib/libportaudio.a
+        ${CMAKE_BINARY_DIR}/external/dist/lib/libportaudiocpp.a
+        ${RT}
+        ${ASOUND}
+    )
+endif(WIN32)
+include_directories(${CMAKE_BINARY_DIR}/external/dist/include)
+
+# Add the portaudio library to the list of libraries that must be linked.
+list(APPEND FREEDV_LINK_LIBS ${PORTAUDIO_LIBRARIES})
+
+# Setup a dependency so that this gets built before linking to freedv.
+list(APPEND FREEDV_STATIC_DEPS portaudio)
diff --git a/freebeacon/cmake/BuildSamplerate.cmake b/freebeacon/cmake/BuildSamplerate.cmake
new file mode 100644 (file)
index 0000000..aa09f85
--- /dev/null
@@ -0,0 +1,27 @@
+set(SAMPLERATE_TARBALL "libsamplerate-0.1.8")
+
+if(MINGW AND CMAKE_CROSSCOMPILING)
+    set(CONFIGURE_COMMAND ./configure --build=${HOST} --host=${HOST} --target=${HOST} --prefix=${CMAKE_BINARY_DIR}/external/dist --disable-sndfile)
+else()
+    set(CONFIGURE_COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/external/dist)
+endif()
+
+include(ExternalProject)
+ExternalProject_Add(samplerate
+    URL http://www.mega-nerd.com/SRC/${SAMPLERATE_TARBALL}.tar.gz 
+    BUILD_IN_SOURCE 1
+    INSTALL_DIR external/dist
+    CONFIGURE_COMMAND ${CONFIGURE_COMMAND}
+    BUILD_COMMAND $(MAKE)
+    INSTALL_COMMAND $(MAKE) install
+)
+if(WIN32)
+    set(SAMPLERATE_LIBRARIES
+        ${CMAKE_BINARY_DIR}/external/dist/lib/libsamplerate.a)
+else(WIN32)
+    set(SAMPLERATE_LIBRARIES
+        ${CMAKE_BINARY_DIR}/external/dist/lib/libsamplerate.a)
+endif(WIN32)
+include_directories(${CMAKE_BINARY_DIR}/external/dist/include)
+list(APPEND FREEDV_LINK_LIBS ${SAMPLERATE_LIBRARIES})
+list(APPEND FREEDV_STATIC_DEPS samplerate)
diff --git a/freebeacon/cmake/BuildSndfile.cmake b/freebeacon/cmake/BuildSndfile.cmake
new file mode 100644 (file)
index 0000000..43233fb
--- /dev/null
@@ -0,0 +1,26 @@
+set(SNDFILE_TARBALL "libsndfile-1.0.25")
+
+if(MINGW AND CMAKE_CROSSCOMPILING)
+    set(CONFIGURE_COMMAND ./configure --host=${HOST}  --prefix=${CMAKE_BINARY_DIR}/external/dist --disable-external-libs --disable-shared)
+else()
+    set(CONFIGURE_COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/external/dist --disable-external-libs --disable-shared --disable-external-libs)
+endif()
+
+include(ExternalProject)
+ExternalProject_Add(sndfile
+    URL http://www.mega-nerd.com/libsndfile/files/${SNDFILE_TARBALL}.tar.gz
+    BUILD_IN_SOURCE 1
+    INSTALL_DIR external/dist
+    CONFIGURE_COMMAND ${CONFIGURE_COMMAND}
+    BUILD_COMMAND $(MAKE) V=1
+    INSTALL_COMMAND $(MAKE) install
+)
+if(MINGW)
+    set(SNDFILE_LIBRARIES ${CMAKE_BINARY_DIR}/external/dist/lib/libsndfile.a)
+else()
+    set(SNDFILE_LIBRARIES ${CMAKE_BINARY_DIR}/external/dist/lib/libsndfile.a)
+endif()
+
+include_directories(${CMAKE_BINARY_DIR}/external/dist/include)
+list(APPEND FREEDV_LINK_LIBS ${SNDFILE_LIBRARIES})
+list(APPEND FREEDV_STATIC_DEPS sndfile)
diff --git a/freebeacon/cmake/FindPortaudio.cmake b/freebeacon/cmake/FindPortaudio.cmake
new file mode 100644 (file)
index 0000000..158e20e
--- /dev/null
@@ -0,0 +1,107 @@
+# - Try to find Portaudio
+# Once done this will define
+#
+#  PORTAUDIO_FOUND - system has Portaudio
+#  PORTAUDIO_INCLUDE_DIRS - the Portaudio include directory
+#  PORTAUDIO_LIBRARIES - Link these to use Portaudio
+#  PORTAUDIO_DEFINITIONS - Compiler switches required for using Portaudio
+#  PORTAUDIO_VERSION - Portaudio version
+#
+#  Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
+#
+# Redistribution and use is allowed according to the terms of the New BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+#
+
+
+if (PORTAUDIO_LIBRARIES AND PORTAUDIO_INCLUDE_DIRS)
+  # in cache already
+  set(PORTAUDIO_FOUND TRUE)
+else (PORTAUDIO_LIBRARIES AND PORTAUDIO_INCLUDE_DIRS)
+  if (NOT WIN32)
+   include(FindPkgConfig)
+   pkg_check_modules(PORTAUDIO2 portaudio-2.0)
+  endif (NOT WIN32)
+
+  if (PORTAUDIO2_FOUND)
+    set(PORTAUDIO_INCLUDE_DIRS
+      ${PORTAUDIO2_INCLUDE_DIRS}
+    )
+    if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+      set(PORTAUDIO_LIBRARIES "${PORTAUDIO2_LIBRARY_DIRS}/lib${PORTAUDIO2_LIBRARIES}.dylib")
+    else (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+      set(PORTAUDIO_LIBRARIES
+        ${PORTAUDIO2_LIBRARIES}
+      )
+    endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+    set(PORTAUDIO_VERSION
+      19
+    )
+    set(PORTAUDIO_FOUND TRUE)
+  else (PORTAUDIO2_FOUND)
+    find_path(PORTAUDIO_INCLUDE_DIR
+      NAMES
+        portaudio.h
+      PATHS
+        /usr/include
+        /usr/local/include
+        /opt/local/include
+        /sw/include
+    )
+   
+    find_library(PORTAUDIO_LIBRARY
+      NAMES
+        portaudio
+      PATHS
+        /usr/lib
+        /usr/local/lib
+        /opt/local/lib
+        /sw/lib
+    )
+   
+    find_path(PORTAUDIO_LIBRARY_DIR
+      NAMES
+        portaudio
+      PATHS
+        /usr/lib
+        /usr/local/lib
+        /opt/local/lib
+        /sw/lib
+    )
+   
+    set(PORTAUDIO_INCLUDE_DIRS
+      ${PORTAUDIO_INCLUDE_DIR}
+    )
+    set(PORTAUDIO_LIBRARIES
+      ${PORTAUDIO_LIBRARY}
+    )
+   
+    set(PORTAUDIO_LIBRARY_DIRS
+      ${PORTAUDIO_LIBRARY_DIR}
+    )
+   
+    set(PORTAUDIO_VERSION
+      18
+    )
+   
+    if (PORTAUDIO_INCLUDE_DIRS AND PORTAUDIO_LIBRARIES)
+       set(PORTAUDIO_FOUND TRUE)
+    endif (PORTAUDIO_INCLUDE_DIRS AND PORTAUDIO_LIBRARIES)
+   
+    if (PORTAUDIO_FOUND)
+      if (NOT Portaudio_FIND_QUIETLY)
+        message(STATUS "Found Portaudio: ${PORTAUDIO_LIBRARIES}")
+      endif (NOT Portaudio_FIND_QUIETLY)
+    else (PORTAUDIO_FOUND)
+      if (Portaudio_FIND_REQUIRED)
+        message(FATAL_ERROR "Could not find Portaudio")
+      endif (Portaudio_FIND_REQUIRED)
+    endif (PORTAUDIO_FOUND)
+  endif (PORTAUDIO2_FOUND)
+
+
+  # show the PORTAUDIO_INCLUDE_DIRS and PORTAUDIO_LIBRARIES variables only in the advanced view
+  mark_as_advanced(PORTAUDIO_INCLUDE_DIRS PORTAUDIO_LIBRARIES)
+
+endif (PORTAUDIO_LIBRARIES AND PORTAUDIO_INCLUDE_DIRS)
+