CI: Add silent cmake SonarCloud scan
[ric-plt/lib/rmr.git] / test / rtg_sim / CMakeLists.txt
1
2 #
3 #==================================================================================
4 #       Copyright (c) 2019 Nokia
5 #       Copyright (c) 2018-2019 AT&T Intellectual Property.
6 #
7 #   Licensed under the Apache License, Version 2.0 (the "License");
8 #   you may not use this file except in compliance with the License.
9 #   You may obtain a copy of the License at
10 #
11 #       http://www.apache.org/licenses/LICENSE-2.0
12 #
13 #   Unless required by applicable law or agreed to in writing, software
14 #   distributed under the License is distributed on an "AS IS" BASIS,
15 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 #   See the License for the specific language governing permissions and
17 #   limitations under the License.
18 #==================================================================================
19 #
20
21 # simulate the route table manager
22 project( rtm_sim LANGUAGES C )
23 cmake_minimum_required( VERSION 3.5 )
24
25 set( major_version "1" )
26 set( minor_version "0" )
27 set( patch_level "1" )
28
29 set( CMAKE_POSITION_INDEPENDENT_CODE ON )
30 set( CMAKE_CXX_FLAGS "-g -Wall -I /usr/local/include" )
31
32 find_library( nanomsg libnanomsg.a )
33
34 find_program( rpm NAMES rpmbuild )                                      # rpm package gen requires this to be installed
35
36 if( "${rpm}" MATCHES "rpm-NOTFOUND" )                           # cannot build rpm
37         set( pkg_list "DEB" )
38         message( "+++ `make package` will generate only deb package; cannot find support to generate rpm packages" )
39 else()
40         set( pkg_list "DEB;RPM" )
41         message( "+++ `make package` will generate both deb and rpm packages" )
42 endif()
43
44 add_executable( rtm_sim rtm_sim.c )
45 target_link_libraries( rtm_sim nanomsg )
46
47 install( 
48         TARGETS rtm_sim
49         DESTINATION /usr/local/bin
50 )
51
52 IF( EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake" )
53         include( InstallRequiredSystemLibraries )
54
55         set( CPACK_set_DESTDIR "on" )
56         set( CPACK_PACKAGING_INSTALL_PREFIX "${install_root}" )
57         set( CPACK_GENERATOR ${pkg_list} )
58
59         set( CPACK_PACKAGE_DESCRIPTION "Simplistic route table manager simulator." )
60         set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "RT manager simulation" )
61         set( CPACK_PACKAGE_VENDOR "None" )
62         set( CPACK_PACKAGE_CONTACT "None" )
63         set( CPACK_PACKAGE_VERSION_MAJOR "${major_version}" )
64         set( CPACK_PACKAGE_VERSION_MINOR "${minor_version}" )
65         set( CPACK_PACKAGE_VERSION_PATCH "${patch_level}" )
66         set( CPACK_PACKAGE_FILE_NAME "rtm_sim-${major_version}.${minor_version}.${patch_level}-${CMAKE_SYSTEM_PROCESSOR}" )
67
68         # we build and ship the libraries, so there is NO dependency
69         set( CPACK_DEBIAN_PACKAGE_DEPENDS "libnanomsg0 (>=0.4)" )
70
71         set( CPACK_DEBIAN_PACKAGE_PRIORITY "optional" )
72         set( CPACK_DEBIAN_PACKAGE_SECTION "test" )
73         set( CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR} )
74         set( CPACK_RPM_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR} )
75
76         INCLUDE( CPack )
77 ENDIF()