Create a cmake API for O_RAN SC xran forked repo
* create the xran forked repo as a cmake external project - easier to maintain and track the changes we applied to the original repo * add xran_DOWNLOAD option - clones and builds latest supported K release * update the FHI README for K release Signed-off-by: Teodora Vladić <teodora.vladic@openairinterface.org>
This commit is contained in:
@@ -21,15 +21,54 @@ add_library(oran_fhlib_5g MODULE
|
||||
set(F_VERSION 6.1.9)
|
||||
set(K_VERSION 11.1.1)
|
||||
|
||||
find_package(xran REQUIRED)
|
||||
if(xran_VERSION VERSION_GREATER_EQUAL 5 AND xran_VERSION VERSION_LESS 6)
|
||||
message(FATAL_ERROR "xran E release not supported starting from tag 2026.w08.\nPlease switch to F version ${F_VERSION}")
|
||||
elseif(xran_VERSION VERSION_EQUAL F_VERSION)
|
||||
target_compile_definitions(oran_fhlib_5g PRIVATE F_RELEASE)
|
||||
elseif(xran_VERSION VERSION_EQUAL K_VERSION)
|
||||
add_boolean_option(xran_DOWNLOAD OFF "Download and build xran library" OFF)
|
||||
|
||||
find_package(xran)
|
||||
if(xran_FOUND)
|
||||
if(xran_VERSION VERSION_GREATER_EQUAL 5 AND xran_VERSION VERSION_LESS 6)
|
||||
message(FATAL_ERROR "xran E release not supported starting from tag 2026.w08.\nPlease switch to F version ${F_VERSION} or K version ${K_VERSION}")
|
||||
elseif(xran_VERSION VERSION_EQUAL F_VERSION)
|
||||
target_compile_definitions(oran_fhlib_5g PRIVATE F_RELEASE)
|
||||
elseif(xran_VERSION VERSION_EQUAL K_VERSION)
|
||||
if(dpdk_VERSION VERSION_LESS 22)
|
||||
message(FATAL_ERROR "DPDK version miniminum 22 required for K release, but found ${dpdk_VERSION}")
|
||||
endif()
|
||||
target_compile_definitions(oran_fhlib_5g PRIVATE K_RELEASE)
|
||||
else()
|
||||
message(FATAL_ERROR "Found xran version ${xran_VERSION} but needed ${F_VERSION} (F release) or ${K_VERSION} (K release)")
|
||||
endif()
|
||||
elseif(NOT xran_FOUND AND xran_DOWNLOAD)
|
||||
if(dpdk_VERSION VERSION_LESS 22)
|
||||
message(FATAL_ERROR "DPDK version miniminum 22 required for K release, but found ${dpdk_VERSION}")
|
||||
endif()
|
||||
include(ExternalProject)
|
||||
set(xran_DIR "${CMAKE_BINARY_DIR}/.deps/src/extern_xran/fhi_lib/lib")
|
||||
ExternalProject_Add(extern_xran
|
||||
PREFIX ${CMAKE_BINARY_DIR}/.deps
|
||||
GIT_REPOSITORY https://github.com/openairinterface/o-du-phy.git
|
||||
GIT_TAG ${K_VERSION}
|
||||
CONFIGURE_COMMAND "" # nothing to configure
|
||||
BUILD_COMMAND cd fhi_lib/lib && WIRELESS_SDK_TOOLCHAIN=gcc RTE_SDK=${dpdk_PREFIX} XRAN_DIR=.. make XRAN_LIB_SO=1
|
||||
BUILD_IN_SOURCE ON
|
||||
INSTALL_COMMAND ""
|
||||
BUILD_BYPRODUCTS ${xran_DIR}/build/libxran.so
|
||||
)
|
||||
add_library(xran::xran UNKNOWN IMPORTED)
|
||||
add_dependencies(xran::xran extern_xran)
|
||||
# This is a workaround for the fact that included directories of an imported
|
||||
# target should exist in the filesystem already at the configuration time.
|
||||
# ref: https://gitlab.kitware.com/cmake/cmake/-/issues/15052
|
||||
file(MAKE_DIRECTORY "${xran_DIR}/api/")
|
||||
file(MAKE_DIRECTORY "${xran_DIR}/build/")
|
||||
set_target_properties(xran::xran PROPERTIES
|
||||
IMPORTED_LOCATION "${xran_DIR}/build/libxran.so"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${xran_DIR}/api/"
|
||||
)
|
||||
message(STATUS "xran not found. Will clone and build automatically K release ${K_VERSION}")
|
||||
target_compile_definitions(oran_fhlib_5g PRIVATE K_RELEASE)
|
||||
else()
|
||||
message(FATAL_ERROR "Found xran version ${xran_VERSION} but needed ${F_VERSION} (F release) or ${K_VERSION} (K release)")
|
||||
message(FATAL_ERROR "could not find xran, and auto-download disabled. Update
|
||||
xran_LOCATION, or set -Dxran_DOWNLOAD=ON")
|
||||
endif()
|
||||
|
||||
# Ignore xran-specific warning: we don't care/can't change the following warning, so suppress
|
||||
|
||||
Reference in New Issue
Block a user