From 2136cda19f8629fc7c3fda67805515dab0e41c90 Mon Sep 17 00:00:00 2001
From: "Peter A. Bigot" <pab@pabigot.com>
Date: Sat, 10 May 2014 06:50:30 -0500
Subject: cmake: fix FindPortaudio pkg-config support

Look for portaudio-2.0 which is the standard pkg-config name for the
portaudio API that gnuradio requires.  Correct the variable name in the
include directory hint derived from pkg-config information.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
---
 cmake/Modules/FindPortaudio.cmake | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'cmake/Modules')

diff --git a/cmake/Modules/FindPortaudio.cmake b/cmake/Modules/FindPortaudio.cmake
index 61e4ae23a1..e28858b0ed 100644
--- a/cmake/Modules/FindPortaudio.cmake
+++ b/cmake/Modules/FindPortaudio.cmake
@@ -6,7 +6,7 @@
 #  PORTAUDIO_LIBRARIES - Link these to use Portaudio
 
 include(FindPkgConfig)
-pkg_check_modules(PC_PORTAUDIO portaudio)
+pkg_check_modules(PC_PORTAUDIO portaudio-2.0)
 
 find_path(PORTAUDIO_INCLUDE_DIRS
   NAMES
@@ -15,7 +15,7 @@ find_path(PORTAUDIO_INCLUDE_DIRS
       /usr/local/include
       /usr/include
   HINTS
-    ${PC_PORTAUDIO_INCLUDE_DIR}
+    ${PC_PORTAUDIO_INCLUDEDIR}
 )
 
 find_library(PORTAUDIO_LIBRARIES
-- 
cgit v1.2.3


From 7f783624dc36b55ba3b217c13e1bdb09ebdf198b Mon Sep 17 00:00:00 2001
From: "Peter A. Bigot" <pab@pabigot.com>
Date: Sat, 10 May 2014 07:53:06 -0500
Subject: cmake: fix FindPortaudio to reject unsupported API version

portaudio18 passes the generic test for locating portaudio, but will
fail when building gr-audio.  Test for the failure before accepting the
portaudio that was found.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
---
 cmake/Modules/FindPortaudio.cmake | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

(limited to 'cmake/Modules')

diff --git a/cmake/Modules/FindPortaudio.cmake b/cmake/Modules/FindPortaudio.cmake
index e28858b0ed..20145ea8df 100644
--- a/cmake/Modules/FindPortaudio.cmake
+++ b/cmake/Modules/FindPortaudio.cmake
@@ -31,5 +31,22 @@ find_library(PORTAUDIO_LIBRARIES
 
 mark_as_advanced(PORTAUDIO_INCLUDE_DIRS PORTAUDIO_LIBRARIES)
 
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(PORTAUDIO DEFAULT_MSG PORTAUDIO_INCLUDE_DIRS PORTAUDIO_LIBRARIES)
+# Found PORTAUDIO, but it may be version 18 which is not acceptable.
+if(EXISTS ${PORTAUDIO_INCLUDE_DIRS}/portaudio.h)
+  include(CheckCXXSourceCompiles)
+  include(CMakePushCheckState)
+  cmake_push_check_state()
+  set(CMAKE_REQUIRED_INCLUDES ${PORTAUDIO_INCLUDE_DIRS})
+  CHECK_CXX_SOURCE_COMPILES(
+    "#include <portaudio.h>\nPaDeviceIndex pa_find_device_by_name(const char *name); int main () {return 0;}"
+    PORTAUDIO2_FOUND)
+  cmake_pop_check_state()
+  if(PORTAUDIO2_FOUND)
+    INCLUDE(FindPackageHandleStandardArgs)
+    FIND_PACKAGE_HANDLE_STANDARD_ARGS(PORTAUDIO DEFAULT_MSG PORTAUDIO_INCLUDE_DIRS PORTAUDIO_LIBRARIES)
+  else(PORTAUDIO2_FOUND)
+    message(STATUS
+      "  portaudio.h not compatible (requires API 2.0)")
+    set(PORTAUDIO_FOUND FALSE)
+  endif(PORTAUDIO2_FOUND)
+endif()
-- 
cgit v1.2.3