X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=sim%2Fe2-interface.git;a=blobdiff_plain;f=e2sim%2FCMakeLists.txt;h=bf57fda806919f64799258852fc0a2b8da17e58f;hp=c4e867a6d5ab379ac5b247caf39a9c75a04ee0d5;hb=a9733dbcc47e93a3b2843056f1d587196296c324;hpb=3ebf932d23dcbec9ed19f4a51f9d00a0a54f5124 diff --git a/e2sim/CMakeLists.txt b/e2sim/CMakeLists.txt index c4e867a..bf57fda 100644 --- a/e2sim/CMakeLists.txt +++ b/e2sim/CMakeLists.txt @@ -1,61 +1,173 @@ -#/***************************************************************************** -# * -# Copyright 2019 AT&T Intellectual Property * -# Copyright 2019 Nokia * -# * -# Licensed under the Apache License, Version 2.0 (the "License"); * -# you may not use this file except in compliance with the License. * -# You may obtain a copy of the License at * -# * -# http://www.apache.org/licenses/LICENSE-2.0 * -# * -# Unless required by applicable law or agreed to in writing, software * -# distributed under the License is distributed on an "AS IS" BASIS, * -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * -# See the License for the specific language governing permissions and * -# limitations under the License. * -# * -#******************************************************************************/ - -cmake_minimum_required(VERSION 3.5.1) -set(CMAKE_CXX_COMPILER "/usr/bin/g++") -set(CMAKE_CXX_STANDARD 14) - -add_definitions("-D ASN_DISABLE_OER_SUPPORT") - -project(e2sim) - -set (E2SIM_ROOT ./) - -include_directories("${E2SIM_ROOT}/src") -include_directories("${E2SIM_ROOT}/src/DEF") -include_directories("${E2SIM_ROOT}/src/SCTP/") -include_directories("${E2SIM_ROOT}/src/E2AP") -include_directories("${E2SIM_ROOT}/src/E2AP/E2SM") -include_directories("${E2SIM_ROOT}/ASN1c") - -find_library( SCTP_STD_LIB sctp ) #needed for sctp_sendmsg - -#---------------------------------------------- -file(GLOB E2SIM_SOURCES - "${E2SIM_ROOT}/e2sim.cpp" - "${E2SIM_ROOT}/src/DEF/*.cpp" - "${E2SIM_ROOT}/src/SCTP/*.cpp" - "${E2SIM_ROOT}/src/E2AP/*.c" - "${E2SIM_ROOT}/src/E2AP/*.cpp" - "${E2SIM_ROOT}/ASN1c/*.c" - ) -add_executable(e2sim ${E2SIM_SOURCES}) -target_link_libraries( e2sim ${SCTP_STD_LIB} ) - -#---------------------------------------------- -file(GLOB RICSIM_SOURCES - "${E2SIM_ROOT}/ricsim.cpp" - "${E2SIM_ROOT}/src/DEF/*.cpp" - "${E2SIM_ROOT}/src/SCTP/*.cpp" - "${E2SIM_ROOT}/src/E2AP/*.c" - "${E2SIM_ROOT}/src/E2AP/*.cpp" - "${E2SIM_ROOT}/ASN1c/*.c" - ) -add_executable(ricsim ${RICSIM_SOURCES}) -target_link_libraries( ricsim ${SCTP_STD_LIB} ) + +project (e2sim) +cmake_minimum_required ( VERSION 3.5 ) + +set ( major_version "1" ) +set ( minor_version "0" ) +set ( patch_level "0" ) + +set( install_root "${CMAKE_INSTALL_PREFIX}" ) +set( install_inc "include/e2sim" ) + +if( MAN_PREFIX ) + set( install_man ${MAN_PREFIX} ) # is there a cmake var for this -- can't find one +else() + set( install_man "/usr/share/man" ) # this needs to be fixed so it's not hard coded +endif() + +include ( GNUInstallDirs ) + +if( NOT CMAKE_INSTALL_LIBDIR ) + set( CMAKE_INSTALL_LIBDIR "lib" ) +endif() + +set( install_lib "${CMAKE_INSTALL_LIBDIR}" ) + +if( ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" ) + if( NOT PRESERVE_PTYPE ) + set( deb_sys_name "amd64" ) + else() + set( deb_sys_name ${CMAKE_SYSTEM_PROCESSOR} ) + endif() +else() + set( deb_sys_name ${CMAKE_SYSTEM_PROCESSOR} ) +endif() +unset( PRESERVE_PTYPE CACHE ) # we don't want this to persist + +set( rpm_sys_name ${CMAKE_SYSTEM_PROCESSOR} ) + +if( DEV_PKG ) + set( deb_pkg_name "e2sim-dev" ) + set( rpm_pkg_name "e2sim-devel" ) +else() + set( deb_pkg_name "e2sim" ) + set( rpm_pkg_name "e2sim" ) +endif() + +set( pkg_label "ricxfcpp${spoiled_str}-${major_version}.${minor_version}.${patch_level}-${sys_name}" ) +set( rpm_pkg_label "${rpm_pkg_name}${spoiled_str}-${major_version}.${minor_version}.${patch_level}-${rpm_sys_name}" ) +set( deb_pkg_label "${deb_pkg_name}${spoiled_str}_${major_version}.${minor_version}.${patch_level}_${deb_sys_name}" ) +message( "+++ pkg name: ${deb_pkg_label}.deb" ) + +set( gen_rpm 0 ) +find_program( rpm NAMES rpmbuild ) # rpm package gen requires this to be installed +if( "${rpm}" MATCHES "rpm-NOTFOUND" ) # cannot build rpm + set( pkg_list "DEB" ) + message( "### make package will generate only deb package; cannot find support to generate rpm packages" ) +else() + message( "+++ pkg name: ${rpm_pkg_label}.rpm" ) # debugging if we think we can gen rpm too + set( pkg_list "DEB;RPM" ) + set( gen_rpm 1 ) + message( "+++ make package will generate both deb and rpm packages" ) +endif() + +# bleeding cmake names are short novels; and when lines cannot be split they're a pain +set ( srcd "${CMAKE_CURRENT_SOURCE_DIR}" ) + +# this gets us round a chicken/egg problem. include files don't exist until make is run +# but Cmake insists on having these exist when we add them to include directories to +# enable code to find them after we build them. +# +include_directories( "${srcd}/src/DEF;${srcd}/src/SCTP;${srcd}/src/messagerouting;${srcd}/src/base;${srcd}/src/encoding" ) + + +# Compiler flags +# +set( CMAKE_POSITION_INDEPENDENT_CODE ON ) +set( CMAKE_C_FLAGS "-g " ) +set( CMAKE_CPP_FLAGS "-g " ) +set( CMAKE_CXX_FLAGS "-g " ) +if( GPROF ) # if set, we'll set profiling flag on compiles + message( "+++ profiling is on" ) + set( CMAKE_C_FLAGS "-pg " ) + set( CMAKE_CPP_FLAGS "-pg " ) +else() + message( "+++ profiling is off" ) +endif() +unset( GPROF CACHE ) # we don't want this to persist + + + + +add_subdirectory(src/ASN1c) +add_subdirectory(src/DEF) +add_subdirectory(src/SCTP) +add_subdirectory(src/messagerouting) +add_subdirectory(src/base) +add_subdirectory(src/encoding) + + +add_library( e2sim_shared SHARED + +"$;$;$;$;$" + +) + + +# we only build/export the static archive (.a) if generating a dev package +if( DEV_PKG ) + add_library( e2sim_static STATIC + "$;$;$;$;$" + ) + + set_target_properties( e2sim_static + PROPERTIES + OUTPUT_NAME "e2sim" + SOVERSION 1 + VERSION ${major_version}.${minor_version}.${patch_level} + ) + + target_include_directories( e2sim_static PUBLIC "src/DEF" "src/SCTP" "src/messagerouting" "src/base" "src/encoding" ) +endif() + + +if (DEV_PKG ) + set (target_list "e2sim_static" ) +else() + set (target_list "e2sim_shared" ) +endif() + +install( TARGETS ${target_list} EXPORT LibraryConfig + LIBRARY DESTINATION ${install_lib} + ARCHIVE DESTINATION ${install_lib} + PUBLIC_HEADER DESTINATION ${install_inc} +) + + +unset( DEV_PKG CACHE ) # prevent from being a hidden setting if user redoes things + +IF( EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake" ) + include( InstallRequiredSystemLibraries ) + + set( CPACK_DEBIAN_PACKAGE_NAME ${deb_pkg_name} ) + set( CPACK_RPM_PACKAGE_NAME ${rpm_pkg_name} ) + + set( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/local;/usr/local/bin;/usr/local/include;/usr/local/share;/usr/local/lib" ) + + set( CPACK_set_DESTDIR "on" ) + set( CPACK_PACKAGING_INSTALL_PREFIX "${install_root}" ) + set( CPACK_GENERATOR "${pkg_list}" ) + + set( CPACK_PACKAGE_DESCRIPTION "C++ framework for RIC xAPPs based on RMR." ) + set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "RIC xAPP C++ framework library" ) + set( CPACK_PACKAGE_VENDOR "None" ) + set( CPACK_PACKAGE_CONTACT "None" ) + set( CPACK_PACKAGE_VERSION_MAJOR "${major_version}" ) + set( CPACK_PACKAGE_VERSION_MINOR "${minor_version}" ) + set( CPACK_PACKAGE_VERSION_PATCH "${patch_level}" ) + set( CPACK_PACKAGE "${pkg_label}" ) # generic name for old versions of cpack + set( CPACK_DEBIAN_FILE_NAME "${deb_pkg_label}.deb" ) + set( CPACK_RPM_FILE_NAME "${rpm_pkg_label}.rpm" ) + + # Future: define dependencies on RMR and other libs + + set( CPACK_DEBIAN_PACKAGE_PRIORITY "optional" ) + set( CPACK_DEBIAN_PACKAGE_SECTION "ric" ) + set( CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR} ) + set( CPACK_RPM_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR} ) + + # this seems ingnored if included + #set( CPACK_COMPONENTS_ALL Libraries ApplicationData ) + + INCLUDE( CPack ) +ENDIF()