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 #==================================================================================
20 cmake_minimum_required( VERSION 3.14 )
22 set( major_version "1" ) # until CI supports auto tagging; must hard set
23 set( minor_version "0" )
24 set( patch_level "0" )
26 set( install_root "${CMAKE_INSTALL_PREFIX}" )
27 set( install_inc "/usr/local/include" )
29 # Must use GNUInstallDirs to install libraries into correct
30 # locations on all platforms.
31 include( GNUInstallDirs )
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.
36 if( NOT CMAKE_INSTALL_LIBDIR )
37 set( CMAKE_INSTALL_LIBDIR "lib" )
40 set( install_lib "${CMAKE_INSTALL_LIBDIR}" )
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}" )
47 message( "+++ debugging is set to off" )
49 unset( DEBUG CACHE ) # we don't want this to persist
52 # ---------------- extract some things from git ------------------------------
54 # commit id for the version string
56 COMMAND bash -c "git rev-parse --short HEAD|awk '{printf\"%s\", $0}'"
57 OUTPUT_VARIABLE git_id
60 # define constants used in the version string, debugging, etc.
63 -DMAJOR_VER=${major_version}
64 -DMINOR_VER=${minor_version}
65 -DPATCH_VER=${patch_level}
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 " )
77 set( CMAKE_C_FLAGS "-g " )
78 set( CMAKE_CPP_FLAGS "-g " )
79 message( "+++ profiling is off" )
81 unset( GPROF CACHE ) # ensure this does not persist
83 # each binary is built from a subset
84 add_subdirectory( src/ASN1c )
85 add_subdirectory( src/kpm )