Harry Tran | 1f1098a | 2020-03-10 10:40:10 -0400 | [diff] [blame] | 1 | |
Ron Shacham | a9733db | 2020-09-14 12:05:31 -0400 | [diff] [blame] | 2 | project (e2sim) |
| 3 | cmake_minimum_required ( VERSION 3.5 ) |
Harry Tran | 1f1098a | 2020-03-10 10:40:10 -0400 | [diff] [blame] | 4 | |
Ron Shacham | a9733db | 2020-09-14 12:05:31 -0400 | [diff] [blame] | 5 | set ( major_version "1" ) |
| 6 | set ( minor_version "0" ) |
| 7 | set ( patch_level "0" ) |
Harry Tran | 1f1098a | 2020-03-10 10:40:10 -0400 | [diff] [blame] | 8 | |
Ron Shacham | a9733db | 2020-09-14 12:05:31 -0400 | [diff] [blame] | 9 | set( install_root "${CMAKE_INSTALL_PREFIX}" ) |
| 10 | set( install_inc "include/e2sim" ) |
Harry Tran | 1f1098a | 2020-03-10 10:40:10 -0400 | [diff] [blame] | 11 | |
Ron Shacham | a9733db | 2020-09-14 12:05:31 -0400 | [diff] [blame] | 12 | if( MAN_PREFIX ) |
| 13 | set( install_man ${MAN_PREFIX} ) # is there a cmake var for this -- can't find one |
| 14 | else() |
| 15 | set( install_man "/usr/share/man" ) # this needs to be fixed so it's not hard coded |
| 16 | endif() |
Harry Tran | 1f1098a | 2020-03-10 10:40:10 -0400 | [diff] [blame] | 17 | |
Ron Shacham | a9733db | 2020-09-14 12:05:31 -0400 | [diff] [blame] | 18 | include ( GNUInstallDirs ) |
Harry Tran | 1f1098a | 2020-03-10 10:40:10 -0400 | [diff] [blame] | 19 | |
subhash kumar singh | f86662b | 2022-03-22 00:39:54 +0530 | [diff] [blame^] | 20 | add_definitions("-D ASN_DISABLE_OER_SUPPORT") |
| 21 | |
Ron Shacham | a9733db | 2020-09-14 12:05:31 -0400 | [diff] [blame] | 22 | if( NOT CMAKE_INSTALL_LIBDIR ) |
| 23 | set( CMAKE_INSTALL_LIBDIR "lib" ) |
| 24 | endif() |
Harry Tran | 1f1098a | 2020-03-10 10:40:10 -0400 | [diff] [blame] | 25 | |
Ron Shacham | a9733db | 2020-09-14 12:05:31 -0400 | [diff] [blame] | 26 | set( install_lib "${CMAKE_INSTALL_LIBDIR}" ) |
Harry Tran | 1f1098a | 2020-03-10 10:40:10 -0400 | [diff] [blame] | 27 | |
Ron Shacham | a9733db | 2020-09-14 12:05:31 -0400 | [diff] [blame] | 28 | if( ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" ) |
| 29 | if( NOT PRESERVE_PTYPE ) |
| 30 | set( deb_sys_name "amd64" ) |
| 31 | else() |
| 32 | set( deb_sys_name ${CMAKE_SYSTEM_PROCESSOR} ) |
| 33 | endif() |
| 34 | else() |
| 35 | set( deb_sys_name ${CMAKE_SYSTEM_PROCESSOR} ) |
| 36 | endif() |
| 37 | unset( PRESERVE_PTYPE CACHE ) # we don't want this to persist |
| 38 | |
| 39 | set( rpm_sys_name ${CMAKE_SYSTEM_PROCESSOR} ) |
| 40 | |
| 41 | if( DEV_PKG ) |
| 42 | set( deb_pkg_name "e2sim-dev" ) |
| 43 | set( rpm_pkg_name "e2sim-devel" ) |
| 44 | else() |
| 45 | set( deb_pkg_name "e2sim" ) |
| 46 | set( rpm_pkg_name "e2sim" ) |
| 47 | endif() |
| 48 | |
| 49 | set( pkg_label "ricxfcpp${spoiled_str}-${major_version}.${minor_version}.${patch_level}-${sys_name}" ) |
| 50 | set( rpm_pkg_label "${rpm_pkg_name}${spoiled_str}-${major_version}.${minor_version}.${patch_level}-${rpm_sys_name}" ) |
| 51 | set( deb_pkg_label "${deb_pkg_name}${spoiled_str}_${major_version}.${minor_version}.${patch_level}_${deb_sys_name}" ) |
| 52 | message( "+++ pkg name: ${deb_pkg_label}.deb" ) |
| 53 | |
| 54 | set( gen_rpm 0 ) |
| 55 | find_program( rpm NAMES rpmbuild ) # rpm package gen requires this to be installed |
| 56 | if( "${rpm}" MATCHES "rpm-NOTFOUND" ) # cannot build rpm |
| 57 | set( pkg_list "DEB" ) |
| 58 | message( "### make package will generate only deb package; cannot find support to generate rpm packages" ) |
| 59 | else() |
| 60 | message( "+++ pkg name: ${rpm_pkg_label}.rpm" ) # debugging if we think we can gen rpm too |
| 61 | set( pkg_list "DEB;RPM" ) |
| 62 | set( gen_rpm 1 ) |
| 63 | message( "+++ make package will generate both deb and rpm packages" ) |
| 64 | endif() |
| 65 | |
| 66 | # bleeding cmake names are short novels; and when lines cannot be split they're a pain |
| 67 | set ( srcd "${CMAKE_CURRENT_SOURCE_DIR}" ) |
| 68 | |
| 69 | # this gets us round a chicken/egg problem. include files don't exist until make is run |
| 70 | # but Cmake insists on having these exist when we add them to include directories to |
| 71 | # enable code to find them after we build them. |
| 72 | # |
| 73 | include_directories( "${srcd}/src/DEF;${srcd}/src/SCTP;${srcd}/src/messagerouting;${srcd}/src/base;${srcd}/src/encoding" ) |
| 74 | |
| 75 | |
| 76 | # Compiler flags |
| 77 | # |
| 78 | set( CMAKE_POSITION_INDEPENDENT_CODE ON ) |
| 79 | set( CMAKE_C_FLAGS "-g " ) |
| 80 | set( CMAKE_CPP_FLAGS "-g " ) |
| 81 | set( CMAKE_CXX_FLAGS "-g " ) |
| 82 | if( GPROF ) # if set, we'll set profiling flag on compiles |
| 83 | message( "+++ profiling is on" ) |
| 84 | set( CMAKE_C_FLAGS "-pg " ) |
| 85 | set( CMAKE_CPP_FLAGS "-pg " ) |
| 86 | else() |
| 87 | message( "+++ profiling is off" ) |
| 88 | endif() |
| 89 | unset( GPROF CACHE ) # we don't want this to persist |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | add_subdirectory(src/ASN1c) |
| 95 | add_subdirectory(src/DEF) |
| 96 | add_subdirectory(src/SCTP) |
| 97 | add_subdirectory(src/messagerouting) |
| 98 | add_subdirectory(src/base) |
| 99 | add_subdirectory(src/encoding) |
| 100 | |
| 101 | |
| 102 | add_library( e2sim_shared SHARED |
| 103 | |
| 104 | "$<TARGET_OBJECTS:def_objects>;$<TARGET_OBJECTS:sctp_objects>;$<TARGET_OBJECTS:messagerouting_objects>;$<TARGET_OBJECTS:encoding_objects>;$<TARGET_OBJECTS:base_objects>" |
| 105 | |
| 106 | ) |
| 107 | |
| 108 | |
| 109 | # we only build/export the static archive (.a) if generating a dev package |
| 110 | if( DEV_PKG ) |
| 111 | add_library( e2sim_static STATIC |
| 112 | "$<TARGET_OBJECTS:def_objects>;$<TARGET_OBJECTS:sctp_objects>;$<TARGET_OBJECTS:messagerouting_objects>;$<TARGET_OBJECTS:encoding_objects>;$<TARGET_OBJECTS:base_objects>" |
| 113 | ) |
| 114 | |
| 115 | set_target_properties( e2sim_static |
| 116 | PROPERTIES |
| 117 | OUTPUT_NAME "e2sim" |
| 118 | SOVERSION 1 |
| 119 | VERSION ${major_version}.${minor_version}.${patch_level} |
| 120 | ) |
| 121 | |
| 122 | target_include_directories( e2sim_static PUBLIC "src/DEF" "src/SCTP" "src/messagerouting" "src/base" "src/encoding" ) |
| 123 | endif() |
| 124 | |
| 125 | |
| 126 | if (DEV_PKG ) |
| 127 | set (target_list "e2sim_static" ) |
| 128 | else() |
| 129 | set (target_list "e2sim_shared" ) |
| 130 | endif() |
| 131 | |
| 132 | install( TARGETS ${target_list} EXPORT LibraryConfig |
| 133 | LIBRARY DESTINATION ${install_lib} |
| 134 | ARCHIVE DESTINATION ${install_lib} |
| 135 | PUBLIC_HEADER DESTINATION ${install_inc} |
| 136 | ) |
| 137 | |
| 138 | |
| 139 | unset( DEV_PKG CACHE ) # prevent from being a hidden setting if user redoes things |
| 140 | |
| 141 | IF( EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake" ) |
| 142 | include( InstallRequiredSystemLibraries ) |
| 143 | |
| 144 | set( CPACK_DEBIAN_PACKAGE_NAME ${deb_pkg_name} ) |
| 145 | set( CPACK_RPM_PACKAGE_NAME ${rpm_pkg_name} ) |
| 146 | |
| 147 | set( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/local;/usr/local/bin;/usr/local/include;/usr/local/share;/usr/local/lib" ) |
| 148 | |
| 149 | set( CPACK_set_DESTDIR "on" ) |
| 150 | set( CPACK_PACKAGING_INSTALL_PREFIX "${install_root}" ) |
| 151 | set( CPACK_GENERATOR "${pkg_list}" ) |
| 152 | |
| 153 | set( CPACK_PACKAGE_DESCRIPTION "C++ framework for RIC xAPPs based on RMR." ) |
| 154 | set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "RIC xAPP C++ framework library" ) |
| 155 | set( CPACK_PACKAGE_VENDOR "None" ) |
| 156 | set( CPACK_PACKAGE_CONTACT "None" ) |
| 157 | set( CPACK_PACKAGE_VERSION_MAJOR "${major_version}" ) |
| 158 | set( CPACK_PACKAGE_VERSION_MINOR "${minor_version}" ) |
| 159 | set( CPACK_PACKAGE_VERSION_PATCH "${patch_level}" ) |
| 160 | set( CPACK_PACKAGE "${pkg_label}" ) # generic name for old versions of cpack |
| 161 | set( CPACK_DEBIAN_FILE_NAME "${deb_pkg_label}.deb" ) |
| 162 | set( CPACK_RPM_FILE_NAME "${rpm_pkg_label}.rpm" ) |
| 163 | |
| 164 | # Future: define dependencies on RMR and other libs |
| 165 | |
| 166 | set( CPACK_DEBIAN_PACKAGE_PRIORITY "optional" ) |
| 167 | set( CPACK_DEBIAN_PACKAGE_SECTION "ric" ) |
| 168 | set( CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR} ) |
| 169 | set( CPACK_RPM_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR} ) |
| 170 | |
| 171 | # this seems ingnored if included |
| 172 | #set( CPACK_COMPONENTS_ALL Libraries ApplicationData ) |
| 173 | |
| 174 | INCLUDE( CPack ) |
| 175 | ENDIF() |