1 #==================================================================================
2 # Copyright (c) 2020 AT&T Intellectual Property.
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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 #==================================================================================
18 # This CMake definition supports several -D command line options:
20 # -DDEBUG=n Enable debugging level n
21 # -DGPROF=1 Enable profiling compile time flags
23 # Building the binaries in this project should be as easy as running the
24 # following command in this directory:
28 # cmake .. [-DGPROF=1] [-DDEBUG=1]
29 # make test [install] ARGS=-V
33 cmake_minimum_required( VERSION 3.14 )
35 set( major_version "1" ) # until CI supports auto tagging; must hard set
36 set( minor_version "2" )
37 set( patch_level "5" )
39 set( install_root "${CMAKE_INSTALL_PREFIX}" )
40 set( install_inc "/usr/local/include" )
42 # Must use GNUInstallDirs to install libraries into correct
43 # locations on all platforms.
44 include( GNUInstallDirs )
46 # externals may install using LIBDIR as established by the gnu include; it varies from system
47 # to system, and we don't trust that it is always set, so we default to lib if it is missing.
49 if( NOT CMAKE_INSTALL_LIBDIR )
50 set( CMAKE_INSTALL_LIBDIR "lib" )
53 set( install_lib "${CMAKE_INSTALL_LIBDIR}" )
55 if( DEBUG ) # if set, we'll set debugging on in the compile
56 set( debugging ${DEBUG} )
57 message( "+++ debugging is being set to ${DEBUG}" )
60 message( "+++ debugging is set to off" )
62 unset( DEBUG CACHE ) # we don't want this to persist
65 # ---------------- extract some things from git ------------------------------
67 # commit id for the version string
69 COMMAND bash -c "git rev-parse --short HEAD|awk '{printf\"%s\", $0}'"
70 OUTPUT_VARIABLE git_id
73 # define constants used in the version string, debugging, etc.
76 -DMAJOR_VER=${major_version}
77 -DMINOR_VER=${minor_version}
78 -DPATCH_VER=${patch_level}
83 # bleeding cmake names are short novels; and when lines cannot be split they're a pain
84 set ( srcd "${CMAKE_CURRENT_SOURCE_DIR}" )
89 set( CMAKE_POSITION_INDEPENDENT_CODE ON )
90 if( GPROF ) # if set, we'll set profiling flag on compiles
91 message( "+++ profiling is on" )
92 set( CMAKE_C_FLAGS "-pg " )
93 set( CMAKE_CXX_FLAGS "-pg " )
95 set( CMAKE_C_FLAGS "-g " )
96 set( CMAKE_CXX_FLAGS "-g " )
97 message( "+++ profiling is off" )
99 unset( GPROF CACHE ) # ensure this does not persist
101 # protobuf and grpc stufs
102 add_subdirectory( ext/protobuf )
105 add_subdirectory( src/utils )
107 # each binary is built from a subset
108 add_subdirectory( src/ts_xapp )
111 # -------- unit testing -------------------------------------------------------
114 NAME drive_unit_tests
115 COMMAND bash ../test/unit_test.sh -q
116 WORKING_DIRECTORY ../test