blob: eb833dd73b926d129f7e82810da8c6c9ec62569f [file] [log] [blame]
Harry Tran1f1098a2020-03-10 10:40:10 -04001
Ron Shachama9733db2020-09-14 12:05:31 -04002project (e2sim)
3cmake_minimum_required ( VERSION 3.5 )
Harry Tran1f1098a2020-03-10 10:40:10 -04004
Ron Shachama9733db2020-09-14 12:05:31 -04005set ( major_version "1" )
6set ( minor_version "0" )
7set ( patch_level "0" )
Harry Tran1f1098a2020-03-10 10:40:10 -04008
Ron Shachama9733db2020-09-14 12:05:31 -04009set( install_root "${CMAKE_INSTALL_PREFIX}" )
10set( install_inc "include/e2sim" )
Harry Tran1f1098a2020-03-10 10:40:10 -040011
Ron Shachama9733db2020-09-14 12:05:31 -040012if( MAN_PREFIX )
13 set( install_man ${MAN_PREFIX} ) # is there a cmake var for this -- can't find one
14else()
15 set( install_man "/usr/share/man" ) # this needs to be fixed so it's not hard coded
16endif()
Harry Tran1f1098a2020-03-10 10:40:10 -040017
Ron Shachama9733db2020-09-14 12:05:31 -040018include ( GNUInstallDirs )
Harry Tran1f1098a2020-03-10 10:40:10 -040019
subhash kumar singhf86662b2022-03-22 00:39:54 +053020add_definitions("-D ASN_DISABLE_OER_SUPPORT")
21
Ron Shachama9733db2020-09-14 12:05:31 -040022if( NOT CMAKE_INSTALL_LIBDIR )
23 set( CMAKE_INSTALL_LIBDIR "lib" )
24endif()
Harry Tran1f1098a2020-03-10 10:40:10 -040025
Ron Shachama9733db2020-09-14 12:05:31 -040026set( install_lib "${CMAKE_INSTALL_LIBDIR}" )
Harry Tran1f1098a2020-03-10 10:40:10 -040027
Ron Shachama9733db2020-09-14 12:05:31 -040028if( ${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()
34else()
35 set( deb_sys_name ${CMAKE_SYSTEM_PROCESSOR} )
36endif()
37unset( PRESERVE_PTYPE CACHE ) # we don't want this to persist
38
39set( rpm_sys_name ${CMAKE_SYSTEM_PROCESSOR} )
40
41if( DEV_PKG )
42 set( deb_pkg_name "e2sim-dev" )
43 set( rpm_pkg_name "e2sim-devel" )
44else()
45 set( deb_pkg_name "e2sim" )
46 set( rpm_pkg_name "e2sim" )
47endif()
48
49set( pkg_label "ricxfcpp${spoiled_str}-${major_version}.${minor_version}.${patch_level}-${sys_name}" )
50set( rpm_pkg_label "${rpm_pkg_name}${spoiled_str}-${major_version}.${minor_version}.${patch_level}-${rpm_sys_name}" )
51set( deb_pkg_label "${deb_pkg_name}${spoiled_str}_${major_version}.${minor_version}.${patch_level}_${deb_sys_name}" )
52message( "+++ pkg name: ${deb_pkg_label}.deb" )
53
54set( gen_rpm 0 )
55find_program( rpm NAMES rpmbuild ) # rpm package gen requires this to be installed
56if( "${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" )
59else()
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" )
64endif()
65
66# bleeding cmake names are short novels; and when lines cannot be split they're a pain
67set ( 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#
73include_directories( "${srcd}/src/DEF;${srcd}/src/SCTP;${srcd}/src/messagerouting;${srcd}/src/base;${srcd}/src/encoding" )
74
75
76# Compiler flags
77#
78set( CMAKE_POSITION_INDEPENDENT_CODE ON )
79set( CMAKE_C_FLAGS "-g " )
80set( CMAKE_CPP_FLAGS "-g " )
81set( CMAKE_CXX_FLAGS "-g " )
82if( 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 " )
86else()
87 message( "+++ profiling is off" )
88endif()
89unset( GPROF CACHE ) # we don't want this to persist
90
91
92
93
94add_subdirectory(src/ASN1c)
95add_subdirectory(src/DEF)
96add_subdirectory(src/SCTP)
97add_subdirectory(src/messagerouting)
98add_subdirectory(src/base)
99add_subdirectory(src/encoding)
100
101
102add_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
110if( 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" )
123endif()
124
125
126if (DEV_PKG )
127 set (target_list "e2sim_static" )
128else()
129 set (target_list "e2sim_shared" )
130endif()
131
132install( TARGETS ${target_list} EXPORT LibraryConfig
133 LIBRARY DESTINATION ${install_lib}
134 ARCHIVE DESTINATION ${install_lib}
135 PUBLIC_HEADER DESTINATION ${install_inc}
136)
137
138
139unset( DEV_PKG CACHE ) # prevent from being a hidden setting if user redoes things
140
141IF( 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 )
175ENDIF()