Update cmake files from gnuradio master gr_modtool output.
I ran gr_modtool to create a new module. Then replaces the top level CMakeLists file and tweaked the details. Also about the cmake Modules. The output compiles for x86 native and armv7a cross. Signed-off-by: Philip Balister <philip@balister.org>
This commit is contained in:
parent
da15a2daf2
commit
77f4245c35
@ -1,4 +1,4 @@
|
||||
# Copyright 2011,2013 Free Software Foundation, Inc.
|
||||
# Copyright 2011,2012,2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of GNU Radio
|
||||
#
|
||||
@ -17,7 +17,6 @@
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
|
||||
|
||||
########################################################################
|
||||
# Project setup
|
||||
########################################################################
|
||||
@ -34,7 +33,8 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||
endif(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
||||
#make sure our local CMake Modules path comes first
|
||||
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
||||
|
||||
########################################################################
|
||||
# Compiler specific setup
|
||||
@ -47,9 +47,23 @@ endif()
|
||||
########################################################################
|
||||
# Find boost
|
||||
########################################################################
|
||||
include(GrBoost)
|
||||
if(UNIX AND EXISTS "/usr/lib64")
|
||||
list(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix
|
||||
endif(UNIX AND EXISTS "/usr/lib64")
|
||||
set(Boost_ADDITIONAL_VERSIONS
|
||||
"1.35.0" "1.35" "1.36.0" "1.36" "1.37.0" "1.37" "1.38.0" "1.38" "1.39.0" "1.39"
|
||||
"1.40.0" "1.40" "1.41.0" "1.41" "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44"
|
||||
"1.45.0" "1.45" "1.46.0" "1.46" "1.47.0" "1.47" "1.48.0" "1.48" "1.49.0" "1.49"
|
||||
"1.50.0" "1.50" "1.51.0" "1.51" "1.52.0" "1.52" "1.53.0" "1.53" "1.54.0" "1.54"
|
||||
"1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59"
|
||||
"1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64"
|
||||
"1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69"
|
||||
)
|
||||
find_package(Boost "1.35" COMPONENTS filesystem system)
|
||||
|
||||
find_package(PythonLibs 2)
|
||||
if(NOT Boost_FOUND)
|
||||
message(FATAL_ERROR "Boost required to compile air-modes")
|
||||
endif()
|
||||
|
||||
########################################################################
|
||||
# Install directories
|
||||
@ -57,7 +71,7 @@ find_package(PythonLibs 2)
|
||||
include(GrPlatform) #define LIB_SUFFIX
|
||||
set(GR_RUNTIME_DIR bin)
|
||||
set(GR_LIBRARY_DIR lib${LIB_SUFFIX})
|
||||
set(GR_INCLUDE_DIR include)
|
||||
set(GR_INCLUDE_DIR include/gr_air_modes)
|
||||
set(GR_DATA_DIR share)
|
||||
set(GR_PKG_DATA_DIR ${GR_DATA_DIR}/${CMAKE_PROJECT_NAME})
|
||||
set(GR_DOC_DIR ${GR_DATA_DIR}/doc)
|
||||
@ -68,36 +82,68 @@ set(GR_LIBEXEC_DIR libexec)
|
||||
set(GR_PKG_LIBEXEC_DIR ${GR_LIBEXEC_DIR}/${CMAKE_PROJECT_NAME})
|
||||
set(GRC_BLOCKS_DIR ${GR_PKG_DATA_DIR}/grc/blocks)
|
||||
|
||||
########################################################################
|
||||
# On Apple only, set install name and use rpath correctly, if not already set
|
||||
########################################################################
|
||||
if(APPLE)
|
||||
if(NOT CMAKE_INSTALL_NAME_DIR)
|
||||
set(CMAKE_INSTALL_NAME_DIR
|
||||
${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR} CACHE
|
||||
PATH "Library Install Name Destination Directory" FORCE)
|
||||
endif(NOT CMAKE_INSTALL_NAME_DIR)
|
||||
if(NOT CMAKE_INSTALL_RPATH)
|
||||
set(CMAKE_INSTALL_RPATH
|
||||
${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR} CACHE
|
||||
PATH "Library Install RPath" FORCE)
|
||||
endif(NOT CMAKE_INSTALL_RPATH)
|
||||
if(NOT CMAKE_BUILD_WITH_INSTALL_RPATH)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE
|
||||
BOOL "Do Build Using Library Install RPath" FORCE)
|
||||
endif(NOT CMAKE_BUILD_WITH_INSTALL_RPATH)
|
||||
endif(APPLE)
|
||||
|
||||
########################################################################
|
||||
# Find gnuradio build dependencies
|
||||
########################################################################
|
||||
find_package(CppUnit)
|
||||
find_package(Doxygen)
|
||||
|
||||
# Search for GNU Radio and its components and versions. Add any
|
||||
# components required to the list of GR_REQUIRED_COMPONENTS (in all
|
||||
# caps such as FILTER or FFT) and change the version to the minimum
|
||||
# API compatible version required.
|
||||
set(GR_REQUIRED_COMPONENTS RUNTIME)
|
||||
find_package(Gnuradio "3.7.2" REQUIRED)
|
||||
|
||||
if(NOT GNURADIO_RUNTIME_FOUND)
|
||||
message(FATAL_ERROR "GnuRadio Runtime required to compile gr-air-modes")
|
||||
if(NOT CPPUNIT_FOUND)
|
||||
message(FATAL_ERROR "CppUnit required to compile airmodes")
|
||||
endif()
|
||||
|
||||
########################################################################
|
||||
# Find PyZMQ bindings
|
||||
# Setup doxygen option
|
||||
########################################################################
|
||||
include(GrPython)
|
||||
#GR_PYTHON_CHECK_MODULE("PyZMQ" "zmq" "int(zmq.__version__.split('.')[0]) >= 13" PYZMQ_FOUND)
|
||||
#if(NOT PYZMQ_FOUND)
|
||||
# message(FATAL_ERROR "Python ZMQ bindings not found.")
|
||||
#endif()
|
||||
if(DOXYGEN_FOUND)
|
||||
option(ENABLE_DOXYGEN "Build docs using Doxygen" ON)
|
||||
else(DOXYGEN_FOUND)
|
||||
option(ENABLE_DOXYGEN "Build docs using Doxygen" OFF)
|
||||
endif(DOXYGEN_FOUND)
|
||||
|
||||
########################################################################
|
||||
# Setup the include and linker paths
|
||||
########################################################################
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/lib
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_BINARY_DIR}/lib
|
||||
${CMAKE_BINARY_DIR}/include
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${GNURADIO_RUNTIME_INCLUDE_DIRS}
|
||||
${CPPUNIT_INCLUDE_DIRS}
|
||||
${GNURADIO_ALL_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
link_directories(
|
||||
${Boost_LIBRARY_DIRS}
|
||||
${CPPUNIT_LIBRARY_DIRS}
|
||||
${GNURADIO_RUNTIME_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
@ -128,3 +174,14 @@ add_subdirectory(grc)
|
||||
add_subdirectory(apps)
|
||||
add_subdirectory(docs)
|
||||
add_subdirectory(res)
|
||||
|
||||
########################################################################
|
||||
# Install cmake search helper for this library
|
||||
########################################################################
|
||||
if(NOT CMAKE_MODULES_DIR)
|
||||
set(CMAKE_MODULES_DIR lib${LIB_SUFFIX}/cmake)
|
||||
endif(NOT CMAKE_MODULES_DIR)
|
||||
|
||||
install(FILES cmake/Modules/gr_air_modesConfig.cmake
|
||||
DESTINATION ${CMAKE_MODULES_DIR}/gr_air_modes
|
||||
)
|
||||
|
39
cmake/Modules/FindCppUnit.cmake
Normal file
39
cmake/Modules/FindCppUnit.cmake
Normal file
@ -0,0 +1,39 @@
|
||||
# http://www.cmake.org/pipermail/cmake/2006-October/011446.html
|
||||
# Modified to use pkg config and use standard var names
|
||||
|
||||
#
|
||||
# Find the CppUnit includes and library
|
||||
#
|
||||
# This module defines
|
||||
# CPPUNIT_INCLUDE_DIR, where to find tiff.h, etc.
|
||||
# CPPUNIT_LIBRARIES, the libraries to link against to use CppUnit.
|
||||
# CPPUNIT_FOUND, If false, do not try to use CppUnit.
|
||||
|
||||
INCLUDE(FindPkgConfig)
|
||||
PKG_CHECK_MODULES(PC_CPPUNIT "cppunit")
|
||||
|
||||
FIND_PATH(CPPUNIT_INCLUDE_DIRS
|
||||
NAMES cppunit/TestCase.h
|
||||
HINTS ${PC_CPPUNIT_INCLUDE_DIR}
|
||||
${CMAKE_INSTALL_PREFIX}/include
|
||||
PATHS
|
||||
/usr/local/include
|
||||
/usr/include
|
||||
)
|
||||
|
||||
FIND_LIBRARY(CPPUNIT_LIBRARIES
|
||||
NAMES cppunit
|
||||
HINTS ${PC_CPPUNIT_LIBDIR}
|
||||
${CMAKE_INSTALL_PREFIX}/lib
|
||||
${CMAKE_INSTALL_PREFIX}/lib64
|
||||
PATHS
|
||||
${CPPUNIT_INCLUDE_DIRS}/../lib
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
)
|
||||
|
||||
LIST(APPEND CPPUNIT_LIBRARIES ${CMAKE_DL_LIBS})
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPPUNIT DEFAULT_MSG CPPUNIT_LIBRARIES CPPUNIT_INCLUDE_DIRS)
|
||||
MARK_AS_ADVANCED(CPPUNIT_LIBRARIES CPPUNIT_INCLUDE_DIRS)
|
@ -1,24 +0,0 @@
|
||||
# Copyright (c) 2007, Simon Edwards <simon@simonzone.com>
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
import PyQt4.pyqtconfig
|
||||
|
||||
pyqtcfg = PyQt4.pyqtconfig.Configuration()
|
||||
print("pyqt_version:%06.0x" % pyqtcfg.pyqt_version)
|
||||
print("pyqt_version_str:%s" % pyqtcfg.pyqt_version_str)
|
||||
|
||||
pyqt_version_tag = ""
|
||||
in_t = False
|
||||
for item in pyqtcfg.pyqt_sip_flags.split(' '):
|
||||
if item=="-t":
|
||||
in_t = True
|
||||
elif in_t:
|
||||
if item.startswith("Qt_4"):
|
||||
pyqt_version_tag = item
|
||||
else:
|
||||
in_t = False
|
||||
print("pyqt_version_tag:%s" % pyqt_version_tag)
|
||||
|
||||
print("pyqt_sip_dir:%s" % pyqtcfg.pyqt_sip_dir)
|
||||
print("pyqt_sip_flags:%s" % pyqtcfg.pyqt_sip_flags)
|
@ -1,61 +0,0 @@
|
||||
# Find PyQt4
|
||||
# ~~~~~~~~~~
|
||||
# Copyright (c) 2007-2008, Simon Edwards <simon@simonzone.com>
|
||||
# Copyright (c) 2012, Nicholas Corgan <nick.corgan@ettus.com>
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
#
|
||||
# PyQt4 website: http://www.riverbankcomputing.co.uk/pyqt/index.php
|
||||
#
|
||||
# Find the installed version of PyQt4. FindPyQt4 should only be called after
|
||||
# Python has been found.
|
||||
#
|
||||
# This file defines the following variables:
|
||||
#
|
||||
# PYQT4_VERSION - The version of PyQt4 found expressed as a 6 digit hex number
|
||||
# suitable for comparision as a string
|
||||
#
|
||||
# PYQT4_VERSION_STR - The version of PyQt4 as a human readable string.
|
||||
#
|
||||
# PYQT4_VERSION_TAG - The PyQt version tag using by PyQt's sip files.
|
||||
#
|
||||
# PYQT4_SIP_DIR - The directory holding the PyQt4 .sip files.
|
||||
#
|
||||
# PYQT4_SIP_FLAGS - The SIP flags used to build PyQt.
|
||||
|
||||
IF(EXISTS PYQT4_VERSION AND EXISTS PYUIC4_EXECUTABLE)
|
||||
# Already in cache, be silent
|
||||
SET(PYQT4_FOUND TRUE)
|
||||
SET(PYUIC4_FOUND TRUE)
|
||||
ELSE(EXISTS PYQT4_VERSION AND EXISTS PYUIC4_EXECUTABLE)
|
||||
|
||||
FIND_FILE(_find_pyqt_py FindPyQt.py PATHS ${CMAKE_MODULE_PATH})
|
||||
|
||||
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_pyqt_py} OUTPUT_VARIABLE pyqt_config)
|
||||
IF(pyqt_config)
|
||||
STRING(REGEX REPLACE "^pyqt_version:([^\n]+).*$" "\\1" PYQT4_VERSION ${pyqt_config})
|
||||
STRING(REGEX REPLACE ".*\npyqt_version_str:([^\n]+).*$" "\\1" PYQT4_VERSION_STR ${pyqt_config})
|
||||
STRING(REGEX REPLACE ".*\npyqt_version_tag:([^\n]+).*$" "\\1" PYQT4_VERSION_TAG ${pyqt_config})
|
||||
STRING(REGEX REPLACE ".*\npyqt_sip_dir:([^\n]+).*$" "\\1" PYQT4_SIP_DIR ${pyqt_config})
|
||||
STRING(REGEX REPLACE ".*\npyqt_sip_flags:([^\n]+).*$" "\\1" PYQT4_SIP_FLAGS ${pyqt_config})
|
||||
|
||||
SET(PYQT4_FOUND TRUE)
|
||||
ENDIF(pyqt_config)
|
||||
|
||||
FIND_PROGRAM(PYUIC4_EXECUTABLE NAMES pyuic4)
|
||||
IF(PYUIC4_EXECUTABLE)
|
||||
SET(PYUIC4_FOUND TRUE)
|
||||
ENDIF(PYUIC4_EXECUTABLE)
|
||||
|
||||
IF(PYQT4_FOUND AND PYUIC4_FOUND)
|
||||
IF(NOT PYQT4_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found PyQt4 version: ${PYQT4_VERSION_STR}")
|
||||
MESSAGE(STATUS "Found pyuic4: ${PYUIC4_EXECUTABLE}")
|
||||
ENDIF(NOT PYQT4_FIND_QUIETLY)
|
||||
ELSE(PYQT4_FOUND AND PYUIC4_FOUND)
|
||||
IF(PYQT4_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find Python")
|
||||
ENDIF(PYQT4_FIND_REQUIRED)
|
||||
ENDIF(PYQT4_FOUND AND PYUIC4_FOUND)
|
||||
|
||||
ENDIF(EXISTS PYQT4_VERSION AND EXISTS PYUIC4_EXECUTABLE)
|
@ -1,30 +0,0 @@
|
||||
# - try to find Qwt libraries and include files
|
||||
# QWT_INCLUDE_DIR where to find qwt_plot.h, etc.
|
||||
# QWT_LIBRARIES libraries to link against
|
||||
# QWT_FOUND If false, do not try to use Qwt
|
||||
|
||||
find_path (QWT_INCLUDE_DIRS
|
||||
NAMES qwt_plot.h
|
||||
PATHS
|
||||
/usr/local/include/qwt-qt4
|
||||
/usr/local/include/qwt
|
||||
/usr/include/qwt-qt4
|
||||
/usr/include/qwt
|
||||
/opt/local/include/qwt
|
||||
/sw/include/qwt
|
||||
)
|
||||
|
||||
find_library (QWT_LIBRARIES
|
||||
NAMES qwt-qt4 qwt
|
||||
PATHS
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
/opt/local/lib
|
||||
/sw/lib
|
||||
)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set QWT_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include ( FindPackageHandleStandardArgs )
|
||||
find_package_handle_standard_args( Qwt DEFAULT_MSG QWT_LIBRARIES QWT_INCLUDE_DIRS )
|
||||
MARK_AS_ADVANCED(QWT_LIBRARIES QWT_INCLUDE_DIRS)
|
@ -1,99 +0,0 @@
|
||||
# Copyright 2010-2011 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of GNU Radio
|
||||
#
|
||||
# GNU Radio is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# GNU Radio is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GNU Radio; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
|
||||
if(DEFINED __INCLUDED_GR_BOOST_CMAKE)
|
||||
return()
|
||||
endif()
|
||||
set(__INCLUDED_GR_BOOST_CMAKE TRUE)
|
||||
|
||||
########################################################################
|
||||
# Setup Boost and handle some system specific things
|
||||
########################################################################
|
||||
|
||||
set(BOOST_REQUIRED_COMPONENTS
|
||||
date_time
|
||||
program_options
|
||||
filesystem
|
||||
system
|
||||
thread
|
||||
)
|
||||
|
||||
if(UNIX AND NOT BOOST_ROOT AND EXISTS "/usr/lib64")
|
||||
list(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix
|
||||
endif(UNIX AND NOT BOOST_ROOT AND EXISTS "/usr/lib64")
|
||||
|
||||
if(MSVC)
|
||||
set(BOOST_REQUIRED_COMPONENTS ${BOOST_REQUIRED_COMPONENTS} chrono)
|
||||
|
||||
if (NOT DEFINED BOOST_ALL_DYN_LINK)
|
||||
set(BOOST_ALL_DYN_LINK TRUE)
|
||||
endif()
|
||||
set(BOOST_ALL_DYN_LINK "${BOOST_ALL_DYN_LINK}" CACHE BOOL "boost enable dynamic linking")
|
||||
if(BOOST_ALL_DYN_LINK)
|
||||
add_definitions(-DBOOST_ALL_DYN_LINK) #setup boost auto-linking in msvc
|
||||
else(BOOST_ALL_DYN_LINK)
|
||||
unset(BOOST_REQUIRED_COMPONENTS) #empty components list for static link
|
||||
endif(BOOST_ALL_DYN_LINK)
|
||||
endif(MSVC)
|
||||
|
||||
find_package(Boost "1.35" COMPONENTS ${BOOST_REQUIRED_COMPONENTS})
|
||||
|
||||
# This does not allow us to disable specific versions. It is used
|
||||
# internally by cmake to know the formation newer versions. As newer
|
||||
# Boost version beyond what is shown here are produced, we must extend
|
||||
# this list. To disable Boost versions, see below.
|
||||
set(Boost_ADDITIONAL_VERSIONS
|
||||
"1.35.0" "1.35" "1.36.0" "1.36" "1.37.0" "1.37" "1.38.0" "1.38" "1.39.0" "1.39"
|
||||
"1.40.0" "1.40" "1.41.0" "1.41" "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44"
|
||||
"1.45.0" "1.45" "1.46.0" "1.46" "1.47.0" "1.47" "1.48.0" "1.48" "1.49.0" "1.49"
|
||||
"1.50.0" "1.50" "1.51.0" "1.51" "1.52.0" "1.52" "1.53.0" "1.53" "1.54.0" "1.54"
|
||||
"1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59"
|
||||
"1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64"
|
||||
"1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69"
|
||||
)
|
||||
|
||||
# Boost 1.52 disabled, see https://svn.boost.org/trac/boost/ticket/7669
|
||||
# Similar problems with Boost 1.46 and 1.47.
|
||||
|
||||
OPTION(ENABLE_BAD_BOOST "Enable known bad versions of Boost" OFF)
|
||||
if(ENABLE_BAD_BOOST)
|
||||
MESSAGE(STATUS "Enabling use of known bad versions of Boost.")
|
||||
endif(ENABLE_BAD_BOOST)
|
||||
|
||||
# For any unsuitable Boost version, add the version number below in
|
||||
# the following format: XXYYZZ
|
||||
# Where:
|
||||
# XX is the major version ('10' for version 1)
|
||||
# YY is the minor version number ('46' for 1.46)
|
||||
# ZZ is the patcher version number (typically just '00')
|
||||
set(Boost_NOGO_VERSIONS
|
||||
104600 104601 104700 105200
|
||||
)
|
||||
|
||||
foreach(ver ${Boost_NOGO_VERSIONS})
|
||||
if(${Boost_VERSION} EQUAL ${ver})
|
||||
if(NOT ENABLE_BAD_BOOST)
|
||||
MESSAGE(STATUS "WARNING: Found a known bad version of Boost (v${Boost_VERSION}). Disabling.")
|
||||
set(Boost_FOUND FALSE)
|
||||
else(NOT ENABLE_BAD_BOOST)
|
||||
MESSAGE(STATUS "WARNING: Found a known bad version of Boost (v${Boost_VERSION}). Continuing anyway.")
|
||||
set(Boost_FOUND TRUE)
|
||||
endif(NOT ENABLE_BAD_BOOST)
|
||||
endif(${Boost_VERSION} EQUAL ${ver})
|
||||
endforeach(ver)
|
@ -1,4 +1,4 @@
|
||||
# Copyright 2010-2011 Free Software Foundation, Inc.
|
||||
# Copyright 2010-2011,2014 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of GNU Radio
|
||||
#
|
||||
@ -94,7 +94,13 @@ macro(GR_ADD_CXX_COMPILER_FLAG_IF_AVAILABLE flag have)
|
||||
include(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG(${flag} ${have})
|
||||
if(${have})
|
||||
add_definitions(${flag})
|
||||
if(${CMAKE_VERSION} VERSION_GREATER "2.8.4")
|
||||
STRING(FIND "${CMAKE_CXX_FLAGS}" "${flag}" flag_dup)
|
||||
if(${flag_dup} EQUAL -1)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
|
||||
endif(${flag_dup} EQUAL -1)
|
||||
endif(${CMAKE_VERSION} VERSION_GREATER "2.8.4")
|
||||
endif(${have})
|
||||
endmacro(GR_ADD_CXX_COMPILER_FLAG_IF_AVAILABLE)
|
||||
|
||||
@ -208,3 +214,312 @@ function(GR_GEN_TARGET_DEPS name var)
|
||||
set(${var} "DEPENDS;${name};COMMAND;${name}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction(GR_GEN_TARGET_DEPS)
|
||||
|
||||
########################################################################
|
||||
# Control use of gr_logger
|
||||
# Usage:
|
||||
# GR_LOGGING()
|
||||
#
|
||||
# Will set ENABLE_GR_LOG to 1 by default.
|
||||
# Can manually set with -DENABLE_GR_LOG=0|1
|
||||
########################################################################
|
||||
function(GR_LOGGING)
|
||||
find_package(Log4cpp)
|
||||
|
||||
OPTION(ENABLE_GR_LOG "Use gr_logger" ON)
|
||||
if(ENABLE_GR_LOG)
|
||||
# If gr_logger is enabled, make it usable
|
||||
add_definitions( -DENABLE_GR_LOG )
|
||||
|
||||
# also test LOG4CPP; if we have it, use this version of the logger
|
||||
# otherwise, default to the stdout/stderr model.
|
||||
if(LOG4CPP_FOUND)
|
||||
SET(HAVE_LOG4CPP True CACHE INTERNAL "" FORCE)
|
||||
add_definitions( -DHAVE_LOG4CPP )
|
||||
else(not LOG4CPP_FOUND)
|
||||
SET(HAVE_LOG4CPP False CACHE INTERNAL "" FORCE)
|
||||
SET(LOG4CPP_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE)
|
||||
SET(LOG4CPP_LIBRARY_DIRS "" CACHE INTERNAL "" FORCE)
|
||||
SET(LOG4CPP_LIBRARIES "" CACHE INTERNAL "" FORCE)
|
||||
endif(LOG4CPP_FOUND)
|
||||
|
||||
SET(ENABLE_GR_LOG ${ENABLE_GR_LOG} CACHE INTERNAL "" FORCE)
|
||||
|
||||
else(ENABLE_GR_LOG)
|
||||
SET(HAVE_LOG4CPP False CACHE INTERNAL "" FORCE)
|
||||
SET(LOG4CPP_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE)
|
||||
SET(LOG4CPP_LIBRARY_DIRS "" CACHE INTERNAL "" FORCE)
|
||||
SET(LOG4CPP_LIBRARIES "" CACHE INTERNAL "" FORCE)
|
||||
endif(ENABLE_GR_LOG)
|
||||
|
||||
message(STATUS "ENABLE_GR_LOG set to ${ENABLE_GR_LOG}.")
|
||||
message(STATUS "HAVE_LOG4CPP set to ${HAVE_LOG4CPP}.")
|
||||
message(STATUS "LOG4CPP_LIBRARIES set to ${LOG4CPP_LIBRARIES}.")
|
||||
|
||||
endfunction(GR_LOGGING)
|
||||
|
||||
########################################################################
|
||||
# Run GRCC to compile .grc files into .py files.
|
||||
#
|
||||
# Usage: GRCC(filename, directory)
|
||||
# - filenames: List of file name of .grc file
|
||||
# - directory: directory of built .py file - usually in
|
||||
# ${CMAKE_CURRENT_BINARY_DIR}
|
||||
# - Sets PYFILES: output converted GRC file names to Python files.
|
||||
########################################################################
|
||||
function(GRCC)
|
||||
# Extract directory from list of args, remove it for the list of filenames.
|
||||
list(GET ARGV -1 directory)
|
||||
list(REMOVE_AT ARGV -1)
|
||||
set(filenames ${ARGV})
|
||||
file(MAKE_DIRECTORY ${directory})
|
||||
|
||||
SET(GRCC_COMMAND ${CMAKE_SOURCE_DIR}/gr-utils/python/grcc)
|
||||
|
||||
# GRCC uses some stuff in grc and gnuradio-runtime, so we force
|
||||
# the known paths here
|
||||
list(APPEND PYTHONPATHS
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/gnuradio-runtime/python
|
||||
${CMAKE_SOURCE_DIR}/gnuradio-runtime/lib/swig
|
||||
${CMAKE_BINARY_DIR}/gnuradio-runtime/lib/swig
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
#SWIG generates the python library files into a subdirectory.
|
||||
#Therefore, we must append this subdirectory into PYTHONPATH.
|
||||
#Only do this for the python directories matching the following:
|
||||
foreach(pydir ${PYTHONPATHS})
|
||||
get_filename_component(name ${pydir} NAME)
|
||||
if(name MATCHES "^(swig|lib|src)$")
|
||||
list(APPEND PYTHONPATHS ${pydir}/${CMAKE_BUILD_TYPE})
|
||||
endif()
|
||||
endforeach(pydir)
|
||||
endif(WIN32)
|
||||
|
||||
file(TO_NATIVE_PATH "${PYTHONPATHS}" pypath)
|
||||
|
||||
if(UNIX)
|
||||
list(APPEND pypath "$PYTHONPATH")
|
||||
string(REPLACE ";" ":" pypath "${pypath}")
|
||||
set(ENV{PYTHONPATH} ${pypath})
|
||||
endif(UNIX)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND pypath "%PYTHONPATH%")
|
||||
string(REPLACE ";" "\\;" pypath "${pypath}")
|
||||
#list(APPEND environs "PYTHONPATH=${pypath}")
|
||||
set(ENV{PYTHONPATH} ${pypath})
|
||||
endif(WIN32)
|
||||
|
||||
foreach(f ${filenames})
|
||||
execute_process(
|
||||
COMMAND ${GRCC_COMMAND} -d ${directory} ${f}
|
||||
)
|
||||
string(REPLACE ".grc" ".py" pyfile "${f}")
|
||||
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" pyfile "${pyfile}")
|
||||
list(APPEND pyfiles ${pyfile})
|
||||
endforeach(f)
|
||||
|
||||
set(PYFILES ${pyfiles} PARENT_SCOPE)
|
||||
endfunction(GRCC)
|
||||
|
||||
########################################################################
|
||||
# Check if HAVE_PTHREAD_SETSCHEDPARAM and HAVE_SCHED_SETSCHEDULER
|
||||
# should be defined
|
||||
########################################################################
|
||||
macro(GR_CHECK_LINUX_SCHED_AVAIL)
|
||||
set(CMAKE_REQUIRED_LIBRARIES -lpthread)
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
#include <pthread.h>
|
||||
int main(){
|
||||
pthread_t pthread;
|
||||
pthread_setschedparam(pthread, 0, 0);
|
||||
return 0;
|
||||
} " HAVE_PTHREAD_SETSCHEDPARAM
|
||||
)
|
||||
GR_ADD_COND_DEF(HAVE_PTHREAD_SETSCHEDPARAM)
|
||||
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
#include <sched.h>
|
||||
int main(){
|
||||
pid_t pid;
|
||||
sched_setscheduler(pid, 0, 0);
|
||||
return 0;
|
||||
} " HAVE_SCHED_SETSCHEDULER
|
||||
)
|
||||
GR_ADD_COND_DEF(HAVE_SCHED_SETSCHEDULER)
|
||||
endmacro(GR_CHECK_LINUX_SCHED_AVAIL)
|
||||
|
||||
########################################################################
|
||||
# Macros to generate source and header files from template
|
||||
########################################################################
|
||||
macro(GR_EXPAND_X_H component root)
|
||||
|
||||
include(GrPython)
|
||||
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
|
||||
"#!${PYTHON_EXECUTABLE}
|
||||
|
||||
import sys, os, re
|
||||
sys.path.append('${GR_RUNTIME_PYTHONPATH}')
|
||||
os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}'
|
||||
os.chdir('${CMAKE_CURRENT_BINARY_DIR}')
|
||||
|
||||
if __name__ == '__main__':
|
||||
import build_utils
|
||||
root, inp = sys.argv[1:3]
|
||||
for sig in sys.argv[3:]:
|
||||
name = re.sub ('X+', sig, root)
|
||||
d = build_utils.standard_dict2(name, sig, '${component}')
|
||||
build_utils.expand_template(d, inp)
|
||||
")
|
||||
|
||||
#make a list of all the generated headers
|
||||
unset(expanded_files_h)
|
||||
foreach(sig ${ARGN})
|
||||
string(REGEX REPLACE "X+" ${sig} name ${root})
|
||||
list(APPEND expanded_files_h ${CMAKE_CURRENT_BINARY_DIR}/${name}.h)
|
||||
endforeach(sig)
|
||||
unset(name)
|
||||
|
||||
#create a command to generate the headers
|
||||
add_custom_command(
|
||||
OUTPUT ${expanded_files_h}
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.h.t
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
|
||||
${root} ${root}.h.t ${ARGN}
|
||||
)
|
||||
|
||||
#install rules for the generated headers
|
||||
list(APPEND generated_includes ${expanded_files_h})
|
||||
|
||||
endmacro(GR_EXPAND_X_H)
|
||||
|
||||
macro(GR_EXPAND_X_CC_H component root)
|
||||
|
||||
include(GrPython)
|
||||
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
|
||||
"#!${PYTHON_EXECUTABLE}
|
||||
|
||||
import sys, os, re
|
||||
sys.path.append('${GR_RUNTIME_PYTHONPATH}')
|
||||
os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}'
|
||||
os.chdir('${CMAKE_CURRENT_BINARY_DIR}')
|
||||
|
||||
if __name__ == '__main__':
|
||||
import build_utils
|
||||
root, inp = sys.argv[1:3]
|
||||
for sig in sys.argv[3:]:
|
||||
name = re.sub ('X+', sig, root)
|
||||
d = build_utils.standard_impl_dict2(name, sig, '${component}')
|
||||
build_utils.expand_template(d, inp)
|
||||
")
|
||||
|
||||
#make a list of all the generated files
|
||||
unset(expanded_files_cc)
|
||||
unset(expanded_files_h)
|
||||
foreach(sig ${ARGN})
|
||||
string(REGEX REPLACE "X+" ${sig} name ${root})
|
||||
list(APPEND expanded_files_cc ${CMAKE_CURRENT_BINARY_DIR}/${name}.cc)
|
||||
list(APPEND expanded_files_h ${CMAKE_CURRENT_BINARY_DIR}/${name}.h)
|
||||
endforeach(sig)
|
||||
unset(name)
|
||||
|
||||
#create a command to generate the source files
|
||||
add_custom_command(
|
||||
OUTPUT ${expanded_files_cc}
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.cc.t
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
|
||||
${root} ${root}.cc.t ${ARGN}
|
||||
)
|
||||
|
||||
#create a command to generate the header files
|
||||
add_custom_command(
|
||||
OUTPUT ${expanded_files_h}
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.h.t
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
|
||||
${root} ${root}.h.t ${ARGN}
|
||||
)
|
||||
|
||||
#make source files depends on headers to force generation
|
||||
set_source_files_properties(${expanded_files_cc}
|
||||
PROPERTIES OBJECT_DEPENDS "${expanded_files_h}"
|
||||
)
|
||||
|
||||
#install rules for the generated files
|
||||
list(APPEND generated_sources ${expanded_files_cc})
|
||||
list(APPEND generated_headers ${expanded_files_h})
|
||||
|
||||
endmacro(GR_EXPAND_X_CC_H)
|
||||
|
||||
macro(GR_EXPAND_X_CC_H_IMPL component root)
|
||||
|
||||
include(GrPython)
|
||||
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
|
||||
"#!${PYTHON_EXECUTABLE}
|
||||
|
||||
import sys, os, re
|
||||
sys.path.append('${GR_RUNTIME_PYTHONPATH}')
|
||||
os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}'
|
||||
os.chdir('${CMAKE_CURRENT_BINARY_DIR}')
|
||||
|
||||
if __name__ == '__main__':
|
||||
import build_utils
|
||||
root, inp = sys.argv[1:3]
|
||||
for sig in sys.argv[3:]:
|
||||
name = re.sub ('X+', sig, root)
|
||||
d = build_utils.standard_dict(name, sig, '${component}')
|
||||
build_utils.expand_template(d, inp, '_impl')
|
||||
")
|
||||
|
||||
#make a list of all the generated files
|
||||
unset(expanded_files_cc_impl)
|
||||
unset(expanded_files_h_impl)
|
||||
unset(expanded_files_h)
|
||||
foreach(sig ${ARGN})
|
||||
string(REGEX REPLACE "X+" ${sig} name ${root})
|
||||
list(APPEND expanded_files_cc_impl ${CMAKE_CURRENT_BINARY_DIR}/${name}_impl.cc)
|
||||
list(APPEND expanded_files_h_impl ${CMAKE_CURRENT_BINARY_DIR}/${name}_impl.h)
|
||||
list(APPEND expanded_files_h ${CMAKE_CURRENT_BINARY_DIR}/../include/gnuradio/${component}/${name}.h)
|
||||
endforeach(sig)
|
||||
unset(name)
|
||||
|
||||
#create a command to generate the _impl.cc files
|
||||
add_custom_command(
|
||||
OUTPUT ${expanded_files_cc_impl}
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}_impl.cc.t
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
|
||||
${root} ${root}_impl.cc.t ${ARGN}
|
||||
)
|
||||
|
||||
#create a command to generate the _impl.h files
|
||||
add_custom_command(
|
||||
OUTPUT ${expanded_files_h_impl}
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}_impl.h.t
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
|
||||
${root} ${root}_impl.h.t ${ARGN}
|
||||
)
|
||||
|
||||
#make _impl.cc source files depend on _impl.h to force generation
|
||||
set_source_files_properties(${expanded_files_cc_impl}
|
||||
PROPERTIES OBJECT_DEPENDS "${expanded_files_h_impl}"
|
||||
)
|
||||
|
||||
#make _impl.h source files depend on headers to force generation
|
||||
set_source_files_properties(${expanded_files_h_impl}
|
||||
PROPERTIES OBJECT_DEPENDS "${expanded_files_h}"
|
||||
)
|
||||
|
||||
#install rules for the generated files
|
||||
list(APPEND generated_sources ${expanded_files_cc_impl})
|
||||
list(APPEND generated_headers ${expanded_files_h_impl})
|
||||
|
||||
endmacro(GR_EXPAND_X_CC_H_IMPL)
|
||||
|
@ -36,11 +36,11 @@ if(PYTHON_EXECUTABLE)
|
||||
else(PYTHON_EXECUTABLE)
|
||||
|
||||
#use the built-in find script
|
||||
find_package(PythonInterp)
|
||||
find_package(PythonInterp 2)
|
||||
|
||||
#and if that fails use the find program routine
|
||||
if(NOT PYTHONINTERP_FOUND)
|
||||
find_program(PYTHON_EXECUTABLE NAMES python python2.7 python2.6 python2.5)
|
||||
find_program(PYTHON_EXECUTABLE NAMES python python2 python2.7 python2.6 python2.5)
|
||||
if(PYTHON_EXECUTABLE)
|
||||
set(PYTHONINTERP_FOUND TRUE)
|
||||
endif(PYTHON_EXECUTABLE)
|
||||
@ -48,8 +48,15 @@ else(PYTHON_EXECUTABLE)
|
||||
|
||||
endif(PYTHON_EXECUTABLE)
|
||||
|
||||
if (CMAKE_CROSSCOMPILING)
|
||||
set(QA_PYTHON_EXECUTABLE "/usr/bin/python")
|
||||
else (CMAKE_CROSSCOMPILING)
|
||||
set(QA_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
|
||||
endif(CMAKE_CROSSCOMPILING)
|
||||
|
||||
#make the path to the executable appear in the cmake gui
|
||||
set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter")
|
||||
set(QA_PYTHON_EXECUTABLE ${QA_PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter for QA tests")
|
||||
|
||||
#make sure we can use -B with python (introduced in 2.6)
|
||||
if(PYTHON_EXECUTABLE)
|
||||
@ -96,11 +103,13 @@ endmacro(GR_PYTHON_CHECK_MODULE)
|
||||
########################################################################
|
||||
# Sets the python installation directory GR_PYTHON_DIR
|
||||
########################################################################
|
||||
if(NOT DEFINED GR_PYTHON_DIR)
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "
|
||||
from distutils import sysconfig
|
||||
print sysconfig.get_python_lib(plat_specific=True, prefix='')
|
||||
" OUTPUT_VARIABLE GR_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
endif()
|
||||
file(TO_CMAKE_PATH ${GR_PYTHON_DIR} GR_PYTHON_DIR)
|
||||
|
||||
########################################################################
|
||||
@ -183,7 +192,7 @@ function(GR_PYTHON_INSTALL)
|
||||
file(TO_NATIVE_PATH ${PYTHON_EXECUTABLE} pyexe_native)
|
||||
|
||||
if (CMAKE_CROSSCOMPILING)
|
||||
set(pyexe_native /usr/bin/env python)
|
||||
set(pyexe_native "/usr/bin/env python")
|
||||
endif()
|
||||
|
||||
foreach(pyfile ${GR_PYTHON_INSTALL_PROGRAMS})
|
||||
@ -198,8 +207,9 @@ function(GR_PYTHON_INSTALL)
|
||||
add_custom_command(
|
||||
OUTPUT ${pyexefile} DEPENDS ${pyfile}
|
||||
COMMAND ${PYTHON_EXECUTABLE} -c
|
||||
\"open('${pyexefile}', 'w').write('\#!${pyexe_native}\\n'+open('${pyfile}').read())\"
|
||||
"open('${pyexefile}','w').write('\#!${pyexe_native}\\n'+open('${pyfile}').read())"
|
||||
COMMENT "Shebangin ${pyfile_name}"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
#on windows, python files need an extension to execute
|
||||
|
@ -105,23 +105,35 @@ endfunction(GR_SWIG_MAKE_DOCS)
|
||||
macro(GR_SWIG_MAKE name)
|
||||
set(ifiles ${ARGN})
|
||||
|
||||
list(APPEND GR_SWIG_TARGET_DEPS ${GR_SWIG_LIBRARIES})
|
||||
# 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})
|
||||
|
||||
#do swig doc generation if specified
|
||||
if(GR_SWIG_DOC_FILE)
|
||||
set(GR_SWIG_DOCS_SOURCE_DEPS ${GR_SWIG_SOURCE_DEPS})
|
||||
set(GR_SWIG_DOCS_TAREGT_DEPS ${GR_SWIG_TARGET_DEPS})
|
||||
list(APPEND GR_SWIG_DOCS_TARGET_DEPS ${GR_SWIG_TARGET_DEPS})
|
||||
GR_SWIG_MAKE_DOCS(${GR_SWIG_DOC_FILE} ${GR_SWIG_DOC_DIRS})
|
||||
add_custom_target(${name}_swig_doc DEPENDS ${GR_SWIG_DOC_FILE})
|
||||
list(APPEND GR_SWIG_TARGET_DEPS ${name}_swig_doc)
|
||||
list(APPEND GR_SWIG_TARGET_DEPS ${name}_swig_doc ${GR_RUNTIME_SWIG_DOC_FILE})
|
||||
endif()
|
||||
|
||||
#append additional include directories
|
||||
find_package(PythonLibs)
|
||||
find_package(PythonLibs 2)
|
||||
list(APPEND GR_SWIG_INCLUDE_DIRS ${PYTHON_INCLUDE_PATH}) #deprecated name (now dirs)
|
||||
list(APPEND GR_SWIG_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS})
|
||||
list(APPEND GR_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
list(APPEND GR_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
#prepend local swig directories
|
||||
list(INSERT GR_SWIG_INCLUDE_DIRS 0 ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
list(INSERT GR_SWIG_INCLUDE_DIRS 0 ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
#determine include dependencies for swig file
|
||||
execute_process(
|
||||
@ -160,6 +172,9 @@ macro(GR_SWIG_MAKE name)
|
||||
include(UseSWIG)
|
||||
SWIG_ADD_MODULE(${name} python ${ifiles})
|
||||
SWIG_LINK_LIBRARIES(${name} ${PYTHON_LIBRARIES} ${GR_SWIG_LIBRARIES})
|
||||
if(${name} STREQUAL "runtime_swig")
|
||||
SET_TARGET_PROPERTIES(${SWIG_MODULE_runtime_swig_REAL_NAME} PROPERTIES DEFINE_SYMBOL "gnuradio_runtime_EXPORTS")
|
||||
endif(${name} STREQUAL "runtime_swig")
|
||||
|
||||
endmacro(GR_SWIG_MAKE)
|
||||
|
||||
@ -207,21 +222,25 @@ file(WRITE ${CMAKE_BINARY_DIR}/get_swig_deps.py "
|
||||
|
||||
import os, sys, re
|
||||
|
||||
include_matcher = re.compile('[#|%]include\\s*[<|\"](.*)[>|\"]')
|
||||
i_include_matcher = re.compile('%(include|import)\\s*[<|\"](.*)[>|\"]')
|
||||
h_include_matcher = re.compile('#(include)\\s*[<|\"](.*)[>|\"]')
|
||||
include_dirs = sys.argv[2].split(';')
|
||||
|
||||
def get_swig_incs(file_path):
|
||||
if file_path.endswith('.i'): matcher = i_include_matcher
|
||||
else: matcher = h_include_matcher
|
||||
file_contents = open(file_path, 'r').read()
|
||||
return include_matcher.findall(file_contents, re.MULTILINE)
|
||||
return matcher.findall(file_contents, re.MULTILINE)
|
||||
|
||||
def get_swig_deps(file_path, level):
|
||||
deps = [file_path]
|
||||
if level == 0: return deps
|
||||
for inc_file in get_swig_incs(file_path):
|
||||
for keyword, inc_file in get_swig_incs(file_path):
|
||||
for inc_dir in include_dirs:
|
||||
inc_path = os.path.join(inc_dir, inc_file)
|
||||
if not os.path.exists(inc_path): continue
|
||||
deps.extend(get_swig_deps(inc_path, level-1))
|
||||
break #found, we dont search in lower prio inc dirs
|
||||
return deps
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -30,6 +30,7 @@ set(__INCLUDED_GR_TEST_CMAKE TRUE)
|
||||
# GR_TEST_TARGET_DEPS - built targets for the library path
|
||||
# GR_TEST_LIBRARY_DIRS - directories for the library path
|
||||
# GR_TEST_PYTHON_DIRS - directories for the python path
|
||||
# GR_TEST_ENVIRONS - other environment key/value pairs
|
||||
########################################################################
|
||||
function(GR_ADD_TEST test_name)
|
||||
|
||||
@ -65,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 "GR_DONT_LOAD_PREFS=1" "srcdir=${srcdir}")
|
||||
set(environs "VOLK_GENERIC=1" "GR_DONT_LOAD_PREFS=1" "srcdir=${srcdir}")
|
||||
list(APPEND environs ${GR_TEST_ENVIRONS})
|
||||
|
||||
#http://www.cmake.org/pipermail/cmake/2009-May/029464.html
|
||||
#Replaced this add test + set environs code with the shell script generation.
|
||||
@ -89,7 +91,11 @@ function(GR_ADD_TEST test_name)
|
||||
list(APPEND environs "PATH=${binpath}" "${LD_PATH_VAR}=${libpath}" "PYTHONPATH=${pypath}")
|
||||
|
||||
#generate a bat file that sets the environment and runs the test
|
||||
if (CMAKE_CROSSCOMPILING)
|
||||
set(SHELL "/bin/sh")
|
||||
else(CMAKE_CROSSCOMPILING)
|
||||
find_program(SHELL sh)
|
||||
endif(CMAKE_CROSSCOMPILING)
|
||||
set(sh_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.sh)
|
||||
file(WRITE ${sh_file} "#!${SHELL}\n")
|
||||
#each line sets an environment variable
|
||||
|
304
cmake/Modules/UseSWIG.cmake
Normal file
304
cmake/Modules/UseSWIG.cmake
Normal file
@ -0,0 +1,304 @@
|
||||
# - SWIG module for CMake
|
||||
# Defines the following macros:
|
||||
# SWIG_ADD_MODULE(name language [ files ])
|
||||
# - Define swig module with given name and specified language
|
||||
# SWIG_LINK_LIBRARIES(name [ libraries ])
|
||||
# - Link libraries to swig module
|
||||
# All other macros are for internal use only.
|
||||
# To get the actual name of the swig module,
|
||||
# use: ${SWIG_MODULE_${name}_REAL_NAME}.
|
||||
# Set Source files properties such as CPLUSPLUS and SWIG_FLAGS to specify
|
||||
# special behavior of SWIG. Also global CMAKE_SWIG_FLAGS can be used to add
|
||||
# special flags to all swig calls.
|
||||
# Another special variable is CMAKE_SWIG_OUTDIR, it allows one to specify
|
||||
# where to write all the swig generated module (swig -outdir option)
|
||||
# The name-specific variable SWIG_MODULE_<name>_EXTRA_DEPS may be used
|
||||
# to specify extra dependencies for the generated modules.
|
||||
# If the source file generated by swig need some special flag you can use
|
||||
# set_source_files_properties( ${swig_generated_file_fullname}
|
||||
# PROPERTIES COMPILE_FLAGS "-bla")
|
||||
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2004-2009 Kitware, Inc.
|
||||
# Copyright 2009 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
set(SWIG_CXX_EXTENSION "cxx")
|
||||
set(SWIG_EXTRA_LIBRARIES "")
|
||||
|
||||
set(SWIG_PYTHON_EXTRA_FILE_EXTENSION "py")
|
||||
|
||||
#
|
||||
# For given swig module initialize variables associated with it
|
||||
#
|
||||
macro(SWIG_MODULE_INITIALIZE name language)
|
||||
string(TOUPPER "${language}" swig_uppercase_language)
|
||||
string(TOLOWER "${language}" swig_lowercase_language)
|
||||
set(SWIG_MODULE_${name}_LANGUAGE "${swig_uppercase_language}")
|
||||
set(SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG "${swig_lowercase_language}")
|
||||
|
||||
set(SWIG_MODULE_${name}_REAL_NAME "${name}")
|
||||
if("${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "UNKNOWN")
|
||||
message(FATAL_ERROR "SWIG Error: Language \"${language}\" not found")
|
||||
elseif("${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "PYTHON")
|
||||
# when swig is used without the -interface it will produce in the module.py
|
||||
# a 'import _modulename' statement, which implies having a corresponding
|
||||
# _modulename.so (*NIX), _modulename.pyd (Win32).
|
||||
set(SWIG_MODULE_${name}_REAL_NAME "_${name}")
|
||||
elseif("${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "PERL")
|
||||
set(SWIG_MODULE_${name}_EXTRA_FLAGS "-shadow")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
#
|
||||
# For a given language, input file, and output file, determine extra files that
|
||||
# will be generated. This is internal swig macro.
|
||||
#
|
||||
|
||||
macro(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile)
|
||||
set(${outfiles} "")
|
||||
get_source_file_property(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename
|
||||
${infile} SWIG_MODULE_NAME)
|
||||
if(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename STREQUAL "NOTFOUND")
|
||||
get_filename_component(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${infile}" NAME_WE)
|
||||
endif()
|
||||
foreach(it ${SWIG_${language}_EXTRA_FILE_EXTENSION})
|
||||
set(${outfiles} ${${outfiles}}
|
||||
"${generatedpath}/${SWIG_GET_EXTRA_OUTPUT_FILES_module_basename}.${it}")
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
#
|
||||
# Take swig (*.i) file and add proper custom commands for it
|
||||
#
|
||||
macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
|
||||
set(swig_full_infile ${infile})
|
||||
get_filename_component(swig_source_file_path "${infile}" PATH)
|
||||
get_filename_component(swig_source_file_name_we "${infile}" NAME_WE)
|
||||
get_source_file_property(swig_source_file_generated ${infile} GENERATED)
|
||||
get_source_file_property(swig_source_file_cplusplus ${infile} CPLUSPLUS)
|
||||
get_source_file_property(swig_source_file_flags ${infile} SWIG_FLAGS)
|
||||
if("${swig_source_file_flags}" STREQUAL "NOTFOUND")
|
||||
set(swig_source_file_flags "")
|
||||
endif()
|
||||
set(swig_source_file_fullname "${infile}")
|
||||
if(${swig_source_file_path} MATCHES "^${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
string(REGEX REPLACE
|
||||
"^${CMAKE_CURRENT_SOURCE_DIR}" ""
|
||||
swig_source_file_relative_path
|
||||
"${swig_source_file_path}")
|
||||
else()
|
||||
if(${swig_source_file_path} MATCHES "^${CMAKE_CURRENT_BINARY_DIR}")
|
||||
string(REGEX REPLACE
|
||||
"^${CMAKE_CURRENT_BINARY_DIR}" ""
|
||||
swig_source_file_relative_path
|
||||
"${swig_source_file_path}")
|
||||
set(swig_source_file_generated 1)
|
||||
else()
|
||||
set(swig_source_file_relative_path "${swig_source_file_path}")
|
||||
if(swig_source_file_generated)
|
||||
set(swig_source_file_fullname "${CMAKE_CURRENT_BINARY_DIR}/${infile}")
|
||||
else()
|
||||
set(swig_source_file_fullname "${CMAKE_CURRENT_SOURCE_DIR}/${infile}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(swig_generated_file_fullname
|
||||
"${CMAKE_CURRENT_BINARY_DIR}")
|
||||
if(swig_source_file_relative_path)
|
||||
set(swig_generated_file_fullname
|
||||
"${swig_generated_file_fullname}/${swig_source_file_relative_path}")
|
||||
endif()
|
||||
# If CMAKE_SWIG_OUTDIR was specified then pass it to -outdir
|
||||
if(CMAKE_SWIG_OUTDIR)
|
||||
set(swig_outdir ${CMAKE_SWIG_OUTDIR})
|
||||
else()
|
||||
set(swig_outdir ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif()
|
||||
SWIG_GET_EXTRA_OUTPUT_FILES(${SWIG_MODULE_${name}_LANGUAGE}
|
||||
swig_extra_generated_files
|
||||
"${swig_outdir}"
|
||||
"${infile}")
|
||||
set(swig_generated_file_fullname
|
||||
"${swig_generated_file_fullname}/${swig_source_file_name_we}")
|
||||
# add the language into the name of the file (i.e. TCL_wrap)
|
||||
# this allows for the same .i file to be wrapped into different languages
|
||||
set(swig_generated_file_fullname
|
||||
"${swig_generated_file_fullname}${SWIG_MODULE_${name}_LANGUAGE}_wrap")
|
||||
|
||||
if(swig_source_file_cplusplus)
|
||||
set(swig_generated_file_fullname
|
||||
"${swig_generated_file_fullname}.${SWIG_CXX_EXTENSION}")
|
||||
else()
|
||||
set(swig_generated_file_fullname
|
||||
"${swig_generated_file_fullname}.c")
|
||||
endif()
|
||||
|
||||
# Shut up some warnings from poor SWIG code generation that we
|
||||
# can do nothing about, when this flag is available
|
||||
include(CheckCXXCompilerFlag)
|
||||
check_cxx_compiler_flag("-Wno-unused-but-set-variable" HAVE_WNO_UNUSED_BUT_SET_VARIABLE)
|
||||
if(HAVE_WNO_UNUSED_BUT_SET_VARIABLE)
|
||||
set_source_files_properties(${swig_generated_file_fullname}
|
||||
PROPERTIES COMPILE_FLAGS "-Wno-unused-but-set-variable")
|
||||
endif(HAVE_WNO_UNUSED_BUT_SET_VARIABLE)
|
||||
|
||||
get_directory_property(cmake_include_directories INCLUDE_DIRECTORIES)
|
||||
set(swig_include_dirs)
|
||||
foreach(it ${cmake_include_directories})
|
||||
set(swig_include_dirs ${swig_include_dirs} "-I${it}")
|
||||
endforeach()
|
||||
|
||||
set(swig_special_flags)
|
||||
# default is c, so add c++ flag if it is c++
|
||||
if(swig_source_file_cplusplus)
|
||||
set(swig_special_flags ${swig_special_flags} "-c++")
|
||||
endif()
|
||||
set(swig_extra_flags)
|
||||
if(SWIG_MODULE_${name}_EXTRA_FLAGS)
|
||||
set(swig_extra_flags ${swig_extra_flags} ${SWIG_MODULE_${name}_EXTRA_FLAGS})
|
||||
endif()
|
||||
|
||||
# hack to work around CMake bug in add_custom_command with multiple OUTPUT files
|
||||
|
||||
file(RELATIVE_PATH reldir ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
execute_process(
|
||||
COMMAND ${PYTHON_EXECUTABLE} -c "import re, hashlib
|
||||
unique = hashlib.md5('${reldir}${ARGN}').hexdigest()[:5]
|
||||
print(re.sub('\\W', '_', '${name} ${reldir} ' + unique))"
|
||||
OUTPUT_VARIABLE _target OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
file(
|
||||
WRITE ${CMAKE_CURRENT_BINARY_DIR}/${_target}.cpp.in
|
||||
"int main(void){return 0;}\n"
|
||||
)
|
||||
|
||||
# create dummy dependencies
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_target}.cpp
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${_target}.cpp.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${_target}.cpp
|
||||
DEPENDS "${swig_source_file_fullname}" ${SWIG_MODULE_${name}_EXTRA_DEPS}
|
||||
COMMENT ""
|
||||
)
|
||||
|
||||
# create the dummy target
|
||||
add_executable(${_target} ${CMAKE_CURRENT_BINARY_DIR}/${_target}.cpp)
|
||||
|
||||
# add a custom command to the dummy target
|
||||
add_custom_command(
|
||||
TARGET ${_target}
|
||||
# Let's create the ${swig_outdir} at execution time, in case dir contains $(OutDir)
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${swig_outdir}
|
||||
COMMAND "${SWIG_EXECUTABLE}"
|
||||
ARGS "-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}"
|
||||
${swig_source_file_flags}
|
||||
${CMAKE_SWIG_FLAGS}
|
||||
-outdir ${swig_outdir}
|
||||
${swig_special_flags}
|
||||
${swig_extra_flags}
|
||||
${swig_include_dirs}
|
||||
-o "${swig_generated_file_fullname}"
|
||||
"${swig_source_file_fullname}"
|
||||
COMMENT "Swig source"
|
||||
)
|
||||
|
||||
#add dummy independent dependencies from the _target to each file
|
||||
#that will be generated by the SWIG command above
|
||||
|
||||
set(${outfiles} "${swig_generated_file_fullname}" ${swig_extra_generated_files})
|
||||
|
||||
foreach(swig_gen_file ${${outfiles}})
|
||||
add_custom_command(
|
||||
OUTPUT ${swig_gen_file}
|
||||
COMMAND ""
|
||||
DEPENDS ${_target}
|
||||
COMMENT ""
|
||||
)
|
||||
endforeach()
|
||||
|
||||
set_source_files_properties(
|
||||
${outfiles} PROPERTIES GENERATED 1
|
||||
)
|
||||
|
||||
endmacro()
|
||||
|
||||
#
|
||||
# Create Swig module
|
||||
#
|
||||
macro(SWIG_ADD_MODULE name language)
|
||||
SWIG_MODULE_INITIALIZE(${name} ${language})
|
||||
set(swig_dot_i_sources)
|
||||
set(swig_other_sources)
|
||||
foreach(it ${ARGN})
|
||||
if(${it} MATCHES ".*\\.i$")
|
||||
set(swig_dot_i_sources ${swig_dot_i_sources} "${it}")
|
||||
else()
|
||||
set(swig_other_sources ${swig_other_sources} "${it}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(swig_generated_sources)
|
||||
foreach(it ${swig_dot_i_sources})
|
||||
SWIG_ADD_SOURCE_TO_MODULE(${name} swig_generated_source ${it})
|
||||
set(swig_generated_sources ${swig_generated_sources} "${swig_generated_source}")
|
||||
endforeach()
|
||||
get_directory_property(swig_extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES)
|
||||
set_directory_properties(PROPERTIES
|
||||
ADDITIONAL_MAKE_CLEAN_FILES "${swig_extra_clean_files};${swig_generated_sources}")
|
||||
add_library(${SWIG_MODULE_${name}_REAL_NAME}
|
||||
MODULE
|
||||
${swig_generated_sources}
|
||||
${swig_other_sources})
|
||||
string(TOLOWER "${language}" swig_lowercase_language)
|
||||
if ("${swig_lowercase_language}" STREQUAL "java")
|
||||
if (APPLE)
|
||||
# In java you want:
|
||||
# System.loadLibrary("LIBRARY");
|
||||
# then JNI will look for a library whose name is platform dependent, namely
|
||||
# MacOS : libLIBRARY.jnilib
|
||||
# Windows: LIBRARY.dll
|
||||
# Linux : libLIBRARY.so
|
||||
set_target_properties (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".jnilib")
|
||||
endif ()
|
||||
endif ()
|
||||
if ("${swig_lowercase_language}" STREQUAL "python")
|
||||
# this is only needed for the python case where a _modulename.so is generated
|
||||
set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "")
|
||||
# Python extension modules on Windows must have the extension ".pyd"
|
||||
# instead of ".dll" as of Python 2.5. Older python versions do support
|
||||
# this suffix.
|
||||
# http://docs.python.org/whatsnew/ports.html#SECTION0001510000000000000000
|
||||
# <quote>
|
||||
# Windows: .dll is no longer supported as a filename extension for extension modules.
|
||||
# .pyd is now the only filename extension that will be searched for.
|
||||
# </quote>
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".pyd")
|
||||
endif()
|
||||
endif ()
|
||||
endmacro()
|
||||
|
||||
#
|
||||
# Like TARGET_LINK_LIBRARIES but for swig modules
|
||||
#
|
||||
macro(SWIG_LINK_LIBRARIES name)
|
||||
if(SWIG_MODULE_${name}_REAL_NAME)
|
||||
target_link_libraries(${SWIG_MODULE_${name}_REAL_NAME} ${ARGN})
|
||||
else()
|
||||
message(SEND_ERROR "Cannot find Swig library \"${name}\".")
|
||||
endif()
|
||||
endmacro()
|
Loading…
Reference in New Issue
Block a user