From 95ffcd3ac0a0afab909ffce7dedf012fbde514de Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 12 Apr 2017 18:06:04 +0200 Subject: [PATCH] Improve portability In some architectures (e.g. alpha, hppa, powerpcspe, m68k, sh4, sparc64, x32) the package gr-osmosdr is not available. So when the package is build with -DENABLE_OSMOSDR=ON, it breaks on the mentioned architectures. This is expected behaviour (it breaks because a required dependency is not found), but prevents from building the package on such architectures. This commit introduces a small change: when compilation is called with cmake -DENABLE_OSMOSDR=ON -DENABLE_PACKAGING=ON .. then, the compilation does not break if gr-osmosdr is not found. This commit also fixes building when UHD is present but gnuradio-uhd is not (for instance, in hurd-i386) --- CMakeLists.txt | 13 +++++-- .../signal_source/adapters/CMakeLists.txt | 35 ++++++++++--------- src/core/receiver/CMakeLists.txt | 10 +++--- src/main/CMakeLists.txt | 12 +++---- 4 files changed, 42 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9bb480c64..66251e28f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1167,8 +1167,17 @@ if($ENV{RTLSDR_DRIVER}) endif($ENV{RTLSDR_DRIVER}) if(ENABLE_OSMOSDR) - message(STATUS "The driver for OsmoSDR and other front-ends (HackRF, bladeRF, Realtek's RTL2832U-based dongles, etc.) will be compiled." ) - message(STATUS "You can disable it with 'cmake -DENABLE_OSMOSDR=OFF ../'" ) + find_package(GrOsmoSDR) + if(GROSMOSDR_FOUND) + message(STATUS "The driver for OsmoSDR and other front-ends (HackRF, bladeRF, Realtek's RTL2832U-based dongles, etc.) will be compiled." ) + message(STATUS "You can disable it with 'cmake -DENABLE_OSMOSDR=OFF ../'" ) + else(GROSMOSDR_FOUND) + if(ENABLE_PACKAGING) + message(WARNING "gr-osmosdr has not been found. Source blocks depending on it will NOT be built.") + else(ENABLE_PACKAGING) + message(FATAL_ERROR "gr-osmosdr required to build gnss-sdr with the optional OSMOSDR driver") + endif(ENABLE_PACKAGING) + endif(GROSMOSDR_FOUND) else(ENABLE_OSMOSDR) message(STATUS "The (optional) driver for OsmoSDR and related front-ends is not enabled." ) message(STATUS "Enable it with 'cmake -DENABLE_OSMOSDR=ON ../' to add support for OsmoSDR and other front-ends (HackRF, bladeRF, Realtek's RTL2832U-based USB dongles, etc.)" ) diff --git a/src/algorithms/signal_source/adapters/CMakeLists.txt b/src/algorithms/signal_source/adapters/CMakeLists.txt index ad00956da..388b2ed59 100644 --- a/src/algorithms/signal_source/adapters/CMakeLists.txt +++ b/src/algorithms/signal_source/adapters/CMakeLists.txt @@ -16,6 +16,9 @@ # along with GNSS-SDR. If not, see . # +file(GLOB SIGNAL_SOURCE_ADAPTER_HEADERS "*.h") +list(SORT SIGNAL_SOURCE_ADAPTER_HEADERS) + # Optional drivers if(ENABLE_GN3S) @@ -72,26 +75,29 @@ if(ENABLE_OSMOSDR) ################################################################################ # OsmoSDR - http://sdr.osmocom.org/trac/ ################################################################################ - find_package(GrOsmoSDR REQUIRED) if(NOT GROSMOSDR_FOUND) - message(FATAL_ERROR "gr-osmosdr required to build gnss-sdr with the optional OSMOSDR driver") + if(ENABLE_PACKAGING) + list(REMOVE_ITEM SIGNAL_SOURCE_ADAPTER_HEADERS ${CMAKE_SOURCE_DIR}/src/algorithms/signal_source/adapters/osmosdr_signal_source.h) + endif(ENABLE_PACKAGING) + else(NOT GROSMOSDR_FOUND) + # set OSMO include dirs + set(OSMO_DRIVER_INCLUDE_DIRS + ${OPT_DRIVER_INCLUDE_DIRS} + ${GROSMOSDR_INCLUDE_DIR}/osmosdr + ) + set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} osmosdr_signal_source.cc) + set(OPT_LIBRARIES ${OPT_LIBRARIES} ${GROSMOSDR_LIBRARIES}) + set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${OSMO_DRIVER_INCLUDE_DIRS}) endif(NOT GROSMOSDR_FOUND) - - # set OSMO include dirs - set(OSMO_DRIVER_INCLUDE_DIRS - ${OPT_DRIVER_INCLUDE_DIRS} - ${GROSMOSDR_INCLUDE_DIR}/osmosdr - ) - set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} osmosdr_signal_source.cc) - set(OPT_LIBRARIES ${OPT_LIBRARIES} ${GROSMOSDR_LIBRARIES}) - set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${OSMO_DRIVER_INCLUDE_DIRS}) endif(ENABLE_OSMOSDR) -if(ENABLE_UHD) +if(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} uhd_signal_source.cc) set(OPT_LIBRARIES ${OPT_LIBRARIES} ${UHD_LIBRARIES} ${GNURADIO_UHD_LIBRARIES}) set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${UHD_INCLUDE_DIRS}) -endif(ENABLE_UHD) +else(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) + list(REMOVE_ITEM SIGNAL_SOURCE_ADAPTER_HEADERS ${CMAKE_SOURCE_DIR}/src/algorithms/signal_source/adapters/uhd_signal_source.h) +endif(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) set(SIGNAL_SOURCE_ADAPTER_SOURCES file_signal_source.cc @@ -129,8 +135,6 @@ endif(ARCH_64BITS) add_definitions(-DGNSSSDR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}") -file(GLOB SIGNAL_SOURCE_ADAPTER_HEADERS "*.h") -list(SORT SIGNAL_SOURCE_ADAPTER_HEADERS) add_library(signal_source_adapters ${SIGNAL_SOURCE_ADAPTER_SOURCES} ${SIGNAL_SOURCE_ADAPTER_HEADERS}) source_group(Headers FILES ${SIGNAL_SOURCE_ADAPTER_HEADERS}) target_link_libraries(signal_source_adapters signal_source_gr_blocks @@ -140,4 +144,3 @@ target_link_libraries(signal_source_adapters signal_source_gr_blocks ${OPT_LIBRARIES} gnss_sp_libs ) - diff --git a/src/core/receiver/CMakeLists.txt b/src/core/receiver/CMakeLists.txt index e06c2c4f0..d25aae97a 100644 --- a/src/core/receiver/CMakeLists.txt +++ b/src/core/receiver/CMakeLists.txt @@ -79,7 +79,7 @@ include_directories( ${OPT_RECEIVER_INCLUDE_DIRS} ${VOLK_GNSSSDR_INCLUDE_DIRS} ) - + if(Boost_VERSION LESS 105000) add_definitions(-DOLD_BOOST=1) endif(Boost_VERSION LESS 105000) @@ -101,12 +101,14 @@ if(ENABLE_FLEXIBAND) endif(ENABLE_FLEXIBAND) if(ENABLE_OSMOSDR) - add_definitions(-DOSMOSDR_DRIVER=1) + if(GROSMOSDR_FOUND) + add_definitions(-DOSMOSDR_DRIVER=1) + endif(GROSMOSDR_FOUND) endif(ENABLE_OSMOSDR) -if(ENABLE_UHD) +if(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) add_definitions(-DUHD_DRIVER=1) -endif(ENABLE_UHD) +endif(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) #Enable OpenCL if found in the system if(OPENCL_FOUND) diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index 649727e82..6a8e42a1b 100644 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -28,10 +28,10 @@ if(ENABLE_GPERFTOOLS) endif(GPERFTOOLS_FOUND) endif(ENABLE_GPERFTOOLS) -if(ENABLE_UHD) +if(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) set(GNSS_SDR_OPTIONAL_LIBS ${GNSS_SDR_OPTIONAL_LIBS} ${UHD_LIBRARIES} ${GNURADIO_UHD_LIBRARIES}) set(GNSS_SDR_OPTIONAL_HEADERS ${GNSS_SDR_OPTIONAL_HEADERS} ${UHD_INCLUDE_DIRS}) -endif(ENABLE_UHD) +endif(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) if(OPENSSL_FOUND) add_definitions( -DUSE_OPENSSL_FALLBACK=1 ) @@ -130,18 +130,18 @@ if(NOT GZIP_NOTFOUND) WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_FILE "${CMAKE_BINARY_DIR}/gnss-sdr.1.gz") install(FILES ${CMAKE_BINARY_DIR}/gnss-sdr.1.gz DESTINATION share/man/man1) - + execute_process(COMMAND gzip -9 -c ${CMAKE_SOURCE_DIR}/docs/changelog WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_FILE "${CMAKE_BINARY_DIR}/changelog.gz") - + install(FILES ${CMAKE_BINARY_DIR}/changelog.gz DESTINATION share/doc/gnss-sdr) - + if(NOT VOLK_GNSSSDR_FOUND) execute_process(COMMAND gzip -9 -c ${CMAKE_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr_profile-manpage WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_FILE "${CMAKE_BINARY_DIR}/volk_gnsssdr_profile.1.gz") execute_process(COMMAND gzip -9 -c ${CMAKE_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr-config-info-manpage WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_FILE "${CMAKE_BINARY_DIR}/volk_gnsssdr-config-info.1.gz") - + install(FILES ${CMAKE_BINARY_DIR}/volk_gnsssdr_profile.1.gz DESTINATION share/man/man1) install(FILES ${CMAKE_BINARY_DIR}/volk_gnsssdr-config-info.1.gz DESTINATION share/man/man1) endif(NOT VOLK_GNSSSDR_FOUND)