summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau <tom@trondeau.com>2015-03-03 12:21:19 -0500
committerTom Rondeau <tom@trondeau.com>2015-04-02 15:38:57 -0700
commitd99c0b44b1883708edee13bfbaaecae7ebfd7be5 (patch)
tree27d704592e3b0bea699029561a98cc96edeea9e4
parent636c1557936ca004dce4c905eb7f337ad5677c60 (diff)
controlport: fixing up some issues; generate thrift sources into thrift subdir.
Fixed FindThrift cmake module to do a better job of handling version info.
-rw-r--r--cmake/Modules/FindThrift.cmake75
-rw-r--r--gnuradio-runtime/include/gnuradio/rpcpmtconverters_thrift.h2
-rw-r--r--gnuradio-runtime/include/gnuradio/rpcserver_booter_thrift.h2
-rw-r--r--gnuradio-runtime/include/gnuradio/rpcserver_thrift.h4
-rw-r--r--gnuradio-runtime/include/gnuradio/thrift_server_template.h2
-rw-r--r--gnuradio-runtime/lib/controlport/CMakeLists.txt10
-rw-r--r--gnuradio-runtime/lib/controlport/thrift/rpcpmtconverters_thrift.cc2
-rw-r--r--gnuradio-runtime/lib/controlport/thrift/rpcserver_thrift.cc2
8 files changed, 62 insertions, 37 deletions
diff --git a/cmake/Modules/FindThrift.cmake b/cmake/Modules/FindThrift.cmake
index 017e941eeb..170ea481de 100644
--- a/cmake/Modules/FindThrift.cmake
+++ b/cmake/Modules/FindThrift.cmake
@@ -1,41 +1,66 @@
INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(PC_THRIFT thrift>=0.9.2)
+PKG_CHECK_MODULES(PC_THRIFT thrift)
-FIND_PATH(THRIFT_INCLUDE_DIRS
- NAMES thrift/Thrift.h
- HINTS ${PC_THRIFT_INCLUDE_DIR}
- ${CMAKE_INSTALL_PREFIX}/include
- PATHS
- /usr/local/include
- /usr/include
-)
+set(THRIFT_REQ_VERSION "0.9.0")
-FIND_LIBRARY(THRIFT_LIBRARIES
- NAMES thrift
- HINTS ${PC_THRIFT_LIBDIR}
- ${CMAKE_INSTALL_PREFIX}/lib
- ${CMAKE_INSTALL_PREFIX}/lib64
- PATHS
- ${THRIFT_INCLUDE_DIRS}/../lib
- /usr/local/lib
- /usr/lib
-)
+# If pkg-config found Thrift and it doesn't meet our version
+# requirement, warn and exit -- does not cause an error; just doesn't
+# enable Thrift.
+if(PC_THRIFT_FOUND AND PC_THRIFT_VERSION VERSION_LESS ${THRIFT_REQ_VERSION})
+ message(STATUS "Could not find appropriate version of Thrift: ${PC_THRIFT_VERSION} < ${THRIFT_REQ_VERSION}")
+ return()
+endif(PC_THRIFT_FOUND AND PC_THRIFT_VERSION VERSION_LESS ${THRIFT_REQ_VERSION})
-if(THRIFT_INCLUDE_DIRS AND THRIFT_LIBRARIES)
- set(THRIFT_FOUND TRUE CACHE BOOL "If Thift has been found")
-endif(THRIFT_INCLUDE_DIRS AND THRIFT_LIBRARIES)
+# Else, look for it ourselves
+
+FIND_PATH(THRIFT_INCLUDE_DIRS
+ NAMES thrift/Thrift.h
+ HINTS ${PC_THRIFT_INCLUDE_DIR}
+ ${CMAKE_INSTALL_PREFIX}/include
+ PATHS
+ /usr/local/include
+ /usr/include
+ )
+
+FIND_LIBRARY(THRIFT_LIBRARIES
+ NAMES thrift
+ HINTS ${PC_THRIFT_LIBDIR}
+ ${CMAKE_INSTALL_PREFIX}/lib
+ ${CMAKE_INSTALL_PREFIX}/lib64
+ PATHS
+ ${THRIFT_INCLUDE_DIRS}/../lib
+ /usr/local/lib
+ /usr/lib
+ )
# Get the thrift binary to build our files during cmake
FIND_PROGRAM(THRIFT_BIN thrift)
+# Use binary to get version string and test against THRIFT_REQ_VERSION
+EXECUTE_PROCESS(
+ COMMAND ${THRIFT_BIN} --version
+ OUTPUT_VARIABLE THRIFT_VERSION
+ ERROR_VARIABLE THRIFT_VERSION_ERROR
+ )
+STRING(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+"
+ THRIFT_VERSION ${THRIFT_VERSION})
+
+if(THRIFT_VERSION VERSION_LESS THRIFT_REQ_VERSION)
+ message(STATUS "Could not find appropriate version of Thrift: ${THRIFT_VERSION} < ${THRIFT_REQ_VERSION}")
+ return()
+endif(THRIFT_VERSION VERSION_LESS THRIFT_REQ_VERSION)
+
+
# Check that Thrift for Python is available
include(GrPython)
GR_PYTHON_CHECK_MODULE("Thrift" thrift "1" PYTHON_THRIFT_FOUND)
-if(NOT PYTHON_THRIFT_FOUND)
- unset(THRIFT_FOUND)
-endif(NOT PYTHON_THRIFT_FOUND)
+# Set to found if we've made it this far
+if(THRIFT_INCLUDE_DIRS AND THRIFT_LIBRARIES AND PYTHON_THRIFT_FOUND)
+ set(THRIFT_FOUND TRUE CACHE BOOL "If Thift has been found")
+endif(THRIFT_INCLUDE_DIRS AND THRIFT_LIBRARIES AND PYTHON_THRIFT_FOUND)
+
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(THRIFT DEFAULT_MSG
diff --git a/gnuradio-runtime/include/gnuradio/rpcpmtconverters_thrift.h b/gnuradio-runtime/include/gnuradio/rpcpmtconverters_thrift.h
index eeb5b35c4e..6523165a11 100644
--- a/gnuradio-runtime/include/gnuradio/rpcpmtconverters_thrift.h
+++ b/gnuradio-runtime/include/gnuradio/rpcpmtconverters_thrift.h
@@ -25,7 +25,7 @@
#include <pmt/pmt.h>
#include <boost/noncopyable.hpp>
#include <boost/ptr_container/ptr_map.hpp>
-#include "gnuradio_types.h"
+#include "thrift/gnuradio_types.h"
namespace rpcpmtconverter
diff --git a/gnuradio-runtime/include/gnuradio/rpcserver_booter_thrift.h b/gnuradio-runtime/include/gnuradio/rpcserver_booter_thrift.h
index 836d4313aa..28900a4670 100644
--- a/gnuradio-runtime/include/gnuradio/rpcserver_booter_thrift.h
+++ b/gnuradio-runtime/include/gnuradio/rpcserver_booter_thrift.h
@@ -25,7 +25,7 @@
#include <gnuradio/rpcserver_booter_base.h>
#include <gnuradio/thrift_server_template.h>
-#include <ControlPort.h>
+#include "thrift/ControlPort.h"
class rpcserver_base;
class rpcserver_thrift;
diff --git a/gnuradio-runtime/include/gnuradio/rpcserver_thrift.h b/gnuradio-runtime/include/gnuradio/rpcserver_thrift.h
index c09b0a1f80..027a9ea75e 100644
--- a/gnuradio-runtime/include/gnuradio/rpcserver_thrift.h
+++ b/gnuradio-runtime/include/gnuradio/rpcserver_thrift.h
@@ -29,8 +29,8 @@
#include <iostream>
#include <sstream>
#include <map>
-#include "ControlPort.h"
-#include "gnuradio_types.h"
+#include "thrift/ControlPort.h"
+#include "thrift/gnuradio_types.h"
#include <boost/format.hpp>
#define S(x) #x
diff --git a/gnuradio-runtime/include/gnuradio/thrift_server_template.h b/gnuradio-runtime/include/gnuradio/thrift_server_template.h
index 5b97b0a0ce..5a81886343 100644
--- a/gnuradio-runtime/include/gnuradio/thrift_server_template.h
+++ b/gnuradio-runtime/include/gnuradio/thrift_server_template.h
@@ -35,7 +35,7 @@
#include <thrift/concurrency/PlatformThreadFactory.h>
#include <thrift/transport/TServerSocket.h>
#include <thrift/transport/TBufferTransports.h>
-#include <ControlPort.h>
+#include "thrift/ControlPort.h"
using namespace apache;
diff --git a/gnuradio-runtime/lib/controlport/CMakeLists.txt b/gnuradio-runtime/lib/controlport/CMakeLists.txt
index 30b0671cf3..4998aebec6 100644
--- a/gnuradio-runtime/lib/controlport/CMakeLists.txt
+++ b/gnuradio-runtime/lib/controlport/CMakeLists.txt
@@ -47,13 +47,13 @@ GR_APPEND_SUBCOMPONENT("thrift")
# Run Thrrift To compile C++ and Python files
message(STATUS "Running thrift to build C++ bindings")
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thrift/)
EXECUTE_PROCESS(
- COMMAND ${THRIFT_BIN} --gen cpp -out ${CMAKE_CURRENT_BINARY_DIR}/ ${CMAKE_CURRENT_SOURCE_DIR}/thrift/gnuradio.thrift
+ COMMAND ${THRIFT_BIN} --gen cpp -out ${CMAKE_CURRENT_BINARY_DIR}/thrift/ ${CMAKE_CURRENT_SOURCE_DIR}/thrift/gnuradio.thrift
OUTPUT_VARIABLE THRIFT_CPP_OUTPUT
ERROR_VARIABLE THRIFT_CPP_ERROR
)
-
list(APPEND gnuradio_ctrlport_sources
${CMAKE_CURRENT_SOURCE_DIR}/thrift/rpcserver_thrift.cc
${CMAKE_CURRENT_SOURCE_DIR}/thrift/rpcpmtconverters_thrift.cc
@@ -63,9 +63,9 @@ list(APPEND gnuradio_ctrlport_sources
# add files built by compiling gnuradio.thrift
list(APPEND gnuradio_ctrlport_sources
- ${CMAKE_CURRENT_BINARY_DIR}/gnuradio_types.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/gnuradio_constants.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/ControlPort.cpp
+ ${CMAKE_CURRENT_BINARY_DIR}/thrift/gnuradio_types.cpp
+ ${CMAKE_CURRENT_BINARY_DIR}/thrift/gnuradio_constants.cpp
+ ${CMAKE_CURRENT_BINARY_DIR}/thrift/ControlPort.cpp
)
# Add required libraries here
diff --git a/gnuradio-runtime/lib/controlport/thrift/rpcpmtconverters_thrift.cc b/gnuradio-runtime/lib/controlport/thrift/rpcpmtconverters_thrift.cc
index 79620322a5..19da05f787 100644
--- a/gnuradio-runtime/lib/controlport/thrift/rpcpmtconverters_thrift.cc
+++ b/gnuradio-runtime/lib/controlport/thrift/rpcpmtconverters_thrift.cc
@@ -21,8 +21,8 @@
#include <boost/assign/ptr_map_inserter.hpp>
#include <gnuradio/rpcpmtconverters_thrift.h>
-#include "gnuradio_types.h"
#include <gnuradio/gr_complex.h>
+#include "thrift/gnuradio_types.h"
#include <iostream>
GNURadio::Knob
diff --git a/gnuradio-runtime/lib/controlport/thrift/rpcserver_thrift.cc b/gnuradio-runtime/lib/controlport/thrift/rpcserver_thrift.cc
index bc878a8e1a..a4119f7080 100644
--- a/gnuradio-runtime/lib/controlport/thrift/rpcserver_thrift.cc
+++ b/gnuradio-runtime/lib/controlport/thrift/rpcserver_thrift.cc
@@ -29,7 +29,7 @@
#include <thrift/transport/TSocket.h>
#include <thrift/transport/TTransportUtils.h>
#include <boost/xpressive/xpressive.hpp>
-#include "ControlPort.h"
+#include "thrift/ControlPort.h"
#define DEBUG 0