From 514b806d0a6c64cc795414d05a452c24d6c85927 Mon Sep 17 00:00:00 2001 From: Dimitri Stolnikov Date: Thu, 26 Apr 2012 19:13:23 +0200 Subject: update build system to check for component dependencies this will only enable components if the dependencies were met. --- cmake/Modules/FindGnuradioFCD.cmake | 34 +++++++++++ cmake/Modules/FindGnuradioUHD.cmake | 34 +++++++++++ cmake/Modules/GrComponent.cmake | 115 ++++++++++++++++++++++++++++++++++++ cmake/Modules/GrVersion.cmake | 76 ++++++++++++++++++++++++ 4 files changed, 259 insertions(+) create mode 100644 cmake/Modules/FindGnuradioFCD.cmake create mode 100644 cmake/Modules/FindGnuradioUHD.cmake create mode 100644 cmake/Modules/GrComponent.cmake create mode 100644 cmake/Modules/GrVersion.cmake (limited to 'cmake/Modules') diff --git a/cmake/Modules/FindGnuradioFCD.cmake b/cmake/Modules/FindGnuradioFCD.cmake new file mode 100644 index 0000000..401acda --- /dev/null +++ b/cmake/Modules/FindGnuradioFCD.cmake @@ -0,0 +1,34 @@ +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PC_GNURADIO_FCD gnuradio-fcd) + +FIND_PATH( + GNURADIO_FCD_INCLUDE_DIRS + NAMES fcd_api.h + HINTS $ENV{GNURADIO_FCD_DIR}/include/gnuradio/fcd + ${PC_GNURADIO_FCD_INCLUDEDIR} + PATHS /usr/local/include/gnuradio + /usr/include/gnuradio +) + +FIND_LIBRARY( + GNURADIO_FCD_LIBRARIES + NAMES gnuradio-fcd + HINTS $ENV{GNURADIO_FCD_DIR}/lib + ${PC_GNURADIO_FCD_LIBDIR} + PATHS /usr/local/lib + /usr/local/lib64 + /usr/lib + /usr/lib64 +) + +if(GNURADIO_FCD_INCLUDE_DIRS AND GNURADIO_FCD_LIBRARIES) + set(GNURADIO_FCD_FOUND TRUE CACHE INTERNAL "gnuradio-fcd found") + message(STATUS "Found gnuradio-fcd: ${GNURADIO_FCD_INCLUDE_DIRS}, ${GNURADIO_FCD_LIBRARIES}") +else(GNURADIO_FCD_INCLUDE_DIRS AND GNURADIO_FCD_LIBRARIES) + set(GNURADIO_FCD_FOUND FALSE CACHE INTERNAL "gnuradio-fcd found") + message(STATUS "gnuradio-fcd not found.") +endif(GNURADIO_FCD_INCLUDE_DIRS AND GNURADIO_FCD_LIBRARIES) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNURADIO_FCD DEFAULT_MSG GNURADIO_FCD_LIBRARIES GNURADIO_FCD_INCLUDE_DIRS) +MARK_AS_ADVANCED(GNURADIO_FCD_LIBRARIES GNURADIO_FCD_INCLUDE_DIRS) diff --git a/cmake/Modules/FindGnuradioUHD.cmake b/cmake/Modules/FindGnuradioUHD.cmake new file mode 100644 index 0000000..f8557df --- /dev/null +++ b/cmake/Modules/FindGnuradioUHD.cmake @@ -0,0 +1,34 @@ +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PC_GNURADIO_UHD gnuradio-uhd) + +FIND_PATH( + GNURADIO_UHD_INCLUDE_DIRS + NAMES gr_uhd_api.h + HINTS $ENV{GNURADIO_UHD_DIR}/include/gnuradio + ${PC_GNURADIO_UHD_INCLUDEDIR} + PATHS /usr/local/include/gnuradio + /usr/include/gnuradio +) + +FIND_LIBRARY( + GNURADIO_UHD_LIBRARIES + NAMES gnuradio-uhd + HINTS $ENV{GNURADIO_UHD_DIR}/lib + ${PC_GNURADIO_UHD_LIBDIR} + PATHS /usr/local/lib + /usr/local/lib64 + /usr/lib + /usr/lib64 +) + +if(GNURADIO_UHD_INCLUDE_DIRS AND GNURADIO_UHD_LIBRARIES) + set(GNURADIO_UHD_FOUND TRUE CACHE INTERNAL "gnuradio-uhd found") + message(STATUS "Found gnuradio-uhd: ${GNURADIO_UHD_INCLUDE_DIRS}, ${GNURADIO_UHD_LIBRARIES}") +else(GNURADIO_UHD_INCLUDE_DIRS AND GNURADIO_UHD_LIBRARIES) + set(GNURADIO_UHD_FOUND FALSE CACHE INTERNAL "gnuradio-uhd found") + message(STATUS "gnuradio-uhd not found.") +endif(GNURADIO_UHD_INCLUDE_DIRS AND GNURADIO_UHD_LIBRARIES) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNURADIO_UHD DEFAULT_MSG GNURADIO_UHD_LIBRARIES GNURADIO_UHD_INCLUDE_DIRS) +MARK_AS_ADVANCED(GNURADIO_UHD_LIBRARIES GNURADIO_UHD_INCLUDE_DIRS) diff --git a/cmake/Modules/GrComponent.cmake b/cmake/Modules/GrComponent.cmake new file mode 100644 index 0000000..22b0ea4 --- /dev/null +++ b/cmake/Modules/GrComponent.cmake @@ -0,0 +1,115 @@ +# 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_COMPONENT_CMAKE) + return() +endif() +set(__INCLUDED_GR_COMPONENT_CMAKE TRUE) + +set(_gr_enabled_components "" CACHE INTERNAL "" FORCE) +set(_gr_disabled_components "" CACHE INTERNAL "" FORCE) + +if(NOT DEFINED ENABLE_DEFAULT) + set(ENABLE_DEFAULT ON) + message(STATUS "") + message(STATUS "The build system will automatically enable all components.") + message(STATUS "Use -DENABLE_DEFAULT=OFF to disable components by default.") +endif() + +######################################################################## +# Register a component into the system +# - name: canonical component name +# - var: variable for enabled status +# - argn: list of dependencies +######################################################################## +function(GR_REGISTER_COMPONENT name var) + include(CMakeDependentOption) + message(STATUS "") + message(STATUS "Configuring ${name} support...") + foreach(dep ${ARGN}) + message(STATUS " Dependency ${dep} = ${${dep}}") + endforeach(dep) + + #if the user set the var to force, we note this + if("${${var}}" STREQUAL "FORCE") + set(${var} ON) + set(var_force TRUE) + else() + set(var_force FALSE) + endif() + + #rewrite the dependency list so that deps that are also components use the cached version + unset(comp_deps) + foreach(dep ${ARGN}) + list(FIND _gr_enabled_components ${dep} dep_enb_index) + list(FIND _gr_disabled_components ${dep} dep_dis_index) + if (${dep_enb_index} EQUAL -1 AND ${dep_dis_index} EQUAL -1) + list(APPEND comp_deps ${dep}) + else() + list(APPEND comp_deps ${dep}_cached) #is a component, use cached version + endif() + endforeach(dep) + + #setup the dependent option for this component + CMAKE_DEPENDENT_OPTION(${var} "enable ${name} support" ${ENABLE_DEFAULT} "${comp_deps}" OFF) + set(${var} "${${var}}" PARENT_SCOPE) + set(${var}_cached "${${var}}" CACHE INTERNAL "" FORCE) + + #force was specified, but the dependencies were not met + if(NOT ${var} AND var_force) + message(FATAL_ERROR "user force-enabled ${name} but configuration checked failed") + endif() + + #append the component into one of the lists + if(${var}) + message(STATUS " Enabling ${name} support.") + list(APPEND _gr_enabled_components ${name}) + else(${var}) + message(STATUS " Disabling ${name} support.") + list(APPEND _gr_disabled_components ${name}) + endif(${var}) + message(STATUS " Override with -D${var}=ON/OFF") + + #make components lists into global variables + set(_gr_enabled_components ${_gr_enabled_components} CACHE INTERNAL "" FORCE) + set(_gr_disabled_components ${_gr_disabled_components} CACHE INTERNAL "" FORCE) +endfunction(GR_REGISTER_COMPONENT) + +######################################################################## +# Print the registered component summary +######################################################################## +function(GR_PRINT_COMPONENT_SUMMARY) + message(STATUS "") + message(STATUS "######################################################") + message(STATUS "# gr-osmosdr enabled components ") + message(STATUS "######################################################") + foreach(comp ${_gr_enabled_components}) + message(STATUS " * ${comp}") + endforeach(comp) + + message(STATUS "") + message(STATUS "######################################################") + message(STATUS "# gr-osmosdr disabled components ") + message(STATUS "######################################################") + foreach(comp ${_gr_disabled_components}) + message(STATUS " * ${comp}") + endforeach(comp) + + message(STATUS "") +endfunction(GR_PRINT_COMPONENT_SUMMARY) diff --git a/cmake/Modules/GrVersion.cmake b/cmake/Modules/GrVersion.cmake new file mode 100644 index 0000000..31b0a8e --- /dev/null +++ b/cmake/Modules/GrVersion.cmake @@ -0,0 +1,76 @@ +# Copyright 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_VERSION_CMAKE) + return() +endif() +set(__INCLUDED_GR_VERSION_CMAKE TRUE) + +#eventually, replace version.sh and fill in the variables below +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}) + +######################################################################## +# Extract the version string from git describe. +######################################################################## +find_package(Git) + +if(GIT_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git) + message(STATUS "Extracting version information from git describe...") + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --always --abbrev=8 --long + OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) +else() + set(GIT_DESCRIBE "v${MAJOR_VERSION}.${API_COMPAT}.x-xxx-xunknown") +endif() + +######################################################################## +# Use the logic below to set the version constants +######################################################################## +if("${MINOR_VERSION}" STREQUAL "git") + # VERSION: 3.6git-xxx-gxxxxxxxx + # DOCVER: 3.6git + # LIBVER: 3.6git + set(VERSION "${GIT_DESCRIBE}") + set(DOCVER "${MAJOR_VERSION}.${API_COMPAT}${MINOR_VERSION}") + set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}${MINOR_VERSION}") +elseif("${MAINT_VERSION}" STREQUAL "git") + # VERSION: 3.6.1git-xxx-gxxxxxxxx + # DOCVER: 3.6.1git + # LIBVER: 3.6.1git + set(VERSION "${GIT_DESCRIBE}") + set(DOCVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}${MAINT_VERSION}") + set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}${MAINT_VERSION}") +else() + # This is a numbered release. + # VERSION: 3.6.1{.x} + # DOCVER: 3.6.1{.x} + # LIBVER: 3.6.1{.x} + if("${MAINT_VERSION}" STREQUAL "0") + set(VERSION "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}") + else() + set(VERSION "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}.${MAINT_VERSION}") + endif() + set(DOCVER "${VERSION}") + set(LIBVER "${VERSION}") +endif() -- cgit v1.2.3