2014-03-03 11:09:26 -08:00
|
|
|
#
|
2020-03-13 04:12:52 -07:00
|
|
|
# Copyright 2013-2020 Software Radio Systems Limited
|
2014-03-03 11:09:26 -08:00
|
|
|
#
|
2020-11-26 01:25:22 -08:00
|
|
|
# By using this file, you agree to the terms and conditions set
|
|
|
|
# forth in the LICENSE file which can be found at the top level of
|
|
|
|
# the distribution.
|
2014-03-03 11:09:26 -08:00
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# Prevent in-tree builds
|
|
|
|
########################################################################
|
2014-01-28 03:41:17 -08:00
|
|
|
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
|
|
|
message(FATAL_ERROR "Prevented in-tree build. This is bad practice.")
|
|
|
|
endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
|
|
|
|
|
|
|
|
2014-03-03 11:09:26 -08:00
|
|
|
########################################################################
|
|
|
|
# Project setup
|
|
|
|
########################################################################
|
2017-05-30 10:14:41 -07:00
|
|
|
cmake_minimum_required(VERSION 2.6)
|
|
|
|
project( SRSLTE )
|
|
|
|
message( STATUS "CMAKE_SYSTEM: " ${CMAKE_SYSTEM} )
|
|
|
|
message( STATUS "CMAKE_SYSTEM_PROCESSOR: " ${CMAKE_SYSTEM_PROCESSOR} )
|
|
|
|
message( STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER} )
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2016-04-18 02:17:23 -07:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")
|
|
|
|
include(SRSLTEVersion) #sets version information
|
|
|
|
include(SRSLTEPackage) #setup cpack
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2014-03-08 03:46:19 -08:00
|
|
|
include(CTest)
|
2017-06-27 02:42:20 -07:00
|
|
|
|
2016-04-18 02:17:23 -07:00
|
|
|
configure_file(
|
2014-03-11 11:42:51 -07:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake"
|
|
|
|
IMMEDIATE @ONLY)
|
2014-03-08 03:46:19 -08:00
|
|
|
|
2017-06-02 07:21:26 -07:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
|
|
message(STATUS "Build type not specified: defaulting to Release.")
|
|
|
|
endif(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
|
|
|
|
|
2017-11-23 04:25:40 -08:00
|
|
|
# Generate CMake to include build information
|
|
|
|
configure_file(
|
2019-10-04 08:02:20 -07:00
|
|
|
${PROJECT_SOURCE_DIR}/cmake/modules/SRSLTEbuildinfo.cmake.in
|
2017-11-23 04:25:40 -08:00
|
|
|
${CMAKE_BINARY_DIR}/SRSLTEbuildinfo.cmake
|
|
|
|
)
|
|
|
|
|
2015-03-11 03:10:29 -07:00
|
|
|
########################################################################
|
|
|
|
# Options
|
|
|
|
########################################################################
|
2017-06-08 03:22:02 -07:00
|
|
|
option(ENABLE_SRSUE "Build srsUE application" ON)
|
|
|
|
option(ENABLE_SRSENB "Build srsENB application" ON)
|
2017-10-09 04:22:17 -07:00
|
|
|
option(ENABLE_SRSEPC "Build srsEPC application" ON)
|
2019-12-10 07:38:34 -08:00
|
|
|
option(ENABLE_5GNR "Build with 5G-NR components" OFF)
|
2020-09-02 01:17:13 -07:00
|
|
|
option(DISABLE_SIMD "Disable SIMD instructions" OFF)
|
2020-02-05 15:35:02 -08:00
|
|
|
option(AUTO_DETECT_ISA "Autodetect supported ISA extensions" ON)
|
2017-06-08 03:22:02 -07:00
|
|
|
|
|
|
|
option(ENABLE_GUI "Enable GUI (using srsGUI)" ON)
|
2018-07-10 03:02:04 -07:00
|
|
|
option(ENABLE_UHD "Enable UHD" ON)
|
2017-06-08 03:22:02 -07:00
|
|
|
option(ENABLE_BLADERF "Enable BladeRF" ON)
|
2018-06-21 11:42:28 -07:00
|
|
|
option(ENABLE_SOAPYSDR "Enable SoapySDR" ON)
|
2019-04-22 02:45:07 -07:00
|
|
|
option(ENABLE_ZEROMQ "Enable ZeroMQ" ON)
|
2018-07-10 03:02:04 -07:00
|
|
|
option(ENABLE_HARDSIM "Enable support for SIM cards" ON)
|
2017-06-08 03:22:02 -07:00
|
|
|
|
2019-09-16 12:17:21 -07:00
|
|
|
option(ENABLE_TTCN3 "Enable TTCN3 test binaries" OFF)
|
2020-02-27 12:39:09 -08:00
|
|
|
option(ENABLE_ZMQ_TEST "Enable ZMQ based E2E tests" OFF)
|
2019-09-16 12:17:21 -07:00
|
|
|
|
2017-06-08 03:22:02 -07:00
|
|
|
option(BUILD_STATIC "Attempt to statically link external deps" OFF)
|
|
|
|
option(RPATH "Enable RPATH" OFF)
|
2018-09-21 07:37:54 -07:00
|
|
|
option(ENABLE_ASAN "Enable gcc/clang address sanitizer" OFF)
|
2019-12-13 04:04:47 -08:00
|
|
|
option(ENABLE_GCOV "Enable gcc/clang address sanitizer" OFF)
|
2018-09-21 07:37:54 -07:00
|
|
|
option(ENABLE_MSAN "Enable clang memory sanitizer" OFF)
|
2018-12-13 02:06:57 -08:00
|
|
|
option(ENABLE_TIDY "Enable clang tidy" OFF)
|
2017-06-08 03:22:02 -07:00
|
|
|
|
2017-06-23 06:49:21 -07:00
|
|
|
option(USE_LTE_RATES "Use standard LTE sampling rates" OFF)
|
2019-11-28 02:59:24 -08:00
|
|
|
option(USE_MKL "Use MKL instead of fftw" OFF)
|
2017-05-30 10:14:41 -07:00
|
|
|
|
2020-03-18 16:00:33 -07:00
|
|
|
option(ENABLE_TIMEPROF "Enable time profiling" ON)
|
2020-03-15 15:52:39 -07:00
|
|
|
|
2019-12-19 10:07:08 -08:00
|
|
|
option(FORCE_32BIT "Add flags to force 32 bit compilation" OFF)
|
|
|
|
|
2020-09-02 00:21:56 -07:00
|
|
|
# Users that want to try this feature need to make sure the lto plugin is
|
|
|
|
# loaded by bintools (ar, nm, ...). Older versions of bintools will not do
|
|
|
|
# it automatically so it is necessary to use the gcc wrappers of the compiler
|
|
|
|
# (gcc-ar, gcc-nm, ...).
|
|
|
|
option(BUILD_WITH_LTO "Enable LTO (experimental)" OFF)
|
|
|
|
|
2019-11-06 03:11:26 -08:00
|
|
|
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
|
|
|
set(GCC_ARCH armv8-a CACHE STRING "GCC compile for specific architecture.")
|
|
|
|
message(STATUS "Detected aarch64 processor")
|
|
|
|
else(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
|
|
|
set(GCC_ARCH native CACHE STRING "GCC compile for specific architecture.")
|
|
|
|
endif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
2017-05-18 03:57:52 -07:00
|
|
|
|
2019-12-10 07:38:34 -08:00
|
|
|
if (ENABLE_5GNR)
|
|
|
|
add_definitions(-DHAVE_5GNR)
|
|
|
|
endif (ENABLE_5GNR)
|
|
|
|
|
2017-05-18 03:57:52 -07:00
|
|
|
########################################################################
|
|
|
|
# Find dependencies
|
|
|
|
########################################################################
|
2017-06-23 11:36:30 -07:00
|
|
|
|
2019-11-27 04:10:00 -08:00
|
|
|
# Enable ccache if not already enabled
|
|
|
|
find_program(CCACHE_EXECUTABLE ccache)
|
|
|
|
mark_as_advanced(CCACHE_EXECUTABLE)
|
|
|
|
if(CCACHE_EXECUTABLE)
|
|
|
|
foreach(LANG C CXX)
|
|
|
|
if(NOT DEFINED CMAKE_${LANG}_COMPILER_LAUNCHER AND NOT CMAKE_${LANG}_COMPILER MATCHES ".*/ccache$")
|
|
|
|
message(STATUS "Enabling ccache for ${LANG}")
|
|
|
|
set(CMAKE_${LANG}_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE} CACHE STRING "")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2017-06-23 11:36:30 -07:00
|
|
|
# Threads
|
2017-06-02 02:53:51 -07:00
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
2017-06-23 11:36:30 -07:00
|
|
|
# FFT
|
2019-11-28 02:59:24 -08:00
|
|
|
if(USE_MKL)
|
|
|
|
find_package(MKL REQUIRED)
|
2017-06-23 07:51:36 -07:00
|
|
|
include_directories(${MKL_INCLUDE_DIRS})
|
|
|
|
link_directories(${MKL_LIBRARY_DIRS})
|
2017-06-23 11:36:30 -07:00
|
|
|
set(FFT_LIBRARIES "${MKL_STATIC_LIBRARIES}") # Static by default
|
2019-11-28 02:59:24 -08:00
|
|
|
else(USE_MKL)
|
2017-06-23 07:51:36 -07:00
|
|
|
find_package(FFTW3F REQUIRED)
|
|
|
|
if(FFTW3F_FOUND)
|
|
|
|
include_directories(${FFTW3F_INCLUDE_DIRS})
|
|
|
|
link_directories(${FFTW3F_LIBRARY_DIRS})
|
2017-06-23 11:36:30 -07:00
|
|
|
if(BUILD_STATIC)
|
|
|
|
set(FFT_LIBRARIES "${FFTW3F_STATIC_LIBRARIES}")
|
|
|
|
else(BUILD_STATIC)
|
|
|
|
set(FFT_LIBRARIES "${FFTW3F_LIBRARIES}")
|
|
|
|
endif(BUILD_STATIC)
|
2017-11-21 04:56:29 -08:00
|
|
|
message(STATUS "FFT_LIBRARIES: " ${FFT_LIBRARIES})
|
2017-06-23 07:51:36 -07:00
|
|
|
endif(FFTW3F_FOUND)
|
2019-11-28 02:59:24 -08:00
|
|
|
endif(USE_MKL)
|
2017-06-23 07:51:36 -07:00
|
|
|
|
2017-06-23 11:36:30 -07:00
|
|
|
# Crypto
|
2017-05-18 03:57:52 -07:00
|
|
|
find_package(Polarssl)
|
|
|
|
if (POLARSSL_FOUND)
|
2017-06-02 07:59:03 -07:00
|
|
|
set(SEC_INCLUDE_DIRS "${POLARSSL_INCLUDE_DIRS}")
|
2017-06-23 06:49:21 -07:00
|
|
|
if(BUILD_STATIC)
|
|
|
|
set(SEC_LIBRARIES "${POLARSSL_STATIC_LIBRARIES}")
|
|
|
|
else(BUILD_STATIC)
|
|
|
|
set(SEC_LIBRARIES "${POLARSSL_LIBRARIES}")
|
|
|
|
endif(BUILD_STATIC)
|
2017-05-18 03:57:52 -07:00
|
|
|
add_definitions(-DHAVE_POLARSSL)
|
|
|
|
else(POLARSSL_FOUND)
|
2017-06-02 07:59:03 -07:00
|
|
|
find_package(MbedTLS REQUIRED)
|
2017-05-18 03:57:52 -07:00
|
|
|
if (MBEDTLS_FOUND)
|
2017-06-02 07:59:03 -07:00
|
|
|
set(SEC_INCLUDE_DIRS "${MBEDTLS_INCLUDE_DIRS}")
|
2017-06-23 06:49:21 -07:00
|
|
|
if(BUILD_STATIC)
|
|
|
|
set(SEC_LIBRARIES "${MBEDTLS_STATIC_LIBRARIES}")
|
|
|
|
else(BUILD_STATIC)
|
|
|
|
set(SEC_LIBRARIES "${MBEDTLS_LIBRARIES}")
|
|
|
|
endif(BUILD_STATIC)
|
2017-05-18 03:57:52 -07:00
|
|
|
add_definitions(-DHAVE_MBEDTLS)
|
2017-09-01 04:29:11 -07:00
|
|
|
else(MBEDTLS_FOUND)
|
|
|
|
message(FATAL_ERROR "Either PolarSSL or mbedTLS are required to build srsLTE")
|
2017-05-18 03:57:52 -07:00
|
|
|
endif (MBEDTLS_FOUND)
|
|
|
|
endif(POLARSSL_FOUND)
|
|
|
|
|
2018-04-04 02:53:36 -07:00
|
|
|
# Hard-SIM support
|
2018-07-10 03:02:04 -07:00
|
|
|
if(ENABLE_HARDSIM)
|
|
|
|
find_package(PCSCLite)
|
|
|
|
if (PCSCLITE_FOUND)
|
|
|
|
message(STATUS "Building with PCSC support.")
|
|
|
|
add_definitions(-DHAVE_PCSC)
|
|
|
|
set(HAVE_PCSC TRUE)
|
|
|
|
include_directories(${PCSCLITE_INCLUDE_DIR})
|
|
|
|
#link_directories(${PCSCLITE_LIBRARIES})
|
|
|
|
endif (PCSCLITE_FOUND)
|
|
|
|
endif(ENABLE_HARDSIM)
|
2018-04-04 02:53:36 -07:00
|
|
|
|
2017-06-23 11:36:30 -07:00
|
|
|
# UHD
|
2018-07-10 03:02:04 -07:00
|
|
|
if(ENABLE_UHD)
|
|
|
|
find_package(UHD)
|
|
|
|
if(UHD_FOUND)
|
|
|
|
include_directories(${UHD_INCLUDE_DIRS})
|
|
|
|
link_directories(${UHD_LIBRARY_DIRS})
|
|
|
|
endif(UHD_FOUND)
|
|
|
|
endif(ENABLE_UHD)
|
2017-05-30 06:10:19 -07:00
|
|
|
|
2017-06-23 11:36:30 -07:00
|
|
|
# BladeRF
|
2017-06-02 07:21:26 -07:00
|
|
|
if(ENABLE_BLADERF)
|
2017-05-30 06:10:19 -07:00
|
|
|
find_package(bladeRF)
|
|
|
|
if(BLADERF_FOUND)
|
|
|
|
include_directories(${BLADERF_INCLUDE_DIRS})
|
|
|
|
link_directories(${BLADERF_LIBRARY_DIRS})
|
|
|
|
endif(BLADERF_FOUND)
|
2017-06-02 07:21:26 -07:00
|
|
|
endif(ENABLE_BLADERF)
|
2017-05-30 06:10:19 -07:00
|
|
|
|
2017-06-23 11:36:30 -07:00
|
|
|
# Soapy
|
2018-06-21 11:42:28 -07:00
|
|
|
if(ENABLE_SOAPYSDR)
|
|
|
|
find_package(SoapySDR)
|
|
|
|
if(SOAPYSDR_FOUND)
|
|
|
|
include_directories(${SOAPYSDR_INCLUDE_DIRS})
|
|
|
|
link_directories(${SOAPYSDR_LIBRARY_DIRS})
|
|
|
|
endif(SOAPYSDR_FOUND)
|
|
|
|
endif(ENABLE_SOAPYSDR)
|
2017-05-30 06:10:19 -07:00
|
|
|
|
2019-04-22 02:45:07 -07:00
|
|
|
# ZeroMQ
|
|
|
|
if(ENABLE_ZEROMQ)
|
|
|
|
find_package(ZeroMQ)
|
|
|
|
if(ZEROMQ_FOUND)
|
|
|
|
include_directories(${ZEROMQ_INCLUDE_DIRS})
|
|
|
|
link_directories(${ZEROMQ_LIBRARY_DIRS})
|
|
|
|
endif(ZEROMQ_FOUND)
|
|
|
|
endif(ENABLE_ZEROMQ)
|
|
|
|
|
2020-03-15 15:52:39 -07:00
|
|
|
# TimeProf
|
|
|
|
if(ENABLE_TIMEPROF)
|
|
|
|
add_definitions(-DENABLE_TIMEPROF)
|
|
|
|
endif(ENABLE_TIMEPROF)
|
|
|
|
|
2019-04-22 02:45:07 -07:00
|
|
|
if(BLADERF_FOUND OR UHD_FOUND OR SOAPYSDR_FOUND OR ZEROMQ_FOUND)
|
2017-05-30 06:10:19 -07:00
|
|
|
set(RF_FOUND TRUE CACHE INTERNAL "RF frontend found")
|
2019-04-22 02:45:07 -07:00
|
|
|
else(BLADERF_FOUND OR UHD_FOUND OR SOAPYSDR_FOUND OR ZEROMQ_FOUND)
|
2017-05-30 06:10:19 -07:00
|
|
|
set(RF_FOUND FALSE CACHE INTERNAL "RF frontend found")
|
|
|
|
add_definitions(-DDISABLE_RF)
|
2019-04-22 02:45:07 -07:00
|
|
|
endif(BLADERF_FOUND OR UHD_FOUND OR SOAPYSDR_FOUND OR ZEROMQ_FOUND)
|
2017-05-30 06:10:19 -07:00
|
|
|
|
2017-06-23 11:36:30 -07:00
|
|
|
# Boost
|
2019-10-04 08:02:20 -07:00
|
|
|
if(BUILD_STATIC)
|
|
|
|
set(Boost_USE_STATIC_LIBS ON)
|
|
|
|
endif(BUILD_STATIC)
|
|
|
|
|
|
|
|
set(BOOST_REQUIRED_COMPONENTS
|
|
|
|
program_options
|
|
|
|
)
|
|
|
|
if(UNIX AND EXISTS "/usr/lib64")
|
|
|
|
list(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix
|
|
|
|
endif(UNIX AND EXISTS "/usr/lib64")
|
|
|
|
set(Boost_ADDITIONAL_VERSIONS
|
|
|
|
"1.35.0" "1.35" "1.36.0" "1.36" "1.37.0" "1.37" "1.38.0" "1.38" "1.39.0" "1.39"
|
|
|
|
"1.40.0" "1.40" "1.41.0" "1.41" "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44"
|
|
|
|
"1.45.0" "1.45" "1.46.0" "1.46" "1.47.0" "1.47" "1.48.0" "1.48" "1.49.0" "1.49"
|
|
|
|
"1.50.0" "1.50" "1.51.0" "1.51" "1.52.0" "1.52" "1.53.0" "1.53" "1.54.0" "1.54"
|
|
|
|
"1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59"
|
|
|
|
"1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64"
|
|
|
|
"1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69"
|
|
|
|
)
|
|
|
|
find_package(Boost "1.35" COMPONENTS ${BOOST_REQUIRED_COMPONENTS})
|
2017-06-23 06:49:21 -07:00
|
|
|
|
2019-10-04 08:02:20 -07:00
|
|
|
if(Boost_FOUND)
|
|
|
|
include_directories(${Boost_INCLUDE_DIRS})
|
|
|
|
link_directories(${Boost_LIBRARY_DIRS})
|
|
|
|
else(Boost_FOUND)
|
|
|
|
message(FATAL_ERROR "Boost required to build srsLTE")
|
|
|
|
endif (Boost_FOUND)
|
2017-05-30 06:10:19 -07:00
|
|
|
|
2017-06-23 11:36:30 -07:00
|
|
|
# srsGUI
|
2017-05-30 06:10:19 -07:00
|
|
|
if(ENABLE_GUI)
|
2017-05-31 13:18:07 -07:00
|
|
|
find_package(SRSGUI)
|
|
|
|
if(SRSGUI_FOUND)
|
|
|
|
add_definitions(-DENABLE_GUI)
|
|
|
|
include_directories(${SRSGUI_INCLUDE_DIRS})
|
|
|
|
link_directories(${SRSGUI_LIBRARY_DIRS})
|
|
|
|
endif(SRSGUI_FOUND)
|
2017-05-30 06:10:19 -07:00
|
|
|
endif(ENABLE_GUI)
|
|
|
|
|
2019-09-16 12:17:21 -07:00
|
|
|
if (ENABLE_TTCN3)
|
|
|
|
find_package(RapidJSON REQUIRED)
|
|
|
|
add_definitions(-DENABLE_TTCN3)
|
|
|
|
include_directories(${RAPIDJSON_INCLUDE_DIRS})
|
|
|
|
link_directories(${RAPIDJSON_LIBRARY_DIRS})
|
|
|
|
message(STATUS "Building with TTCN3 binaries")
|
|
|
|
endif (ENABLE_TTCN3)
|
|
|
|
|
2014-03-03 11:09:26 -08:00
|
|
|
########################################################################
|
|
|
|
# Install Dirs
|
|
|
|
########################################################################
|
2016-01-06 07:54:46 -08:00
|
|
|
if (NOT CMAKE_INSTALL_LIBDIR)
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
endif (NOT CMAKE_INSTALL_LIBDIR)
|
|
|
|
|
|
|
|
# Fall back to just "lib" if the item provided by GNUInstallDirs doesn't exist
|
|
|
|
if (NOT EXISTS "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
|
|
|
message(STATUS "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} does not exist. Defaulting install location to ${CMAKE_INSTALL_PREFIX}/lib.")
|
|
|
|
set(CMAKE_INSTALL_LIBDIR lib)
|
|
|
|
endif()
|
|
|
|
|
2016-04-18 02:17:23 -07:00
|
|
|
set(RUNTIME_DIR bin)
|
|
|
|
set(LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR})
|
|
|
|
set(INCLUDE_DIR include)
|
|
|
|
set(DOC_DIR "share/doc/${CPACK_PACKAGE_NAME}")
|
|
|
|
set(DATA_DIR share/${CPACK_PACKAGE_NAME})
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2018-06-05 02:34:01 -07:00
|
|
|
# Auto-generate config install helper and mark for installation
|
|
|
|
configure_file(
|
2019-10-04 08:02:20 -07:00
|
|
|
${PROJECT_SOURCE_DIR}/cmake/modules/SRSLTE_install_configs.sh.in
|
2018-06-05 02:34:01 -07:00
|
|
|
${CMAKE_BINARY_DIR}/srslte_install_configs.sh
|
|
|
|
)
|
|
|
|
install(PROGRAMS ${CMAKE_BINARY_DIR}/srslte_install_configs.sh DESTINATION ${RUNTIME_DIR})
|
|
|
|
|
2020-04-27 02:07:56 -07:00
|
|
|
# Disables the project to build when calling "make install"
|
|
|
|
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)
|
|
|
|
|
2014-03-03 11:09:26 -08:00
|
|
|
########################################################################
|
|
|
|
# Compiler specific setup
|
|
|
|
########################################################################
|
2014-06-13 04:42:29 -07:00
|
|
|
macro(ADD_CXX_COMPILER_FLAG_IF_AVAILABLE flag have)
|
|
|
|
include(CheckCXXCompilerFlag)
|
2016-04-18 02:17:23 -07:00
|
|
|
check_cxx_compiler_flag(${flag} ${have})
|
2014-06-13 04:42:29 -07:00
|
|
|
if(${have})
|
build: fix ADD_CXX_COMPILER_FLAG_IF_AVAILABLE usages
This patch solves two different issues at the same time when building
with gcc/g++ 9.2.0:
1) The -fvisibility=hidden support check was done using the C++
compiler only (with check_cxx_compiler_flag), inside the block
corresponding to the C compiler being GNU/clang, and the result of
the check was applied to both C++ (CXX_FLAGS) and C (C_FLAGS) flags.
Instead of this, there should be separate checks for the C and C++
compilers, each of them modifying a single set of <LANG>_FLAGS.
2) -Wincompatible-pointer-types support check was done using the C++
compiler only, and the result of the check was applied to both C++
(CXX_FLAGS) and C (C_FLAGS) flags. But, this warning is not
applicable to C++ and actually breaks compilation when using g++ 9.2:
[ 0%] Building CXX object lib/src/asn1/CMakeFiles/rrc_asn1.dir/rrc_asn1.cc.o
cc1plus: error: ‘-Werror=’ argument ‘-Werror=incompatible-pointer-types’ is not valid for C++ [-Werror]
Instead of this, there should be a check for this warning only using
the C compiler, and therefore only modifying the C flags (C_FLAGS).
This patch splits the macro into one specific for C++ (which modifies
CXX_FLAGS) and one specific for C (which modifies C_FLAGS). And so,
the macro call to check for `-Werror=incompatible-pointer-types' is
made C-only, and the one for `-fvisibility=hidden` is done for both C
and C++ targets (each on the correct GNU/clang compiler block).
Due to how the tests are done in cmake, the '-fvisibility=hidden'
check wasn't even succeding before, so the compiler option wasn't
being effectively used. The cmake flags.make file contents throughout
the project are updated as follows now:
Before this change, we had:
C_FLAGS = -Werror=incompatible-pointer-types ...
CXX_FLAGS = -Werror=incompatible-pointer-types ...
And after this change, we have:
C_FLAGS = -Werror=incompatible-pointer-types -fvisibility=hidden ...
CXX_FLAGS = -fvisibility=hidden ...
2019-10-21 07:41:07 -07:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
|
2014-06-13 04:42:29 -07:00
|
|
|
endif(${have})
|
|
|
|
endmacro(ADD_CXX_COMPILER_FLAG_IF_AVAILABLE)
|
|
|
|
|
build: fix ADD_CXX_COMPILER_FLAG_IF_AVAILABLE usages
This patch solves two different issues at the same time when building
with gcc/g++ 9.2.0:
1) The -fvisibility=hidden support check was done using the C++
compiler only (with check_cxx_compiler_flag), inside the block
corresponding to the C compiler being GNU/clang, and the result of
the check was applied to both C++ (CXX_FLAGS) and C (C_FLAGS) flags.
Instead of this, there should be separate checks for the C and C++
compilers, each of them modifying a single set of <LANG>_FLAGS.
2) -Wincompatible-pointer-types support check was done using the C++
compiler only, and the result of the check was applied to both C++
(CXX_FLAGS) and C (C_FLAGS) flags. But, this warning is not
applicable to C++ and actually breaks compilation when using g++ 9.2:
[ 0%] Building CXX object lib/src/asn1/CMakeFiles/rrc_asn1.dir/rrc_asn1.cc.o
cc1plus: error: ‘-Werror=’ argument ‘-Werror=incompatible-pointer-types’ is not valid for C++ [-Werror]
Instead of this, there should be a check for this warning only using
the C compiler, and therefore only modifying the C flags (C_FLAGS).
This patch splits the macro into one specific for C++ (which modifies
CXX_FLAGS) and one specific for C (which modifies C_FLAGS). And so,
the macro call to check for `-Werror=incompatible-pointer-types' is
made C-only, and the one for `-fvisibility=hidden` is done for both C
and C++ targets (each on the correct GNU/clang compiler block).
Due to how the tests are done in cmake, the '-fvisibility=hidden'
check wasn't even succeding before, so the compiler option wasn't
being effectively used. The cmake flags.make file contents throughout
the project are updated as follows now:
Before this change, we had:
C_FLAGS = -Werror=incompatible-pointer-types ...
CXX_FLAGS = -Werror=incompatible-pointer-types ...
And after this change, we have:
C_FLAGS = -Werror=incompatible-pointer-types -fvisibility=hidden ...
CXX_FLAGS = -fvisibility=hidden ...
2019-10-21 07:41:07 -07:00
|
|
|
macro(ADD_C_COMPILER_FLAG_IF_AVAILABLE flag have)
|
|
|
|
include(CheckCCompilerFlag)
|
|
|
|
check_c_compiler_flag(${flag} ${have})
|
|
|
|
if(${have})
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
|
|
|
|
endif(${have})
|
|
|
|
endmacro(ADD_C_COMPILER_FLAG_IF_AVAILABLE)
|
|
|
|
|
2017-06-02 06:37:46 -07:00
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
2020-05-07 07:54:26 -07:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-comment -Wno-reorder -Wno-unused-variable -Wtype-limits -std=c++11 -fno-strict-aliasing")
|
2019-10-29 14:29:41 -07:00
|
|
|
|
|
|
|
ADD_C_COMPILER_FLAG_IF_AVAILABLE("-Wno-unused-but-set-variable" HAVE_WNO_UNUSED_BUT_SET_VARIABLE)
|
|
|
|
ADD_CXX_COMPILER_FLAG_IF_AVAILABLE("-Wno-unused-but-set-variable" HAVE_WNO_UNUSED_BUT_SET_VARIABLE)
|
2017-01-16 08:23:10 -08:00
|
|
|
|
2020-02-05 15:35:02 -08:00
|
|
|
if (AUTO_DETECT_ISA)
|
|
|
|
find_package(SSE)
|
|
|
|
endif (AUTO_DETECT_ISA)
|
|
|
|
|
2017-06-02 06:37:46 -07:00
|
|
|
if (HAVE_AVX2)
|
2018-12-12 05:34:13 -08:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${GCC_ARCH} -mfpmath=sse -mavx2 -DLV_HAVE_AVX2 -DLV_HAVE_AVX -DLV_HAVE_SSE")
|
2017-06-02 06:37:46 -07:00
|
|
|
else (HAVE_AVX2)
|
2016-10-27 08:27:59 -07:00
|
|
|
if(HAVE_AVX)
|
2018-12-12 05:34:13 -08:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${GCC_ARCH} -mfpmath=sse -mavx -DLV_HAVE_AVX -DLV_HAVE_SSE")
|
2016-10-27 08:27:59 -07:00
|
|
|
elseif(HAVE_SSE)
|
2018-12-12 05:34:13 -08:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${GCC_ARCH} -mfpmath=sse -msse4.1 -DLV_HAVE_SSE")
|
2016-10-27 08:27:59 -07:00
|
|
|
endif(HAVE_AVX)
|
2017-06-02 06:37:46 -07:00
|
|
|
endif (HAVE_AVX2)
|
build: fix ADD_CXX_COMPILER_FLAG_IF_AVAILABLE usages
This patch solves two different issues at the same time when building
with gcc/g++ 9.2.0:
1) The -fvisibility=hidden support check was done using the C++
compiler only (with check_cxx_compiler_flag), inside the block
corresponding to the C compiler being GNU/clang, and the result of
the check was applied to both C++ (CXX_FLAGS) and C (C_FLAGS) flags.
Instead of this, there should be separate checks for the C and C++
compilers, each of them modifying a single set of <LANG>_FLAGS.
2) -Wincompatible-pointer-types support check was done using the C++
compiler only, and the result of the check was applied to both C++
(CXX_FLAGS) and C (C_FLAGS) flags. But, this warning is not
applicable to C++ and actually breaks compilation when using g++ 9.2:
[ 0%] Building CXX object lib/src/asn1/CMakeFiles/rrc_asn1.dir/rrc_asn1.cc.o
cc1plus: error: ‘-Werror=’ argument ‘-Werror=incompatible-pointer-types’ is not valid for C++ [-Werror]
Instead of this, there should be a check for this warning only using
the C compiler, and therefore only modifying the C flags (C_FLAGS).
This patch splits the macro into one specific for C++ (which modifies
CXX_FLAGS) and one specific for C (which modifies C_FLAGS). And so,
the macro call to check for `-Werror=incompatible-pointer-types' is
made C-only, and the one for `-fvisibility=hidden` is done for both C
and C++ targets (each on the correct GNU/clang compiler block).
Due to how the tests are done in cmake, the '-fvisibility=hidden'
check wasn't even succeding before, so the compiler option wasn't
being effectively used. The cmake flags.make file contents throughout
the project are updated as follows now:
Before this change, we had:
C_FLAGS = -Werror=incompatible-pointer-types ...
CXX_FLAGS = -Werror=incompatible-pointer-types ...
And after this change, we have:
C_FLAGS = -Werror=incompatible-pointer-types -fvisibility=hidden ...
CXX_FLAGS = -fvisibility=hidden ...
2019-10-21 07:41:07 -07:00
|
|
|
|
|
|
|
if(NOT WIN32)
|
|
|
|
ADD_CXX_COMPILER_FLAG_IF_AVAILABLE(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_CXX)
|
|
|
|
endif(NOT WIN32)
|
2019-12-19 10:07:08 -08:00
|
|
|
|
|
|
|
if(FORCE_32BIT)
|
|
|
|
ADD_C_COMPILER_FLAG_IF_AVAILABLE("-m32" HAVE_WNO_UNUSED_BUT_SET_VARIABLE)
|
|
|
|
ADD_CXX_COMPILER_FLAG_IF_AVAILABLE("-m32" HAVE_WNO_UNUSED_BUT_SET_VARIABLE)
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "-m32")
|
|
|
|
endif(FORCE_32BIT)
|
|
|
|
|
2017-06-02 06:37:46 -07:00
|
|
|
endif(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
|
|
|
build: fix ADD_CXX_COMPILER_FLAG_IF_AVAILABLE usages
This patch solves two different issues at the same time when building
with gcc/g++ 9.2.0:
1) The -fvisibility=hidden support check was done using the C++
compiler only (with check_cxx_compiler_flag), inside the block
corresponding to the C compiler being GNU/clang, and the result of
the check was applied to both C++ (CXX_FLAGS) and C (C_FLAGS) flags.
Instead of this, there should be separate checks for the C and C++
compilers, each of them modifying a single set of <LANG>_FLAGS.
2) -Wincompatible-pointer-types support check was done using the C++
compiler only, and the result of the check was applied to both C++
(CXX_FLAGS) and C (C_FLAGS) flags. But, this warning is not
applicable to C++ and actually breaks compilation when using g++ 9.2:
[ 0%] Building CXX object lib/src/asn1/CMakeFiles/rrc_asn1.dir/rrc_asn1.cc.o
cc1plus: error: ‘-Werror=’ argument ‘-Werror=incompatible-pointer-types’ is not valid for C++ [-Werror]
Instead of this, there should be a check for this warning only using
the C compiler, and therefore only modifying the C flags (C_FLAGS).
This patch splits the macro into one specific for C++ (which modifies
CXX_FLAGS) and one specific for C (which modifies C_FLAGS). And so,
the macro call to check for `-Werror=incompatible-pointer-types' is
made C-only, and the one for `-fvisibility=hidden` is done for both C
and C++ targets (each on the correct GNU/clang compiler block).
Due to how the tests are done in cmake, the '-fvisibility=hidden'
check wasn't even succeding before, so the compiler option wasn't
being effectively used. The cmake flags.make file contents throughout
the project are updated as follows now:
Before this change, we had:
C_FLAGS = -Werror=incompatible-pointer-types ...
CXX_FLAGS = -Werror=incompatible-pointer-types ...
And after this change, we have:
C_FLAGS = -Werror=incompatible-pointer-types -fvisibility=hidden ...
CXX_FLAGS = -fvisibility=hidden ...
2019-10-21 07:41:07 -07:00
|
|
|
ADD_C_COMPILER_FLAG_IF_AVAILABLE("-Werror=incompatible-pointer-types" HAVE_ERROR_INCOMPATIBLE)
|
2017-06-02 06:37:46 -07:00
|
|
|
|
|
|
|
if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
2020-11-19 03:23:02 -08:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-comment -Wno-write-strings -Wno-unused-result -Wformat -Wmissing-field-initializers -Wtype-limits -std=c99 -fno-strict-aliasing -D_GNU_SOURCE")
|
2017-06-02 06:37:46 -07:00
|
|
|
|
|
|
|
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
2018-03-19 05:21:36 -07:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb -O0 -DDEBUG_MODE -DBUILD_TYPE_DEBUG")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -O0 -DDEBUG_MODE -DBUILD_TYPE_DEBUG")
|
2016-04-18 02:17:23 -07:00
|
|
|
else(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
2018-03-14 13:19:02 -07:00
|
|
|
if(${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
|
2018-03-19 05:21:36 -07:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb -DBUILD_TYPE_RELWITHDEBINFO")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -DBUILD_TYPE_RELWITHDEBINFO")
|
2018-03-14 13:19:02 -07:00
|
|
|
else(${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
|
2018-09-04 08:51:35 -07:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -fno-trapping-math -fno-math-errno -DBUILD_TYPE_RELEASE")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fno-trapping-math -fno-math-errno -DBUILD_TYPE_RELEASE")
|
2020-09-02 00:21:56 -07:00
|
|
|
if(BUILD_WITH_LTO)
|
|
|
|
ADD_C_COMPILER_FLAG_IF_AVAILABLE(-flto HAVE_FLTO)
|
|
|
|
ADD_CXX_COMPILER_FLAG_IF_AVAILABLE(-flto HAVE_FLTO)
|
|
|
|
endif(BUILD_WITH_LTO)
|
2018-03-14 13:19:02 -07:00
|
|
|
endif(${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
|
2016-04-18 02:17:23 -07:00
|
|
|
endif(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
2017-06-02 06:37:46 -07:00
|
|
|
|
2017-06-07 03:39:00 -07:00
|
|
|
if (USE_LTE_RATES)
|
|
|
|
message(STATUS "Using standard LTE sampling rates")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFORCE_STANDARD_RATE")
|
|
|
|
endif (USE_LTE_RATES)
|
|
|
|
|
2020-02-05 15:35:02 -08:00
|
|
|
if (AUTO_DETECT_ISA)
|
|
|
|
find_package(SSE)
|
|
|
|
endif (AUTO_DETECT_ISA)
|
2017-06-02 06:37:46 -07:00
|
|
|
if (HAVE_AVX2)
|
2018-12-12 05:34:13 -08:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=${GCC_ARCH} -mfpmath=sse -mavx2 -DLV_HAVE_AVX2 -DLV_HAVE_AVX -DLV_HAVE_SSE")
|
2017-06-02 06:37:46 -07:00
|
|
|
else (HAVE_AVX2)
|
|
|
|
if(HAVE_AVX)
|
2018-12-12 05:34:13 -08:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=${GCC_ARCH} -mfpmath=sse -mavx -DLV_HAVE_AVX -DLV_HAVE_SSE")
|
2017-06-02 06:37:46 -07:00
|
|
|
elseif(HAVE_SSE)
|
2018-12-12 05:34:13 -08:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=${GCC_ARCH} -mfpmath=sse -msse4.1 -DLV_HAVE_SSE")
|
2017-06-02 06:37:46 -07:00
|
|
|
endif(HAVE_AVX)
|
|
|
|
endif (HAVE_AVX2)
|
|
|
|
|
2018-05-25 07:05:59 -07:00
|
|
|
if (HAVE_FMA)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfma -DLV_HAVE_FMA")
|
|
|
|
endif (HAVE_FMA)
|
|
|
|
|
2017-09-25 04:07:01 -07:00
|
|
|
if (HAVE_AVX512)
|
2020-11-18 02:02:14 -08:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx512f -mavx512cd -mavx512bw -mavx512dq -DLV_HAVE_AVX512")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx512f -mavx512cd -mavx512bw -mavx512dq -DLV_HAVE_AVX512")
|
2017-09-25 04:07:01 -07:00
|
|
|
endif(HAVE_AVX512)
|
|
|
|
|
2017-06-02 06:37:46 -07:00
|
|
|
if(NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
|
|
|
if(HAVE_SSE)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Ofast -funroll-loops")
|
|
|
|
endif(HAVE_SSE)
|
|
|
|
endif(NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
|
|
|
|
2019-11-06 03:11:26 -08:00
|
|
|
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DIS_ARM -DHAVE_NEON")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIS_ARM")
|
2019-12-20 05:13:28 -08:00
|
|
|
message(STATUS "Detected ARM processor")
|
|
|
|
set(HAVE_NEON "True")
|
2019-11-06 03:11:26 -08:00
|
|
|
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
|
|
|
set(HAVE_NEONv8 "True")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_NEONv8")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_NEONv8")
|
|
|
|
endif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
|
|
|
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard -mfpu=neon")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfloat-abi=hard -mfpu=neon")
|
|
|
|
endif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
|
|
|
|
else(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
2017-12-13 14:11:25 -08:00
|
|
|
set(HAVE_NEON "False")
|
2019-11-06 03:11:26 -08:00
|
|
|
endif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
2017-05-30 10:14:41 -07:00
|
|
|
set(CMAKE_REQUIRED_FLAGS ${CMAKE_C_FLAGS})
|
2017-02-15 03:47:45 -08:00
|
|
|
|
2018-09-04 08:51:35 -07:00
|
|
|
if(NOT HAVE_SSE AND NOT HAVE_NEON AND NOT DISABLE_SIMD)
|
|
|
|
message(FATAL_ERROR "no SIMD instructions found")
|
|
|
|
endif(NOT HAVE_SSE AND NOT HAVE_NEON AND NOT DISABLE_SIMD)
|
2017-12-13 14:11:25 -08:00
|
|
|
|
2016-04-18 02:17:23 -07:00
|
|
|
if(NOT WIN32)
|
build: fix ADD_CXX_COMPILER_FLAG_IF_AVAILABLE usages
This patch solves two different issues at the same time when building
with gcc/g++ 9.2.0:
1) The -fvisibility=hidden support check was done using the C++
compiler only (with check_cxx_compiler_flag), inside the block
corresponding to the C compiler being GNU/clang, and the result of
the check was applied to both C++ (CXX_FLAGS) and C (C_FLAGS) flags.
Instead of this, there should be separate checks for the C and C++
compilers, each of them modifying a single set of <LANG>_FLAGS.
2) -Wincompatible-pointer-types support check was done using the C++
compiler only, and the result of the check was applied to both C++
(CXX_FLAGS) and C (C_FLAGS) flags. But, this warning is not
applicable to C++ and actually breaks compilation when using g++ 9.2:
[ 0%] Building CXX object lib/src/asn1/CMakeFiles/rrc_asn1.dir/rrc_asn1.cc.o
cc1plus: error: ‘-Werror=’ argument ‘-Werror=incompatible-pointer-types’ is not valid for C++ [-Werror]
Instead of this, there should be a check for this warning only using
the C compiler, and therefore only modifying the C flags (C_FLAGS).
This patch splits the macro into one specific for C++ (which modifies
CXX_FLAGS) and one specific for C (which modifies C_FLAGS). And so,
the macro call to check for `-Werror=incompatible-pointer-types' is
made C-only, and the one for `-fvisibility=hidden` is done for both C
and C++ targets (each on the correct GNU/clang compiler block).
Due to how the tests are done in cmake, the '-fvisibility=hidden'
check wasn't even succeding before, so the compiler option wasn't
being effectively used. The cmake flags.make file contents throughout
the project are updated as follows now:
Before this change, we had:
C_FLAGS = -Werror=incompatible-pointer-types ...
CXX_FLAGS = -Werror=incompatible-pointer-types ...
And after this change, we have:
C_FLAGS = -Werror=incompatible-pointer-types -fvisibility=hidden ...
CXX_FLAGS = -fvisibility=hidden ...
2019-10-21 07:41:07 -07:00
|
|
|
ADD_C_COMPILER_FLAG_IF_AVAILABLE(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_C)
|
2016-04-18 02:17:23 -07:00
|
|
|
endif(NOT WIN32)
|
2018-09-21 07:37:54 -07:00
|
|
|
|
|
|
|
if (ENABLE_ASAN AND ENABLE_MSAN)
|
|
|
|
message(FATAL_ERROR "ASAN and MSAN cannot be enabled at the same time.")
|
|
|
|
endif (ENABLE_ASAN AND ENABLE_MSAN)
|
|
|
|
|
|
|
|
if (ENABLE_ASAN)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
|
|
|
|
endif (ENABLE_ASAN)
|
|
|
|
|
|
|
|
if (ENABLE_MSAN AND CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory -fno-omit-frame-pointer -fPIE -pie")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory -fno-omit-frame-pointer -fPIE -pie")
|
|
|
|
endif (ENABLE_MSAN AND CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|
|
|
|
2019-12-13 04:04:47 -08:00
|
|
|
if (ENABLE_GCOV)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
|
|
|
|
endif (ENABLE_GCOV)
|
|
|
|
|
2017-06-02 06:37:46 -07:00
|
|
|
endif(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2016-04-18 02:17:23 -07:00
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
2014-03-03 11:09:26 -08:00
|
|
|
# The following is needed for weak linking to work under OS X
|
2016-04-18 02:17:23 -07:00
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup")
|
|
|
|
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2019-10-14 08:52:46 -07:00
|
|
|
# Add colored output when using the Ninja generator
|
|
|
|
if("Ninja" STREQUAL ${CMAKE_GENERATOR})
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
|
|
|
|
endif()
|
2019-09-16 14:00:25 -07:00
|
|
|
|
|
|
|
# Add -Werror to C/C++ flags for newer compilers
|
2020-05-08 05:13:59 -07:00
|
|
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
|
|
|
endif()
|
2019-09-16 14:00:25 -07:00
|
|
|
|
2020-08-10 06:48:55 -07:00
|
|
|
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
|
|
|
|
# Increase inlining limit to allow gcc compilation on e.g. RPi2
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --param large-function-growth=1600")
|
|
|
|
endif(CMAKE_C_COMPILER_ID MATCHES "GNU")
|
2020-08-10 02:27:29 -07:00
|
|
|
|
2017-06-02 06:37:46 -07:00
|
|
|
message(STATUS "CMAKE_C_FLAGS is ${CMAKE_C_FLAGS}")
|
|
|
|
message(STATUS "CMAKE_CXX_FLAGS is ${CMAKE_CXX_FLAGS}")
|
|
|
|
|
2018-09-13 08:11:55 -07:00
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# clang-tidy check
|
|
|
|
########################################################################
|
2018-12-13 02:06:57 -08:00
|
|
|
if(ENABLE_TIDY)
|
|
|
|
find_program(
|
|
|
|
CLANG_TIDY_BIN
|
|
|
|
NAMES "clang-tidy"
|
|
|
|
DOC "Path to clang-tidy executable"
|
|
|
|
)
|
|
|
|
if(NOT CLANG_TIDY_BIN)
|
|
|
|
message(STATUS "clang-tidy not found.")
|
|
|
|
else()
|
|
|
|
message(STATUS "clang-tidy found: ${CLANG_TIDY_BIN}")
|
|
|
|
set(DO_CLANG_TIDY "${CLANG_TIDY_BIN}" "-checks=*,-clang-analyzer-alpha.*,-modernize-*,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index")
|
|
|
|
endif()
|
|
|
|
endif(ENABLE_TIDY)
|
2018-09-13 08:11:55 -07:00
|
|
|
|
2014-03-03 11:09:26 -08:00
|
|
|
########################################################################
|
|
|
|
# Create uninstall targets
|
|
|
|
########################################################################
|
2016-04-18 02:17:23 -07:00
|
|
|
configure_file(
|
2014-03-03 11:09:26 -08:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
|
|
|
IMMEDIATE @ONLY)
|
|
|
|
|
2016-04-18 02:17:23 -07:00
|
|
|
add_custom_target(uninstall
|
2014-03-03 11:09:26 -08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
|
|
|
|
2020-04-14 09:20:38 -07:00
|
|
|
########################################################################
|
|
|
|
# Create optional target to build osmo-gsm-tester trial
|
|
|
|
########################################################################
|
|
|
|
add_custom_target(trial
|
|
|
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build_trial.sh)
|
|
|
|
|
2014-03-03 11:09:26 -08:00
|
|
|
########################################################################
|
2017-06-08 03:22:02 -07:00
|
|
|
# Add -fPIC property to all targets
|
2014-03-03 11:09:26 -08:00
|
|
|
########################################################################
|
2017-06-08 03:22:02 -07:00
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
2014-03-03 11:09:26 -08:00
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# Print summary
|
|
|
|
########################################################################
|
2016-04-18 02:17:23 -07:00
|
|
|
message(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}")
|
|
|
|
message(STATUS "Building for version: ${VERSION}")
|
2014-01-28 03:41:17 -08:00
|
|
|
|
2014-03-03 11:09:26 -08:00
|
|
|
########################################################################
|
|
|
|
# Add general includes and dependencies
|
|
|
|
########################################################################
|
2017-05-30 06:10:19 -07:00
|
|
|
include_directories(${PROJECT_BINARY_DIR}/lib/include)
|
|
|
|
include_directories(${PROJECT_SOURCE_DIR}/lib/include)
|
2014-01-28 03:41:17 -08:00
|
|
|
|
2017-05-31 04:44:10 -07:00
|
|
|
########################################################################
|
|
|
|
# Add headers to cmake project (useful for IDEs)
|
|
|
|
########################################################################
|
|
|
|
set(HEADERS_ALL "")
|
|
|
|
file(GLOB headers *)
|
|
|
|
foreach(_header ${headers})
|
|
|
|
if(IS_DIRECTORY ${_header})
|
|
|
|
file(GLOB_RECURSE tmp "${_header}/*.h")
|
|
|
|
list(APPEND HEADERS_ALL ${tmp})
|
|
|
|
endif(IS_DIRECTORY ${_header})
|
|
|
|
endforeach()
|
|
|
|
add_custom_target(add_srslte_headers SOURCES ${HEADERS_ALL})
|
|
|
|
|
2014-03-03 11:09:26 -08:00
|
|
|
########################################################################
|
|
|
|
# Add the subdirectories
|
|
|
|
########################################################################
|
2017-05-30 06:10:19 -07:00
|
|
|
add_subdirectory(lib)
|
2017-06-02 07:21:26 -07:00
|
|
|
|
|
|
|
if(RF_FOUND)
|
|
|
|
if(ENABLE_SRSUE)
|
2017-05-30 06:55:08 -07:00
|
|
|
message(STATUS "Building with srsUE")
|
|
|
|
add_subdirectory(srsue)
|
2017-06-02 07:21:26 -07:00
|
|
|
else(ENABLE_SRSUE)
|
|
|
|
message(STATUS "srsUE build disabled")
|
|
|
|
endif(ENABLE_SRSUE)
|
|
|
|
|
|
|
|
if(ENABLE_SRSENB)
|
2017-06-01 03:25:57 -07:00
|
|
|
message(STATUS "Building with srsENB")
|
|
|
|
add_subdirectory(srsenb)
|
2017-06-02 07:21:26 -07:00
|
|
|
else(ENABLE_SRSENB)
|
2018-02-07 01:37:26 -08:00
|
|
|
message(STATUS "srsENB build disabled")
|
2017-06-02 07:21:26 -07:00
|
|
|
endif(ENABLE_SRSENB)
|
|
|
|
else(RF_FOUND)
|
|
|
|
message(STATUS "srsUE and srsENB builds disabled due to missing RF driver")
|
|
|
|
endif(RF_FOUND)
|
2017-10-09 06:11:43 -07:00
|
|
|
|
|
|
|
if(ENABLE_SRSEPC)
|
2017-10-09 04:22:17 -07:00
|
|
|
message(STATUS "Building with srsEPC")
|
|
|
|
add_subdirectory(srsepc)
|
|
|
|
else(ENABLE_SRSEPC)
|
|
|
|
message(STATUS "srsEPC build disabled")
|
2017-10-09 06:11:43 -07:00
|
|
|
endif(ENABLE_SRSEPC)
|
2020-01-15 07:32:49 -08:00
|
|
|
|
2020-04-14 09:20:38 -07:00
|
|
|
add_subdirectory(test)
|