srsLTE/cmake/modules/FindUHD.cmake

148 lines
4.7 KiB
CMake
Raw Normal View History

#
2022-04-29 00:28:44 -07:00
# Copyright 2013-2022 Software Radio Systems Limited
#
2021-04-22 01:59:40 -07:00
# This file is part of srsRAN
2020-12-13 14:12:56 -08:00
#
2021-04-22 01:59:40 -07:00
# srsRAN is free software: you can redistribute it and/or modify
2020-12-13 14:12:56 -08:00
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
2021-04-22 01:59:40 -07:00
# srsRAN is distributed in the hope that it will be useful,
2020-12-13 14:12:56 -08:00
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# A copy of the GNU Affero General Public License can be found in
# the LICENSE file in the top-level directory of this distribution
# and at http://www.gnu.org/licenses/.
#
2021-02-13 09:32:23 -08:00
FIND_PACKAGE(PkgConfig REQUIRED)
#PKG_CHECK_MODULES(UHD uhd)
2014-01-28 03:41:17 -08:00
IF(NOT UHD_FOUND)
FIND_PATH(
UHD_INCLUDE_DIRS
2015-12-10 12:07:00 -08:00
NAMES uhd.h
2014-01-28 03:41:17 -08:00
HINTS $ENV{UHD_DIR}/include
PATHS /usr/local/include
/usr/include
)
FIND_LIBRARY(
UHD_LIBRARIES
NAMES uhd
HINTS $ENV{UHD_DIR}/lib
PATHS /usr/local/lib
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/local/lib64
/usr/local/lib32
2014-01-28 03:41:17 -08:00
)
message(STATUS "UHD LIBRARIES " ${UHD_LIBRARIES})
message(STATUS "UHD INCLUDE DIRS " ${UHD_INCLUDE_DIRS})
2014-01-28 03:41:17 -08:00
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(UHD DEFAULT_MSG UHD_LIBRARIES UHD_INCLUDE_DIRS)
MARK_AS_ADVANCED(UHD_LIBRARIES UHD_INCLUDE_DIRS)
2014-01-28 03:41:17 -08:00
include(CheckCXXSourceCompiles)
IF(UHD_FOUND)
# UHD library directory
get_filename_component(UHD_LIBRARY_DIR ${UHD_LIBRARIES} DIRECTORY)
# Save current required variables
set(_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
set(_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
# Set required variables
set(CMAKE_REQUIRED_INCLUDES ${UHD_INCLUDE_DIRS})
set(CMAKE_REQUIRED_FLAGS "${CMAKE_CXX_FLAGS} -L${UHD_LIBRARY_DIR}")
set(CMAKE_REQUIRED_LIBRARIES uhd boost_program_options boost_system)
2021-03-19 03:45:56 -07:00
# Checks whether the UHD driver supports X300 reset from srsRAN. This functionality requires changing the function
# `x300_make_ctrl_iface_enet` visibility in the file `uhd/host/lib/usrp/x300_fw_ctrl.cpp`. This can be accomplished
# adding the following line:
# `UHD_API wb_iface::sptr x300_make_ctrl_iface_enet(uhd::transport::udp_simple::sptr udp, bool enable_errors);`
check_cxx_source_compiles("#include <uhd.h>
#include <uhd/usrp/multi_usrp.hpp>
#include <uhd/transport/udp_simple.hpp>
uhd::wb_iface::sptr x300_make_ctrl_iface_enet(uhd::transport::udp_simple::sptr udp, bool enable_errors);
uhd_error try_usrp_x300_reset()
{
uhd::transport::udp_simple::sptr udp_simple = uhd::transport::udp_simple::make_connected(\"\", \"49152\");
uhd::wb_iface::sptr x300_ctrl = x300_make_ctrl_iface_enet(udp_simple, true);
x300_ctrl->poke32(0x100058, 1);
return UHD_ERROR_NONE;
}
int main(int argc, char** argv)
{
try_usrp_x300_reset();
return 0;
}" UHD_ENABLE_X300_FW_RESET)
# Checks whether the UHD driver supports X300 custom RF-NOC devices
check_cxx_source_compiles("#include <uhd.h>
#include <uhd/device3.hpp>
#include <uhd/rfnoc/ddc_block_ctrl.hpp>
2020-10-16 06:39:49 -07:00
#include <uhd/rfnoc/radio_ctrl.hpp>
static uhd::device3::sptr device3;
static uhd::rfnoc::ddc_block_ctrl::sptr ddc_ctrl;
2020-10-16 06:39:49 -07:00
static uhd::rfnoc::radio_ctrl::sptr radio_ctrl;
uhd_error try_device3_ddc_ctrl()
{
ddc_ctrl = device3->get_block_ctrl<uhd::rfnoc::ddc_block_ctrl>(uhd::rfnoc::block_id_t(\"DDC_0\"));
return UHD_ERROR_NONE;
}
2020-10-16 06:39:49 -07:00
uhd_error try_device3_radio_ctrl()
{
radio_ctrl = device3->get_block_ctrl<uhd::rfnoc::radio_ctrl>(uhd::rfnoc::block_id_t(\"Radio_0\"));
return UHD_ERROR_NONE;
}
int main(int argc, char** argv)
{
try_device3_ddc_ctrl();
2020-10-16 06:39:49 -07:00
try_device3_radio_ctrl();
return 0;
}" UHD_ENABLE_RFNOC)
# Checks whether the UHD driver supports X300 custom RF-NOC devices
check_cxx_source_compiles("#include <uhd.h>
#include <uhd/device3.hpp>
#include <uhd/rfnoc/ddc_ch2_block_ctrl.hpp>
static uhd::device3::sptr device3;
static uhd::rfnoc::ddc_ch2_block_ctrl::sptr ddc_ctrl;
uhd_error try_device3_ddc_ch2_ctrl()
{
ddc_ctrl = device3->get_block_ctrl<uhd::rfnoc::ddc_ch2_block_ctrl>(uhd::rfnoc::block_id_t(\"DDCch2_0\"));
return UHD_ERROR_NONE;
}
int main(int argc, char** argv)
{
try_device3_ddc_ch2_ctrl();
return 0;
}" UHD_ENABLE_CUSTOM_RFNOC)
# Recover required variables
set(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES})
ENDIF(UHD_FOUND)
2014-01-28 03:41:17 -08:00
ENDIF(NOT UHD_FOUND)