From 7746769c6838d9844fc167c2104aa7b18187ab67 Mon Sep 17 00:00:00 2001
From: "A. Maitland Bottoms" <bottoms@debian.org>
Date: Sat, 22 Feb 2020 18:22:20 -0500
Subject: [PATCH 1/3] restore fcd support

---
 CMakeLists.txt          |  3 ++-
 lib/CMakeLists.txt      | 12 +++++++++++-
 lib/fcd/CMakeLists.txt  | 22 ++++------------------
 lib/fcd/fcd_source_c.cc |  2 +-
 lib/fcd/fcd_source_c.h  | 11 ++++-------
 5 files changed, 22 insertions(+), 28 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7a2cf9d..b7e5a57 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2012 Free Software Foundation, Inc.
+# Copyright 2012,2020 Free Software Foundation, Inc.
 #
 # This file is part of gr-osmosdr
 #
@@ -178,6 +178,7 @@ find_package(LibAIRSPYHF)
 find_package(LibbladeRF)
 find_package(SoapySDR NO_MODULE)
 find_package(LibFreeSRP)
+find_package(gnuradio-fcdproplus NAMES gr-fcdproplus gnuradio-fcdproplus)
 find_package(Doxygen)
 
     # Python
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index d04cb1d..d6cc7cc 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011,2020 Free Software Foundation, Inc.
 #
 # This file is part of gr-osmosdr
 #
@@ -135,6 +135,16 @@ if(ENABLE_OSMOSDR)
     add_subdirectory(osmosdr)
 endif(ENABLE_OSMOSDR)
 
+########################################################################
+# Setup FCD component
+########################################################################
+GR_REGISTER_COMPONENT("FUNcube Dongle" ENABLE_FCD gnuradio-fcdproplus_FOUND)
+if(ENABLE_FCD)
+  add_definitions(-DHAVE_FCD=1)
+  add_definitions(-DHAVE_FCDPP=1)
+  add_subdirectory(fcd)
+endif(ENABLE_FCD)
+
 ########################################################################
 # Setup File component
 ########################################################################
diff --git a/lib/fcd/CMakeLists.txt b/lib/fcd/CMakeLists.txt
index 146191f..53fe5ae 100644
--- a/lib/fcd/CMakeLists.txt
+++ b/lib/fcd/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2012 Free Software Foundation, Inc.
+# Copyright 2012,2020 Free Software Foundation, Inc.
 #
 # This file is part of gr-osmosdr
 #
@@ -21,27 +21,13 @@
 # This file included, use CMake directory variables
 ########################################################################
 
+pkg_check_modules(FCDPP gnuradio-fcdproplus)
+
 target_include_directories(gnuradio-osmosdr PRIVATE
     ${CMAKE_CURRENT_SOURCE_DIR}
 )
 
-if(ENABLE_FCD)
-    target_include_directories(gnuradio-osmosdr PRIVATE
-        ${Gnuradio-fcd_INCLUDE_DIRS}
-    )
-    target_link_libraries(gnuradio-osmosdr PRIVATE
-        ${Gnuradio-fcd_LIBRARIES}
-    )
-endif(ENABLE_FCD)
-
-if(ENABLE_FCDPP)
-    target_include_directories(gnuradio-osmosdr PRIVATE
-        ${Gnuradio-fcdpp_INCLUDE_DIRS}
-    )
-    target_link_libraries(gnuradio-osmosdr PRIVATE
-        ${Gnuradio-fcdpp_LIBRARIES}
-    )
-endif(ENABLE_FCDPP)
+target_link_libraries(gnuradio-osmosdr ${FCDPP_LIBRARIES})
 
 list(APPEND gr_osmosdr_srcs
     ${CMAKE_CURRENT_SOURCE_DIR}/fcd_source_c.cc
diff --git a/lib/fcd/fcd_source_c.cc b/lib/fcd/fcd_source_c.cc
index 885d514..3c23b0b 100644
--- a/lib/fcd/fcd_source_c.cc
+++ b/lib/fcd/fcd_source_c.cc
@@ -145,7 +145,7 @@ fcd_source_c::fcd_source_c(const std::string &args) :
 #ifdef HAVE_FCD
   if ( FUNCUBE_V1 == _type )
   {
-    _src_v1 = gr::fcd::source_c::make( dev_name );
+    _src_v1 = gr::fcdproplus::fcd::make( dev_name );
     connect( _src_v1, 0, self(), 0 );
 
     set_gain( 20, "LNA" );
diff --git a/lib/fcd/fcd_source_c.h b/lib/fcd/fcd_source_c.h
index 70239f8..d7dd957 100644
--- a/lib/fcd/fcd_source_c.h
+++ b/lib/fcd/fcd_source_c.h
@@ -22,12 +22,11 @@
 
 #include <gnuradio/hier_block2.h>
 
-#ifdef HAVE_FCD
-#include <gnuradio/fcd/source_c.h>
-#endif
-
 #ifdef HAVE_FCDPP
+#include <fcdproplus/fcd.h>
 #include <fcdproplus/fcdproplus.h>
+#include <fcdproplus/fcd_control.h>
+#include <fcdproplus/fcdpp_control.h>
 #endif
 
 #include "source_iface.h"
@@ -86,10 +85,8 @@ public:
 
 private:
   dongle_type _type;
-#ifdef HAVE_FCD
-  gr::fcd::source_c::sptr _src_v1;
-#endif
 #ifdef HAVE_FCDPP
+  gr::fcdproplus::fcd::sptr _src_v1;
   gr::fcdproplus::fcdproplus::sptr _src_v2;
 #endif
   double _lna_gain, _mix_gain, _bb_gain, _freq;
-- 
2.20.1

