Separated E2Sim lib from E2SM-specific code
[sim/e2-interface.git] / e2sim / e2sm_examples / kpm_e2sm / CMakeLists.txt
1 #==================================================================================
2 #       Copyright (c) 2020 AT&T Intellectual Property.
3 #
4 #   Licensed under the Apache License, Version 2.0 (the "License"),
5 #   you may not use this file except in compliance with the License.
6 #   You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #   Unless required by applicable law or agreed to in writing, software
11 #   distributed under the License is distributed on an "AS IS" BASIS,
12 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #   See the License for the specific language governing permissions and
14 #   limitations under the License.
15 #==================================================================================
16 #
17
18
19 project( ricxfcpp )
20 cmake_minimum_required( VERSION 3.14 )
21
22 set( major_version "1" )                # until CI supports auto tagging; must hard set
23 set( minor_version "0" )
24 set( patch_level "0" )
25
26 set( install_root "${CMAKE_INSTALL_PREFIX}" )
27 set( install_inc "/usr/local/include" )
28
29 # Must use GNUInstallDirs to install libraries into correct
30 # locations on all platforms.
31 include( GNUInstallDirs )
32
33 # externals may install using LIBDIR as established by the gnu include; it varies from system
34 # to system, and we don't trust that it is always set, so we default to lib if it is missing.
35 #
36 if( NOT CMAKE_INSTALL_LIBDIR )
37         set( CMAKE_INSTALL_LIBDIR "lib" )
38 endif()
39
40 set( install_lib "${CMAKE_INSTALL_LIBDIR}" )
41
42 if( DEBUG )                                     # if set, we'll set debugging on in the compile
43         set( debugging ${DEBUG} )
44         message( "+++ debugging is being set to ${DEBUG}" )
45 else()
46         set( debugging 0 )
47         message( "+++ debugging is set to off" )
48 endif()
49 unset( DEBUG CACHE )                                    # we don't want this to persist
50
51
52 # ---------------- extract some things from git ------------------------------
53
54 # commit id for the version string
55 execute_process(
56         COMMAND bash -c "git rev-parse --short HEAD|awk '{printf\"%s\", $0}'"
57         OUTPUT_VARIABLE git_id
58 )
59
60 # define constants used in the version string, debugging, etc.
61 add_definitions(
62         -DGIT_ID=${git_id}
63         -DMAJOR_VER=${major_version}
64         -DMINOR_VER=${minor_version}
65         -DPATCH_VER=${patch_level}
66         -DDEBUG=${debugging}
67 )
68
69 # Compiler flags
70 #
71 set( CMAKE_POSITION_INDEPENDENT_CODE ON )
72 if( GPROF )                                     # if set, we'll set profiling flag on compiles
73         message( "+++ profiling is on" )
74         set( CMAKE_C_FLAGS "-pg " )
75         set( CMAKE_CPP_FLAGS "-pg " )
76 else()
77         set( CMAKE_C_FLAGS "-g " )
78         set( CMAKE_CPP_FLAGS "-g " )
79         message( "+++ profiling is off" )
80 endif()
81 unset( GPROF CACHE )                                    # ensure this does not persist
82
83 # each binary is built from a subset
84 add_subdirectory( src/ASN1c )
85 add_subdirectory( src/kpm )
86
87