diff options
-rw-r--r-- | CMakeLists.txt | 22 | ||||
-rw-r--r-- | cmake/Modules/GnuradioConfig.cmake | 123 | ||||
-rw-r--r-- | cmake/Modules/GnuradioConfigVersion.cmake.in | 35 | ||||
-rw-r--r-- | docs/doxygen/other/main_page.dox | 59 |
4 files changed, 234 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 14be392eb1..17c0ad367e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -280,12 +280,24 @@ add_subdirectory(gr-fcd) add_subdirectory(gr-wavelet) add_subdirectory(gr-wxgui) -# Install our Cmake modules into ${GR_PKG_DATA_DIR}/cmake/Modules -file(GLOB cmake_modules "cmake/Modules/*.cmake") +# Install our Cmake modules into $prefix/lib/cmake/gnuradio +# See "Package Configuration Files" on page: +# http://www.cmake.org/Wiki/CMake/Tutorials/Packaging + +configure_file( + ${CMAKE_SOURCE_DIR}/cmake/Modules/GnuradioConfigVersion.cmake.in + ${CMAKE_BINARY_DIR}/cmake/Modules/GnuradioConfigVersion.cmake +@ONLY) + +SET(cmake_configs + ${CMAKE_SOURCE_DIR}/cmake/Modules/GnuradioConfig.cmake + ${CMAKE_BINARY_DIR}/cmake/Modules/GnuradioConfigVersion.cmake +) + install( - FILES ${cmake_modules} - DESTINATION ${GR_PKG_DATA_DIR}/cmake/Modules - COMPONENT "core_devel" + FILES ${cmake_configs} + DESTINATION lib/cmake/gnuradio + COMPONENT "runtime_devel" ) #finalize cpack after subdirs processed diff --git a/cmake/Modules/GnuradioConfig.cmake b/cmake/Modules/GnuradioConfig.cmake new file mode 100644 index 0000000000..9434f08ef4 --- /dev/null +++ b/cmake/Modules/GnuradioConfig.cmake @@ -0,0 +1,123 @@ +# Copyright 2013 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.
+
+INCLUDE(FindPkgConfig)
+INCLUDE(FindPackageHandleStandardArgs)
+
+# if GR_REQUIRED_COMPONENTS is not defined, it will be set to the following list (all of them)
+if(NOT GR_REQUIRED_COMPONENTS)
+ set(GR_REQUIRED_COMPONENTS CORE RUNTIME ANALOG ATSC AUDIO BLOCKS CHANNELS DIGITAL FCD FEC FFT FILTER NOAA PAGER QTGUI TRELLIS UHD VOCODER WAVELET WXGUI)
+endif()
+
+set(GNURADIO_ALL_LIBRARIES "")
+set(GNURADIO_ALL_INCLUDE_DIRS "")
+
+MACRO(LIST_CONTAINS var value)
+ SET(${var})
+ FOREACH(value2 ${ARGN})
+ IF (${value} STREQUAL ${value2})
+ SET(${var} TRUE)
+ ENDIF(${value} STREQUAL ${value2})
+ ENDFOREACH(value2)
+ENDMACRO(LIST_CONTAINS)
+
+function(GR_MODULE EXTVAR PCNAME INCFILE LIBFILE)
+
+ LIST_CONTAINS(REQUIRED_MODULE ${EXTVAR} ${GR_REQUIRED_COMPONENTS})
+ if(NOT REQUIRED_MODULE)
+ #message("Ignoring GNU Radio Module ${EXTVAR}")
+ return()
+ endif()
+
+ message("Checking for GNU Radio Module: ${EXTVAR}")
+
+ # check for .pc hints
+ PKG_CHECK_MODULES(PC_GNURADIO_${EXTVAR} ${PCNAME})
+
+ set(INCVAR_NAME "GNURADIO_${EXTVAR}_INCLUDE_DIRS")
+ set(LIBVAR_NAME "GNURADIO_${EXTVAR}_LIBRARIES")
+ set(PC_INCDIR ${PC_GNURADIO_${EXTVAR}_INCLUDEDIR})
+ set(PC_LIBDIR ${PC_GNURADIO_${EXTVAR}_LIBDIR})
+
+ # look for include files
+ FIND_PATH(
+ ${INCVAR_NAME}
+ NAMES ${INCFILE}
+ HINTS $ENV{GNURADIO_CORE_DIR}/include/gnuradio
+ ${PC_INCDIR}
+ ${PC_INCDIR}/gnuradio/
+ ${CMAKE_INSTALL_PREFIX}/include/gnuradio
+ PATHS /usr/local/include/gnuradio
+ /usr/include/gnuradio
+ )
+
+ # look for libs
+ FIND_LIBRARY(
+ ${LIBVAR_NAME}
+ NAMES ${LIBFILE}
+ HINTS $ENV{GNURADIO_CORE_DIR}/lib
+ ${PC_LIBDIR}
+ ${CMAKE_INSTALL_PREFIX}/lib/
+ ${CMAKE_INSTALL_PREFIX}/lib64/
+ PATHS /usr/local/lib
+ /usr/local/lib64
+ /usr/lib
+ /usr/lib64
+ )
+
+ # show results
+ message(" * INCLUDES=${GNURADIO_${EXTVAR}_INCLUDE_DIRS}")
+ message(" * LIBS=${GNURADIO_${EXTVAR}_LIBRARIES}")
+
+ # append to all includes and libs list
+ LIST(APPEND GNURADIO_ALL_INCLUDE_DIRS ${GNURADIO_${EXTVAR}_INCLUDE_DIRS})
+ LIST(APPEND GNURADIO_ALL_LIBRARIES ${GNURADIO_${EXTVAR}_LIBRARIES})
+
+ FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNURADIO_${EXTVAR} DEFAULT_MSG GNURADIO_${EXTVAR}_LIBRARIES GNURADIO_${EXTVAR}_INCLUDE_DIRS)
+ message("GNURADIO_${EXTVAR}_FOUND = ${GNURADIO_${EXTVAR}_FOUND}")
+ set(GNURADIO_${EXTVAR}_FOUND ${GNURADIO_${EXTVAR}_FOUND} PARENT_SCOPE)
+
+ # generate an error if the module is missing
+ if(NOT GNURADIO_${EXTVAR}_FOUND)
+ message(FATAL_ERROR "Required GNU Radio Component: ${EXTVAR} missing!")
+ endif()
+
+ MARK_AS_ADVANCED(GNURADIO_${EXTVAR}_LIBRARIES GNURADIO_${EXTVAR}_INCLUDE_DIRS)
+
+endfunction()
+
+GR_MODULE(CORE gnuradio-core gr_top_block.h gnuradio-core)
+GR_MODULE(RUNTIME gnuradio-core gr_top_block.h gnuradio-core)
+GR_MODULE(ANALOG gnuradio-analog analog/noise_type.h gnuradio-analog)
+GR_MODULE(ATSC gnuradio-atsc atsc/api.h gnuradio-atsc)
+GR_MODULE(AUDIO gnuradio-audio audio/sink.h gnuradio-audio)
+GR_MODULE(BLOCKS gnuradio-blocks blocks/delay.h gnuradio-blocks)
+GR_MODULE(CHANNELS gnuradio-channels channels/channel_model.h gnuradio-channels)
+GR_MODULE(DIGITAL gnuradio-digital digital/lfsr.h gnuradio-digital)
+GR_MODULE(FEC gnuradio-fec fec/rs.h gnuradio-fec)
+GR_MODULE(FFT gnuradio-fft fft/fft.h gnuradio-fft)
+GR_MODULE(FILTER gnuradio-filter filter/fir_filter.h gnuradio-filter)
+GR_MODULE(NOAA gnuradio-noaa noaa/hrpt.h gnuradio-noaa)
+GR_MODULE(PAGER gnuradio-pager pager/flex_deinterleave.h gnuradio-pager)
+GR_MODULE(QTGUI gnuradio-qtgui qtgui/utils.h gnuradio-qtgui)
+GR_MODULE(TRELLIS gnuradio-trellis trellis/fsm.h gnuradio-trellis)
+GR_MODULE(UHD gnuradio-uhd uhd/usrp_sink.h gnuradio-uhd)
+GR_MODULE(VOCODER gnuradio-vocoder vocoder/alaw_encode_sb.h gnuradio-vocoder)
+GR_MODULE(WAVELET gnuradio-wavelet wavelet/wavelet_ff.h gnuradio-wavelet)
+
diff --git a/cmake/Modules/GnuradioConfigVersion.cmake.in b/cmake/Modules/GnuradioConfigVersion.cmake.in new file mode 100644 index 0000000000..a9717a7e5a --- /dev/null +++ b/cmake/Modules/GnuradioConfigVersion.cmake.in @@ -0,0 +1,35 @@ +# Copyright 2013 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.
+
+set(MAJOR_VERSION @VERSION_INFO_MAJOR_VERSION@)
+set(API_COMPAT @VERSION_INFO_API_COMPAT@)
+set(MINOR_VERSION @VERSION_INFO_MINOR_VERSION@)
+set(MAINT_VERSION @VERSION_INFO_MAINT_VERSION@)
+
+set(PACKAGE_VERSION
+ ${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}.${MAINT_VERSION})
+
+if(${PACKAGE_FIND_VERSION_MAJOR} EQUAL ${MAJOR_VERSION})
+ if(${PACKAGE_FIND_VERSION_MINOR} EQUAL ${API_COMPAT})
+ if(NOT ${PACKAGE_FIND_VERSION_PATCH} GREATER ${MINOR_VERSION})
+ set(PACKAGE_VERSION_EXACT 1) # exact match for API version
+ set(PACKAGE_VERSION_COMPATIBLE 1) # compat for minor/patch version
+ endif(NOT ${PACKAGE_FIND_VERSION_PATCH} GREATER ${MINOR_VERSION})
+ endif(${PACKAGE_FIND_VERSION_MINOR} EQUAL ${API_COMPAT})
+endif(${PACKAGE_FIND_VERSION_MAJOR} EQUAL ${MAJOR_VERSION})
\ No newline at end of file diff --git a/docs/doxygen/other/main_page.dox b/docs/doxygen/other/main_page.dox index 9353bfb315..916ac9bdd1 100644 --- a/docs/doxygen/other/main_page.dox +++ b/docs/doxygen/other/main_page.dox @@ -404,4 +404,63 @@ configuration variable and the section and option names are in uppercase. The value is the same format that would be used in the config file itself. + + +\section oot_config_page Out-of-Tree Configuration + +New as of 3.6.5. + +Using gr_modtool, each package comes with the ability to easily locate +the gnuradio-core library using the 'find_package(GnuradioCore)' cmake +command. This only locates that the library and include directories +exist, which is enough for most simple projects. + +As projects become more complicated and start needing to rely on other +GNU Radio components like gnuradio-blocks or gnuradio-filter, for +example, and when they become dependent on certain API compatibility +versions of GNU Radio, we need something more. And so we have +introduced the GnuradioConfig.cmake file. + +When GNU Radio is installed, it also installs a GNU Radio-specific +cmake config file that we can use for more advanced compatibility +issues of our projects. This tool allows us to specific the API +compatible version and a set of components that are required. + +Taking the above example, say we have built against version 3.6.5 with +features that were introduced in this version and we need the blocks +and filter components as well as the main core library. We fist set a +cmake variable GR_REQUIRED_COMPONENTS to the components we need. We +then use the 'find_package' command and also set a minimum required +API compatible version. Since we are on the 3.6 API version, the +minimum required version is "3.6.5". The code in the CMakeLists.txt +file would look like this: + +\code + set(GR_REQUIRED_COMPONENTS RUNTIME BLOCKS FILTER) + find_package(Gnuradio 3.6.5) +\endcode + +Note that the capitalization is important on both lines. + +If the installed version of GNU Radio is 3.6.4 or some other API +version like 3.5 or 3.7, the Cmake configuration will fail with the +version error. Likewise, if libgnuradio-filter was not installed as +part of GNU Radio, the configuration will also fail. + +\subsection oot_config_path_page Install Path + +Cmake has to know where to find these configuration files. They are +installed into $prefix/lib/cmake/gnuradio. If $prefix is '/usr' or +'/usr/local', then everything should work fine. If the GNU Radio +install $prefix is something else, then Cmake must be told where to +find it. This can be done in two ways. If you are installing the +out-of-tree module into the same $prefix, then you would be setting +'-DCMAKE_INSTALL_PREFIX' on the configuration command line. This is +enough to tell Cmake where to look for the configuration files. + +The other way to do it is to set the CMAKE_PREFIX_PATH environmental +variable to $prefix. You can then install your component anywhere +you'd like and it will be able to find and configure against the +installed GNU Radio. + */ |