summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Modules/FindThrift.cmake79
-rw-r--r--cmake/Modules/GrSwig.cmake41
-rw-r--r--cmake/Modules/GrTest.cmake3
3 files changed, 111 insertions, 12 deletions
diff --git a/cmake/Modules/FindThrift.cmake b/cmake/Modules/FindThrift.cmake
new file mode 100644
index 0000000000..f12bce01e6
--- /dev/null
+++ b/cmake/Modules/FindThrift.cmake
@@ -0,0 +1,79 @@
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(PC_THRIFT thrift)
+
+set(THRIFT_REQ_VERSION "0.9.2")
+
+# 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})
+
+
+# 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
+ )
+
+if(NOT THRIFT_BIN)
+ message(STATUS "Binary 'thrift' not found.")
+ return()
+endif(NOT THRIFT_BIN)
+
+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)
+
+# 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
+ THRIFT_LIBRARIES THRIFT_INCLUDE_DIRS
+ THRIFT_BIN PYTHON_THRIFT_FOUND THRIFT_FOUND
+)
+MARK_AS_ADVANCED(
+ THRIFT_LIBRARIES THRIFT_INCLUDE_DIRS
+ THRIFT_BIN PYTHON_THRIFT_FOUND THRIFT_FOUND
+)
diff --git a/cmake/Modules/GrSwig.cmake b/cmake/Modules/GrSwig.cmake
index abf4dc4612..ef3a76eb4c 100644
--- a/cmake/Modules/GrSwig.cmake
+++ b/cmake/Modules/GrSwig.cmake
@@ -105,17 +105,36 @@ endfunction(GR_SWIG_MAKE_DOCS)
macro(GR_SWIG_MAKE name)
set(ifiles ${ARGN})
- # Shimming this in here to take care of a SWIG bug with handling
- # vector<size_t> and vector<unsigned int> (on 32-bit machines) and
- # vector<long unsigned int> (on 64-bit machines). Use this to test
- # the size of size_t, then set SIZE_T_32 if it's a 32-bit machine
- # or not if it's 64-bit. The logic in gr_type.i handles the rest.
- INCLUDE(CheckTypeSize)
- CHECK_TYPE_SIZE("size_t" SIZEOF_SIZE_T)
- CHECK_TYPE_SIZE("unsigned int" SIZEOF_UINT)
- if(${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UINT})
- list(APPEND GR_SWIG_FLAGS -DSIZE_T_32)
- endif(${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UINT})
+ # Take care of a SWIG < 3.0 bug with handling std::vector<size_t>,
+ # by mapping to the correct sized type on the runtime system, one
+ # of "unsigned int", "unsigned long", or "unsigned long long".
+ # Compare the sizeof(size_t) with the sizeof the other types, and
+ # pick the first one in the list with the same sizeof. The logic
+ # in gnuradio-runtime/swig/gr_types.i handles the rest. It is
+ # probably not necessary to do this assignment all of the time,
+ # but it's easier to do it this way than to figure out the
+ # conditions when it is necessary -- and doing it this way won't
+ # hurt. This bug seems to have been fixed with SWIG >= 3.0, and
+ # mostly happens when not doing a native build (e.g., on Mac OS X
+ # when using a 64-bit CPU but building for 32-bit).
+
+ if(SWIG_VERSION VERSION_LESS "3.0.0")
+ include(CheckTypeSize)
+ check_type_size("size_t" SIZEOF_SIZE_T)
+ check_type_size("unsigned int" SIZEOF_UINT)
+ check_type_size("unsigned long" SIZEOF_UL)
+ check_type_size("unsigned long long" SIZEOF_ULL)
+
+ if(${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UINT})
+ list(APPEND GR_SWIG_FLAGS -DSIZE_T_UINT)
+ elseif(${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UL})
+ list(APPEND GR_SWIG_FLAGS -DSIZE_T_UL)
+ elseif(${SIZEOF_SIZE_T} EQUAL ${SIZEOF_ULL})
+ list(APPEND GR_SWIG_FLAGS -DSIZE_T_ULL)
+ else()
+ message(FATAL_ERROR "GrSwig: Unable to find replace for std::vector<size_t>; this should never happen!")
+ endif()
+ endif()
#do swig doc generation if specified
if(GR_SWIG_DOC_FILE)
diff --git a/cmake/Modules/GrTest.cmake b/cmake/Modules/GrTest.cmake
index 62caab4b51..ff78ed2726 100644
--- a/cmake/Modules/GrTest.cmake
+++ b/cmake/Modules/GrTest.cmake
@@ -66,7 +66,8 @@ function(GR_ADD_TEST test_name)
file(TO_NATIVE_PATH "${GR_TEST_LIBRARY_DIRS}" libpath) #ok to use on dir list?
file(TO_NATIVE_PATH "${GR_TEST_PYTHON_DIRS}" pypath) #ok to use on dir list?
- set(environs "VOLK_GENERIC=1" "GR_DONT_LOAD_PREFS=1" "srcdir=${srcdir}")
+ set(environs "VOLK_GENERIC=1" "GR_DONT_LOAD_PREFS=1" "srcdir=${srcdir}"
+ "GR_CONF_CONTROLPORT_ON=False")
list(APPEND environs ${GR_TEST_ENVIRONS})
#http://www.cmake.org/pipermail/cmake/2009-May/029464.html