Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 1 | # |
| 2 | #================================================================================== |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 3 | # Copyright (c) 2019 Nokia |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 4 | # Copyright (c) 2018-2019 AT&T Intellectual Property. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | #================================================================================== |
| 18 | # |
| 19 | |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 20 | # This CMake definition supports several -D command line options: |
| 21 | # |
E. Scott Daniels | ec88d3c | 2019-11-13 09:40:22 -0500 | [diff] [blame] | 22 | # -DDEBUG=n Enable debugging level n |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 23 | # -DDEV_PKG=1 Development package configuration |
| 24 | # -DBUILD_DOC=1 Man pages generated |
E. Scott Daniels | b0ba22e | 2019-08-06 13:26:12 -0400 | [diff] [blame] | 25 | # -DIGNORE_LIBDIR=1 Installation of rmr libries is into /usr/local/lib and ignores |
| 26 | # value in CMAKE_INSTALL_LIBDIR. |
| 27 | # system preferred (typically /usr/local/lib64). |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 28 | # -DPRESERVE_PTYPE=1 Do not change the processor type when naming deb packages |
| 29 | # -DPACK_EXTERNALS=1 Include external libraries used to build in the run-time package |
E. Scott Daniels | e30fc3a | 2019-07-16 12:03:45 -0400 | [diff] [blame] | 30 | # (This makes some stand-alone unit testing of bindings possible, it |
| 31 | # is not meant to be used for production package generation.) |
E. Scott Daniels | ec88d3c | 2019-11-13 09:40:22 -0500 | [diff] [blame] | 32 | # -DGPROF=1 Enable profiling compile time flags |
E. Scott Daniels | b0ba22e | 2019-08-06 13:26:12 -0400 | [diff] [blame] | 33 | # -DSKIP_EXTERNALS=1 Do not use NNG submodule when building; uee installed packages |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 34 | # -DMAN_PREFIX=<path> Supply a path where man pages are installed (default: /usr/share/man) |
| 35 | |
E. Scott Daniels | fc5c77b | 2020-02-21 13:24:29 -0500 | [diff] [blame] | 36 | # See ci/build_all for an example of how to build and test |
| 37 | |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 38 | project( rmr LANGUAGES C ) |
| 39 | cmake_minimum_required( VERSION 3.5 ) |
| 40 | |
E. Scott Daniels | ec88d3c | 2019-11-13 09:40:22 -0500 | [diff] [blame] | 41 | set( major_version "3" ) # should be automatically populated from git tag later, but until CI process sets a tag we use this |
E. Scott Daniels | fe9b5bd | 2020-03-18 08:41:07 -0400 | [diff] [blame] | 42 | set( minor_version "6" ) |
E. Scott Daniels | 0949fab | 2020-03-18 23:50:57 -0400 | [diff] [blame] | 43 | set( patch_level "1" ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 44 | |
| 45 | set( install_root "${CMAKE_INSTALL_PREFIX}" ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 46 | set( install_inc "include/rmr" ) |
| 47 | if( MAN_PREFIX ) |
| 48 | set( install_man ${MAN_PREFIX} ) # is there a cmake var for this -- can't find one |
| 49 | else() |
| 50 | set( install_man "/usr/share/man" ) # this needs to be fixed so it's not hard coded |
| 51 | endif() |
| 52 | |
| 53 | # Must use GNUInstallDirs to install libraries into correct |
| 54 | # locations on all platforms. |
| 55 | include( GNUInstallDirs ) |
| 56 | |
E. Scott Daniels | b0ba22e | 2019-08-06 13:26:12 -0400 | [diff] [blame] | 57 | # nng installs using LIBDIR as established by the gnu include; it varies from system |
| 58 | # to system, and we don't trust that it is always set, so we default to lib if it is missing. |
E. Scott Daniels | a943533 | 2019-05-09 14:39:19 +0000 | [diff] [blame] | 59 | # |
| 60 | if( NOT CMAKE_INSTALL_LIBDIR ) |
| 61 | set( CMAKE_INSTALL_LIBDIR "lib" ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 62 | endif() |
| 63 | |
E. Scott Daniels | b0ba22e | 2019-08-06 13:26:12 -0400 | [diff] [blame] | 64 | if( IGNORE_LIBDIR ) # if set, then force to lib otherwise use "system preference" |
| 65 | set( install_lib "lib" ) |
| 66 | else() |
| 67 | set( install_lib "${CMAKE_INSTALL_LIBDIR}" ) |
| 68 | endif() |
| 69 | unset(IGNORE_LIBDIR CACHE ) # we don't want this to persist |
| 70 | message( "+++ RMR library install target directory: ${install_lib}" ) |
| 71 | |
E. Scott Daniels | 68c5cf1 | 2019-04-12 15:14:40 +0000 | [diff] [blame] | 72 | # ---------------- extract some things from git ------------------------------ |
| 73 | |
| 74 | # commit id for the version string |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 75 | execute_process( |
| 76 | COMMAND bash -c "git rev-parse --short HEAD|awk '{printf\"%s\", $0}'" |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 77 | OUTPUT_VARIABLE git_id |
| 78 | ) |
| 79 | |
E. Scott Daniels | 68c5cf1 | 2019-04-12 15:14:40 +0000 | [diff] [blame] | 80 | # version information for library names and version string |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 81 | execute_process( |
E. Scott Daniels | 68c5cf1 | 2019-04-12 15:14:40 +0000 | [diff] [blame] | 82 | COMMAND bash -c "git describe --tags --abbrev=0 HEAD 2>/dev/null | awk -v tag=0.0.4095 ' { tag=$1 } END{ print tag suffix }'|sed 's/\\./;/g' " |
| 83 | OUTPUT_VARIABLE mmp_version_str |
| 84 | ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE |
| 85 | ) |
E. Scott Daniels | b0ba22e | 2019-08-06 13:26:12 -0400 | [diff] [blame] | 86 | message( "+++ mmp version from tag: '${mmp_version_str}'" ) |
E. Scott Daniels | 68c5cf1 | 2019-04-12 15:14:40 +0000 | [diff] [blame] | 87 | |
| 88 | # extra indicator to show that the build was based on modified file(s) and not the true commit |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 89 | # (no hope of reproducing the exact library for debugging). Used only for the internal version |
E. Scott Daniels | 68c5cf1 | 2019-04-12 15:14:40 +0000 | [diff] [blame] | 90 | # string. |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 91 | execute_process( |
| 92 | COMMAND bash -c "git diff --shortstat|awk -v fmt=%s -v r=-rotten '{ s=r } END { printf( fmt, s ) }'" |
E. Scott Daniels | 68c5cf1 | 2019-04-12 15:14:40 +0000 | [diff] [blame] | 93 | OUTPUT_VARIABLE spoiled_str |
| 94 | ) |
| 95 | |
E. Scott Daniels | d710957 | 2019-04-18 14:01:16 +0000 | [diff] [blame] | 96 | # uncomment these lines once CI starts adding a tag on merge |
| 97 | #set( mmp_version ${mmp_version_str} ) |
| 98 | #list( GET mmp_version 0 major_version ) |
| 99 | #list( GET mmp_version 1 minor_version ) |
| 100 | #list( GET mmp_version 2 patch_level ) |
E. Scott Daniels | 68c5cf1 | 2019-04-12 15:14:40 +0000 | [diff] [blame] | 101 | |
E. Scott Daniels | a1c1dc6 | 2019-09-30 13:05:12 -0400 | [diff] [blame] | 102 | if( DEBUG ) # if set, we'll set debugging on in the compile |
| 103 | set( debugging ${DEBUG} ) |
| 104 | message( "+++ debugging is being set to ${DEBUG}" ) |
| 105 | else() |
| 106 | set( debugging 0 ) |
E. Scott Daniels | ec88d3c | 2019-11-13 09:40:22 -0500 | [diff] [blame] | 107 | message( "+++ debugging is set to off" ) |
E. Scott Daniels | a1c1dc6 | 2019-09-30 13:05:12 -0400 | [diff] [blame] | 108 | endif() |
| 109 | unset( DEBUG CACHE ) # we don't want this to persist |
E. Scott Daniels | 68c5cf1 | 2019-04-12 15:14:40 +0000 | [diff] [blame] | 110 | |
E. Scott Daniels | ec88d3c | 2019-11-13 09:40:22 -0500 | [diff] [blame] | 111 | |
E. Scott Daniels | a1c1dc6 | 2019-09-30 13:05:12 -0400 | [diff] [blame] | 112 | # define constants used in the version string, debugging, etc. |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 113 | add_definitions( |
| 114 | -DGIT_ID=${git_id} |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 115 | -DMAJOR_VER=${major_version} |
| 116 | -DMINOR_VER=${minor_version} |
E. Scott Daniels | d4f18ba | 2019-06-17 15:08:17 -0400 | [diff] [blame] | 117 | -DPATCH_VER=${patch_level} |
E. Scott Daniels | a1c1dc6 | 2019-09-30 13:05:12 -0400 | [diff] [blame] | 118 | -DDEBUG=${debugging} |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 119 | ) |
| 120 | |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 121 | # ---------------- suss out pkg gen tools so we don't fail generating packages that the system cannot support -------------- |
| 122 | |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 123 | # deb packages use underbars, and package manager(s) seem to flip the *_64 processor type |
E. Scott Daniels | b0ba22e | 2019-08-06 13:26:12 -0400 | [diff] [blame] | 124 | # to the old (non-standard) amd64 string, so we do it here for consistency. Set -DPRESERVE_PTYPE=1 |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 125 | # to prevent the flip. RPM packages will always be given the system generated processor type string. |
| 126 | # |
| 127 | if( ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" ) |
| 128 | if( NOT PRESERVE_PTYPE ) |
| 129 | set( deb_sys_name "amd64" ) |
| 130 | else() |
| 131 | set( deb_sys_name ${CMAKE_SYSTEM_PROCESSOR} ) |
| 132 | endif() |
| 133 | else() |
| 134 | set( deb_sys_name ${CMAKE_SYSTEM_PROCESSOR} ) |
| 135 | endif() |
| 136 | unset( PRESERVE_PTYPE CACHE ) # we don't want this to persist |
| 137 | |
| 138 | set( rpm_sys_name ${CMAKE_SYSTEM_PROCESSOR} ) |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 139 | |
| 140 | if( DEV_PKG ) |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 141 | set( deb_pkg_name "rmr-dev" ) |
| 142 | set( rpm_pkg_name "rmr-devel" ) |
E. Scott Daniels | d4f18ba | 2019-06-17 15:08:17 -0400 | [diff] [blame] | 143 | else() |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 144 | set( deb_pkg_name "rmr" ) |
| 145 | set( rpm_pkg_name "rmr" ) |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 146 | endif() |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 147 | |
| 148 | set( pkg_label "rmr${spoiled_str}-${major_version}.${minor_version}.${patch_level}-${sys_name}" ) |
| 149 | set( rpm_pkg_label "${rpm_pkg_name}${spoiled_str}-${major_version}.${minor_version}.${patch_level}-${rpm_sys_name}" ) |
| 150 | set( deb_pkg_label "${deb_pkg_name}${spoiled_str}_${major_version}.${minor_version}.${patch_level}_${deb_sys_name}" ) |
| 151 | message( "+++ pkg name: ${deb_pkg_label}.deb" ) |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 152 | |
E. Scott Daniels | b0ba22e | 2019-08-06 13:26:12 -0400 | [diff] [blame] | 153 | #set( out_yml /tmp/build_output.yml ) # we will record package names (we record only untainted names) |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 154 | find_program( rpm NAMES rpmbuild ) # rpm package gen requires this to be installed |
| 155 | |
| 156 | set( gen_rpm 0 ) |
| 157 | if( "${rpm}" MATCHES "rpm-NOTFOUND" ) # cannot build rpm |
| 158 | set( pkg_list "DEB" ) |
| 159 | message( "### make package will generate only deb package; cannot find support to generate rpm packages" ) |
| 160 | else() |
E. Scott Daniels | b0ba22e | 2019-08-06 13:26:12 -0400 | [diff] [blame] | 161 | message( "+++ pkg name: ${rpm_pkg_label}.rpm" ) # debugging if we think we can gen rpm too |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 162 | set( pkg_list "DEB;RPM" ) |
| 163 | set( gen_rpm 1 ) |
| 164 | message( "+++ make package will generate both deb and rpm packages" ) |
| 165 | endif() |
| 166 | |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 167 | # ---------------- setup nano/nng things --------------------------------------- |
| 168 | if( NOT SKIP_EXTERNALS ) |
| 169 | set( need_ext 1 ) # we force dependences on these for right build order |
| 170 | execute_process( COMMAND git submodule update --init -- ext/nng |
| 171 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
| 172 | ) |
| 173 | |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 174 | if( NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/ext/nng/CMakeLists.txt ) |
| 175 | message( FATAL_ERROR "cannot find nng in our git source as a submodule: Giving up" ) # this will abort which seems wrong, but tdam. |
| 176 | endif() |
| 177 | |
| 178 | include( ExternalProject ) |
| 179 | ExternalProject_Add( |
| 180 | ext_nng |
| 181 | SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ext/nng" |
| 182 | CMAKE_ARGS "-DBUILD_SHARED_LIBS=1" |
| 183 | CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}" |
| 184 | BUILD_COMMAND "make" |
| 185 | UPDATE_COMMAND "" |
| 186 | TEST_COMMAND "" |
| 187 | STEP_TARGETS build |
| 188 | ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 189 | |
| 190 | # it seems impossible to install everything that lands in {bin}/lib, so we need to |
| 191 | # hard code (shudder) some things. Even worse, we have to make exceptions for |
| 192 | # builds on apple (osx) since their naming convention wandered off the path. |
| 193 | set( nng_major 1 ) |
| 194 | set( nng_minor 1.0 ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 195 | set( so ${CMAKE_SHARED_LIBRARY_SUFFIX} ) # cmake variables are impossibly long :( |
| 196 | if( NOT APPLE ) # probably breaks in windows, but idc |
| 197 | set( nng_so_suffix ${so} ) |
| 198 | set( nng_so_suffix_m ${so}.${nng_major} ) |
| 199 | set( nng_so_suffix_mm ${so}.${nng_major}.${nng_minor} ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 200 | else() |
| 201 | # of course apple puts versions before the suffix :( |
| 202 | set( nng_so_suffix ${so} ) # so has a lead dot, so NOT needed |
| 203 | set( nng_so_suffix_m ".${nng_major}${so}" ) # these need leading dots |
| 204 | set( nng_so_suffix_mm ".${nng_major}.${nng_minor}${so}" ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 205 | endif() |
| 206 | |
E. Scott Daniels | b0ba22e | 2019-08-06 13:26:12 -0400 | [diff] [blame] | 207 | message( "+++ building with nng: ${nng_major}.${nng_minor}" ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 208 | else() |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 209 | if( PACK_EXTERNALS ) |
E. Scott Daniels | e30fc3a | 2019-07-16 12:03:45 -0400 | [diff] [blame] | 210 | # This makes some stand-alone unit testing possible for bindings and transport layer testing; |
| 211 | # it is not meant for production packages. |
| 212 | # |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 213 | unset( SKIP_EXTERNALS CACHE ) # must remove so as not to trap user into a never ending failure |
| 214 | unset( PACK_EXTERNALS CACHE ) |
| 215 | message( FATAL_ERROR "ERROR: PACK_EXTERNALS can be set only if SKIP_EXTERNALS is unset (=0, or not supplied on command line)" ) |
| 216 | endif() |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 217 | set( need_ext 0 ) |
| 218 | endif() |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 219 | |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 220 | |
| 221 | |
| 222 | # this gets us round a chicken/egg problem. include files don't exist until make is run |
| 223 | # but Cmake insists on having these exist when we add them to include directories to |
| 224 | # enable rmr code to find them after we build them. |
| 225 | # |
| 226 | execute_process( COMMAND "mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/include/nng" ) |
| 227 | include_directories( "${CMAKE_CURRENT_BINARY_DIR}/include" ) |
| 228 | |
| 229 | |
| 230 | # Compiler flags |
| 231 | # |
| 232 | set( CMAKE_POSITION_INDEPENDENT_CODE ON ) |
E. Scott Daniels | ec88d3c | 2019-11-13 09:40:22 -0500 | [diff] [blame] | 233 | #set( CMAKE_C_FLAGS "-g -Wall " ) |
| 234 | #set( CMAKE_C_FLAGS "-g " ) |
| 235 | if( GPROF ) # if set, we'll set profiling flag on compiles |
| 236 | message( "+++ profiling is on" ) |
| 237 | set( CMAKE_C_FLAGS "-pg " ) |
| 238 | else() |
| 239 | message( "+++ profiling is off" ) |
| 240 | set( CMAKE_C_FLAGS "-g " ) |
| 241 | endif() |
| 242 | unset( GPROF CACHE ) # we don't want this to persist |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 243 | |
| 244 | # Include modules |
E. Scott Daniels | 68c1ab2 | 2019-05-17 17:50:59 +0000 | [diff] [blame] | 245 | add_subdirectory( src/rmr/common ) |
E. Scott Daniels | 68c1ab2 | 2019-05-17 17:50:59 +0000 | [diff] [blame] | 246 | add_subdirectory( src/rmr/nng ) |
E. Scott Daniels | ec88d3c | 2019-11-13 09:40:22 -0500 | [diff] [blame] | 247 | add_subdirectory( src/rmr/si ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 248 | add_subdirectory( doc ) # this will auto skip if {X}fm is not available |
| 249 | |
| 250 | |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 251 | # shared and static libraries are built from the same object files. |
E. Scott Daniels | b0ba22e | 2019-08-06 13:26:12 -0400 | [diff] [blame] | 252 | # librmr_nng is a combination of common and nng specific rmr functions. |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 253 | # |
E. Scott Daniels | 68c5cf1 | 2019-04-12 15:14:40 +0000 | [diff] [blame] | 254 | |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 255 | add_library( rmr_nng_shared SHARED "$<TARGET_OBJECTS:nng_objects>;$<TARGET_OBJECTS:common_objects>" ) |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 256 | set_target_properties( rmr_nng_shared |
| 257 | PROPERTIES |
| 258 | OUTPUT_NAME "rmr_nng" |
| 259 | SOVERSION ${major_version} |
| 260 | VERSION ${major_version}.${minor_version}.${patch_level} ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 261 | |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 262 | # we only build/export the static archive (.a) if generating a dev package |
| 263 | if( DEV_PKG ) |
| 264 | add_library( rmr_nng_static STATIC "$<TARGET_OBJECTS:nng_objects>;$<TARGET_OBJECTS:common_objects>" ) |
| 265 | set_target_properties( rmr_nng_static |
| 266 | PROPERTIES |
| 267 | OUTPUT_NAME "rmr_nng" |
| 268 | SOVERSION ${major_version} |
| 269 | VERSION ${major_version}.${minor_version}.${patch_level} ) |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 270 | endif() |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 271 | |
E. Scott Daniels | ec88d3c | 2019-11-13 09:40:22 -0500 | [diff] [blame] | 272 | add_library( rmr_si_shared SHARED "$<TARGET_OBJECTS:rmr_si_objects>;$<TARGET_OBJECTS:common_objects>" ) |
| 273 | set_target_properties( rmr_si_shared |
| 274 | PROPERTIES |
| 275 | OUTPUT_NAME "rmr_si" |
| 276 | SOVERSION ${major_version} |
| 277 | VERSION ${major_version}.${minor_version}.${patch_level} ) |
| 278 | |
E. Scott Daniels | 0949fab | 2020-03-18 23:50:57 -0400 | [diff] [blame] | 279 | # even if not generating a development package we still need to generate the .a so that health check |
| 280 | # can link against it to avoid RPM install issues. |
| 281 | # |
| 282 | add_library( rmr_si_static STATIC "$<TARGET_OBJECTS:rmr_si_objects>;$<TARGET_OBJECTS:common_objects>" ) |
| 283 | set_target_properties( rmr_si_static |
| 284 | PROPERTIES |
| 285 | OUTPUT_NAME "rmr_si" |
| 286 | SOVERSION ${major_version} |
| 287 | VERSION ${major_version}.${minor_version}.${patch_level} ) |
E. Scott Daniels | ec88d3c | 2019-11-13 09:40:22 -0500 | [diff] [blame] | 288 | |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 289 | # if externals need to be built, then we must force them to be built first by depending on them |
| 290 | if( need_ext ) |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 291 | if( DEV_PKG ) |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 292 | add_dependencies( rmr_nng_shared;rmr_nng_static ext_nng ) |
| 293 | else() |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 294 | add_dependencies( rmr_nng_shared ext_nng ) |
| 295 | endif() |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 296 | endif() |
| 297 | |
E. Scott Daniels | fc5c77b | 2020-02-21 13:24:29 -0500 | [diff] [blame] | 298 | # ------------- testing ------------------------------------------------------- |
| 299 | enable_testing() |
| 300 | add_test( |
| 301 | NAME drive_unit_tests |
| 302 | COMMAND bash ../test/unit_test.ksh -q |
| 303 | WORKING_DIRECTORY ../test |
| 304 | ) |
| 305 | |
| 306 | # cmake seems unable to start test/app_test/run_all.ksh, so we have to lump |
| 307 | # a dummy script in ./test that does the obvious thing. |
| 308 | add_test( |
| 309 | NAME drive_app |
| 310 | COMMAND bash ./run_app_tests LD_LIBRARY_PATH=${install_root}/lib C_INCLUDE_PATH=${install_root}/include |
| 311 | WORKING_DIRECTORY ../test |
| 312 | ) |
| 313 | |
| 314 | |
| 315 | # --- support binaries that depend on the libs identified above --------------- |
| 316 | add_subdirectory( src/support ) |
| 317 | |
| 318 | # ------------- packaging ----------------------------------------------------- |
| 319 | |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 320 | # |
| 321 | if( APPLE ) |
| 322 | message( "### apple hack: forcing hard coded library paths for nng/nano dynamic libraries" ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 323 | target_link_libraries( rmr_nng_shared ${CMAKE_CURRENT_BINARY_DIR}/lib/libnng${nng_so_suffix} ) |
| 324 | endif() |
| 325 | |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 326 | # Define what should be installed, and where they should go. For dev package we install |
| 327 | # only the RMr headers, man pages and archive (.a) files. The run-time package gets just |
| 328 | # the library (.so) files and nothing more. |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 329 | # |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 330 | if( DEV_PKG ) |
E. Scott Daniels | ec88d3c | 2019-11-13 09:40:22 -0500 | [diff] [blame] | 331 | set( target_list "rmr_nng_static;rmr_si_static" ) |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 332 | else() |
E. Scott Daniels | ec88d3c | 2019-11-13 09:40:22 -0500 | [diff] [blame] | 333 | set( target_list "rmr_nng_shared;rmr_si_shared" ) |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 334 | endif() |
| 335 | |
| 336 | install( TARGETS ${target_list} EXPORT LibraryConfig |
| 337 | LIBRARY DESTINATION ${install_lib} |
| 338 | ARCHIVE DESTINATION ${install_lib} |
| 339 | PUBLIC_HEADER DESTINATION ${install_inc} |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 340 | ) |
| 341 | |
| 342 | |
E. Scott Daniels | b0ba22e | 2019-08-06 13:26:12 -0400 | [diff] [blame] | 343 | unset( DEV_PKG CACHE ) # prevent from being a hidden setting if user redoes things |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 344 | |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 345 | # install any nano/nng libraries in to the deb as well, but ONLY if asked for on the 'cmake ..' command |
| 346 | # (sure would be nice if FILEs allowed for globbing; sadlyy it does not.) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 347 | # |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 348 | if( PACK_EXTERNALS ) |
E. Scott Daniels | 257323c | 2019-06-14 12:30:21 -0400 | [diff] [blame] | 349 | message( "+++ including nano and nng libraries in the deb" ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 350 | install( FILES |
E. Scott Daniels | a943533 | 2019-05-09 14:39:19 +0000 | [diff] [blame] | 351 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libnng${nng_so_suffix} |
| 352 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libnng${nng_so_suffix_m} |
| 353 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libnng${nng_so_suffix_mm} |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 354 | |
| 355 | DESTINATION ${install_lib} |
| 356 | ) |
| 357 | endif() |
| 358 | |
E. Scott Daniels | 257323c | 2019-06-14 12:30:21 -0400 | [diff] [blame] | 359 | unset( SKIP_EXTERNALS CACHE ) # prevent these from being applied next build unless specifically set on comd line |
| 360 | unset( PACK_EXTERNALS CACHE ) |
| 361 | |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 362 | IF( EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake" ) |
| 363 | include( InstallRequiredSystemLibraries ) |
| 364 | |
E. Scott Daniels | 78da4c9 | 2019-06-19 10:59:18 -0400 | [diff] [blame] | 365 | set( CPACK_DEBIAN_PACKAGE_NAME ${deb_pkg_name} ) |
| 366 | set( CPACK_RPM_PACKAGE_NAME ${rpm_pkg_name} ) |
| 367 | |
E. Scott Daniels | 0949fab | 2020-03-18 23:50:57 -0400 | [diff] [blame] | 368 | # auto dependency checking makes the RPM install fail, see NOTES |
| 369 | set( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION="/usr/local /usr/local/bin /usr/local/lib" ) |
| 370 | |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 371 | set( CPACK_set_DESTDIR "on" ) |
| 372 | set( CPACK_PACKAGING_INSTALL_PREFIX "${install_root}" ) |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 373 | set( CPACK_GENERATOR "${pkg_list}" ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 374 | |
| 375 | set( CPACK_PACKAGE_DESCRIPTION "Thin library for RIC xAPP messaging routed based on message type." ) |
| 376 | set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "RIC message routing library" ) |
| 377 | set( CPACK_PACKAGE_VENDOR "None" ) |
| 378 | set( CPACK_PACKAGE_CONTACT "None" ) |
| 379 | set( CPACK_PACKAGE_VERSION_MAJOR "${major_version}" ) |
| 380 | set( CPACK_PACKAGE_VERSION_MINOR "${minor_version}" ) |
| 381 | set( CPACK_PACKAGE_VERSION_PATCH "${patch_level}" ) |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 382 | set( CPACK_PACKAGE "${pkg_label}" ) # generic name for old versions of cpack |
E. Scott Daniels | d4f18ba | 2019-06-17 15:08:17 -0400 | [diff] [blame] | 383 | set( CPACK_DEBIAN_FILE_NAME "${deb_pkg_label}.deb" ) |
| 384 | set( CPACK_RPM_FILE_NAME "${rpm_pkg_label}.rpm" ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 385 | |
E. Scott Daniels | b0ba22e | 2019-08-06 13:26:12 -0400 | [diff] [blame] | 386 | # there is not an NNG package, so we cannot define a dependency |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 387 | |
| 388 | set( CPACK_DEBIAN_PACKAGE_PRIORITY "optional" ) |
| 389 | set( CPACK_DEBIAN_PACKAGE_SECTION "ric" ) |
| 390 | set( CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR} ) |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 391 | set( CPACK_RPM_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR} ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 392 | |
| 393 | # this seems ingnored if included |
| 394 | #set( CPACK_COMPONENTS_ALL Libraries ApplicationData ) |
| 395 | |
| 396 | INCLUDE( CPack ) |
| 397 | ENDIF() |