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 | # |
| 22 | # -DDEV_PKG=1 Development package configuration |
| 23 | # -DBUILD_DOC=1 Man pages generated |
| 24 | # -DPRESERVE_PTYPE=1 Do not change the processor type when naming deb packages |
| 25 | # -DPACK_EXTERNALS=1 Include external libraries used to build in the run-time package |
| 26 | # -DSKIP_EXTERNALS=1 Do not use Nano/NNG submodules when building; uee installed packages |
| 27 | # -DMAN_PREFIX=<path> Supply a path where man pages are installed (default: /usr/share/man) |
| 28 | |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 29 | project( rmr LANGUAGES C ) |
| 30 | cmake_minimum_required( VERSION 3.5 ) |
| 31 | |
E. Scott Daniels | d710957 | 2019-04-18 14:01:16 +0000 | [diff] [blame] | 32 | set( major_version "1" ) # should be automatically populated from git tag later, but until CI process sets a tag we use this |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 33 | set( minor_version "0" ) |
E. Scott Daniels | 78da4c9 | 2019-06-19 10:59:18 -0400 | [diff] [blame^] | 34 | set( patch_level "36" ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 35 | |
| 36 | set( install_root "${CMAKE_INSTALL_PREFIX}" ) |
| 37 | set( install_lib "lib" ) |
| 38 | set( install_inc "include/rmr" ) |
| 39 | if( MAN_PREFIX ) |
| 40 | set( install_man ${MAN_PREFIX} ) # is there a cmake var for this -- can't find one |
| 41 | else() |
| 42 | set( install_man "/usr/share/man" ) # this needs to be fixed so it's not hard coded |
| 43 | endif() |
| 44 | |
| 45 | # Must use GNUInstallDirs to install libraries into correct |
| 46 | # locations on all platforms. |
| 47 | include( GNUInstallDirs ) |
| 48 | |
E. Scott Daniels | a943533 | 2019-05-09 14:39:19 +0000 | [diff] [blame] | 49 | # nano/nng install using LIBDIR as established by the gnu include; it varies from system |
| 50 | # to system, and we don't trust that it is always set, so we default to lib. |
| 51 | # |
| 52 | if( NOT CMAKE_INSTALL_LIBDIR ) |
| 53 | set( CMAKE_INSTALL_LIBDIR "lib" ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 54 | endif() |
| 55 | |
E. Scott Daniels | 68c5cf1 | 2019-04-12 15:14:40 +0000 | [diff] [blame] | 56 | # ---------------- extract some things from git ------------------------------ |
| 57 | |
| 58 | # commit id for the version string |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 59 | execute_process( |
| 60 | COMMAND bash -c "git rev-parse --short HEAD|awk '{printf\"%s\", $0}'" |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 61 | OUTPUT_VARIABLE git_id |
| 62 | ) |
| 63 | |
E. Scott Daniels | 68c5cf1 | 2019-04-12 15:14:40 +0000 | [diff] [blame] | 64 | # version information for library names and version string |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 65 | execute_process( |
E. Scott Daniels | 68c5cf1 | 2019-04-12 15:14:40 +0000 | [diff] [blame] | 66 | 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' " |
| 67 | OUTPUT_VARIABLE mmp_version_str |
| 68 | ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE |
| 69 | ) |
| 70 | |
| 71 | # 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] | 72 | # (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] | 73 | # string. |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 74 | execute_process( |
| 75 | 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] | 76 | OUTPUT_VARIABLE spoiled_str |
| 77 | ) |
| 78 | |
E. Scott Daniels | d710957 | 2019-04-18 14:01:16 +0000 | [diff] [blame] | 79 | # uncomment these lines once CI starts adding a tag on merge |
| 80 | #set( mmp_version ${mmp_version_str} ) |
| 81 | #list( GET mmp_version 0 major_version ) |
| 82 | #list( GET mmp_version 1 minor_version ) |
| 83 | #list( GET mmp_version 2 patch_level ) |
E. Scott Daniels | 68c5cf1 | 2019-04-12 15:14:40 +0000 | [diff] [blame] | 84 | |
E. Scott Daniels | 68c5cf1 | 2019-04-12 15:14:40 +0000 | [diff] [blame] | 85 | |
| 86 | # define constants used in the version string |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 87 | add_definitions( |
| 88 | -DGIT_ID=${git_id} |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 89 | -DMAJOR_VER=${major_version} |
| 90 | -DMINOR_VER=${minor_version} |
E. Scott Daniels | d4f18ba | 2019-06-17 15:08:17 -0400 | [diff] [blame] | 91 | -DPATCH_VER=${patch_level} |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 92 | ) |
| 93 | |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 94 | # ---------------- suss out pkg gen tools so we don't fail generating packages that the system cannot support -------------- |
| 95 | |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 96 | # deb packages use underbars, and package manager(s) seem to flip the *_64 processor type |
| 97 | # to the old (non-standard) amd64 string, so we do it here for consistency. Set -DPRESERVE_PTYPE=1 |
| 98 | # to prevent the flip. RPM packages will always be given the system generated processor type string. |
| 99 | # |
| 100 | if( ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" ) |
| 101 | if( NOT PRESERVE_PTYPE ) |
| 102 | set( deb_sys_name "amd64" ) |
| 103 | else() |
| 104 | set( deb_sys_name ${CMAKE_SYSTEM_PROCESSOR} ) |
| 105 | endif() |
| 106 | else() |
| 107 | set( deb_sys_name ${CMAKE_SYSTEM_PROCESSOR} ) |
| 108 | endif() |
| 109 | unset( PRESERVE_PTYPE CACHE ) # we don't want this to persist |
| 110 | |
| 111 | set( rpm_sys_name ${CMAKE_SYSTEM_PROCESSOR} ) |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 112 | |
| 113 | if( DEV_PKG ) |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 114 | set( deb_pkg_name "rmr-dev" ) |
| 115 | set( rpm_pkg_name "rmr-devel" ) |
E. Scott Daniels | d4f18ba | 2019-06-17 15:08:17 -0400 | [diff] [blame] | 116 | else() |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 117 | set( deb_pkg_name "rmr" ) |
| 118 | set( rpm_pkg_name "rmr" ) |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 119 | endif() |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 120 | |
| 121 | set( pkg_label "rmr${spoiled_str}-${major_version}.${minor_version}.${patch_level}-${sys_name}" ) |
| 122 | set( rpm_pkg_label "${rpm_pkg_name}${spoiled_str}-${major_version}.${minor_version}.${patch_level}-${rpm_sys_name}" ) |
| 123 | set( deb_pkg_label "${deb_pkg_name}${spoiled_str}_${major_version}.${minor_version}.${patch_level}_${deb_sys_name}" ) |
| 124 | message( "+++ pkg name: ${deb_pkg_label}.deb" ) |
| 125 | message( "+++ pkg name: ${rpm_pkg_label}.rpm" ) |
| 126 | |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 127 | set( out_yml /tmp/build_output.yml ) # we will record package names (we record only untainted names) |
| 128 | find_program( rpm NAMES rpmbuild ) # rpm package gen requires this to be installed |
| 129 | |
| 130 | set( gen_rpm 0 ) |
| 131 | if( "${rpm}" MATCHES "rpm-NOTFOUND" ) # cannot build rpm |
| 132 | set( pkg_list "DEB" ) |
| 133 | message( "### make package will generate only deb package; cannot find support to generate rpm packages" ) |
| 134 | else() |
| 135 | set( pkg_list "DEB;RPM" ) |
| 136 | set( gen_rpm 1 ) |
| 137 | message( "+++ make package will generate both deb and rpm packages" ) |
| 138 | endif() |
| 139 | |
| 140 | execute_process( |
| 141 | COMMAND bash -c "printf '# RMr build generated list of package paths\n---\n' >${out_yml}" |
E. Scott Daniels | 8a03ad0 | 2019-06-11 15:57:02 -0400 | [diff] [blame] | 142 | ) |
| 143 | |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 144 | execute_process( |
E. Scott Daniels | d4f18ba | 2019-06-17 15:08:17 -0400 | [diff] [blame] | 145 | COMMAND bash -c " echo deb: ${CMAKE_CURRENT_BINARY_DIR}/${deb_pkg_label}.deb >>${out_yml}" |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 146 | ) |
| 147 | |
| 148 | if( gen_rpm ) |
| 149 | execute_process( |
E. Scott Daniels | d4f18ba | 2019-06-17 15:08:17 -0400 | [diff] [blame] | 150 | COMMAND bash -c " echo rpm: ${CMAKE_CURRENT_BINARY_DIR}/${rpm_pkg_label}.rpm >>${out_yml}" |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 151 | ) |
| 152 | endif() |
| 153 | |
| 154 | execute_process( |
| 155 | COMMAND bash -c "printf '...\n' >>${out_yml}" |
| 156 | ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 157 | |
| 158 | # ---------------- setup nano/nng things --------------------------------------- |
| 159 | if( NOT SKIP_EXTERNALS ) |
| 160 | set( need_ext 1 ) # we force dependences on these for right build order |
| 161 | execute_process( COMMAND git submodule update --init -- ext/nng |
| 162 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
| 163 | ) |
| 164 | |
| 165 | execute_process( COMMAND git submodule update --init -- ext/nanomsg |
| 166 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
| 167 | ) |
| 168 | if( NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/ext/nng/CMakeLists.txt ) |
| 169 | message( FATAL_ERROR "cannot find nng in our git source as a submodule: Giving up" ) # this will abort which seems wrong, but tdam. |
| 170 | endif() |
| 171 | |
| 172 | include( ExternalProject ) |
| 173 | ExternalProject_Add( |
| 174 | ext_nng |
| 175 | SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ext/nng" |
| 176 | CMAKE_ARGS "-DBUILD_SHARED_LIBS=1" |
| 177 | CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}" |
| 178 | BUILD_COMMAND "make" |
| 179 | UPDATE_COMMAND "" |
| 180 | TEST_COMMAND "" |
| 181 | STEP_TARGETS build |
| 182 | ) |
| 183 | ExternalProject_Add( |
| 184 | nanomsg |
| 185 | SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ext/nanomsg" |
| 186 | BUILD_COMMAND "make" |
| 187 | UPDATE_COMMAND "" |
| 188 | CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}" |
| 189 | TEST_COMMAND "" |
| 190 | STEP_TARGETS build |
| 191 | ) |
| 192 | |
| 193 | # it seems impossible to install everything that lands in {bin}/lib, so we need to |
| 194 | # hard code (shudder) some things. Even worse, we have to make exceptions for |
| 195 | # builds on apple (osx) since their naming convention wandered off the path. |
| 196 | set( nng_major 1 ) |
| 197 | set( nng_minor 1.0 ) |
| 198 | set( nano_major 5 ) |
| 199 | set( nano_minor 1.0 ) |
| 200 | set( so ${CMAKE_SHARED_LIBRARY_SUFFIX} ) # cmake variables are impossibly long :( |
| 201 | if( NOT APPLE ) # probably breaks in windows, but idc |
| 202 | set( nng_so_suffix ${so} ) |
| 203 | set( nng_so_suffix_m ${so}.${nng_major} ) |
| 204 | set( nng_so_suffix_mm ${so}.${nng_major}.${nng_minor} ) |
| 205 | |
| 206 | set( nano_so_suffix ${so} ) |
| 207 | set( nano_so_suffix_m ${so}.${nano_major} ) |
| 208 | set( nano_so_suffix_mm ${so}.${nano_major}.${nano_minor} ) |
| 209 | else() |
| 210 | # of course apple puts versions before the suffix :( |
| 211 | set( nng_so_suffix ${so} ) # so has a lead dot, so NOT needed |
| 212 | set( nng_so_suffix_m ".${nng_major}${so}" ) # these need leading dots |
| 213 | set( nng_so_suffix_mm ".${nng_major}.${nng_minor}${so}" ) |
| 214 | |
| 215 | set( nano_so_suffix ${so} ) |
| 216 | set( nano_so_suffix_m ".${nano_major}${so}" ) |
| 217 | set( nano_so_suffix_mm ".${nano_major}.${nano_minor}${so}" ) |
| 218 | endif() |
| 219 | |
| 220 | message( "+++ installing nano/nng with: ${nano_major}.${nano_minor} | ${nng_major}.${nng_minor}" ) |
| 221 | else() |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 222 | if( PACK_EXTERNALS ) |
| 223 | unset( SKIP_EXTERNALS CACHE ) # must remove so as not to trap user into a never ending failure |
| 224 | unset( PACK_EXTERNALS CACHE ) |
| 225 | message( FATAL_ERROR "ERROR: PACK_EXTERNALS can be set only if SKIP_EXTERNALS is unset (=0, or not supplied on command line)" ) |
| 226 | endif() |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 227 | set( need_ext 0 ) |
| 228 | endif() |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 229 | |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 230 | |
| 231 | |
| 232 | # this gets us round a chicken/egg problem. include files don't exist until make is run |
| 233 | # but Cmake insists on having these exist when we add them to include directories to |
| 234 | # enable rmr code to find them after we build them. |
| 235 | # |
| 236 | execute_process( COMMAND "mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/include/nng" ) |
| 237 | include_directories( "${CMAKE_CURRENT_BINARY_DIR}/include" ) |
| 238 | |
| 239 | |
| 240 | # Compiler flags |
| 241 | # |
| 242 | set( CMAKE_POSITION_INDEPENDENT_CODE ON ) |
| 243 | set( CMAKE_CXX_FLAGS "-g -Wall " ) |
| 244 | |
| 245 | # Include modules |
E. Scott Daniels | 68c1ab2 | 2019-05-17 17:50:59 +0000 | [diff] [blame] | 246 | add_subdirectory( src/rmr/common ) |
| 247 | add_subdirectory( src/rmr/nanomsg ) |
| 248 | add_subdirectory( src/rmr/nng ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 249 | add_subdirectory( doc ) # this will auto skip if {X}fm is not available |
| 250 | |
| 251 | |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 252 | # shared and static libraries are built from the same object files. |
| 253 | # Nanomsg based library (librmr ) while nng based is librmr_nng. |
| 254 | # library is built by pulling object files from either the nano or nng and common subdirs |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 255 | # |
| 256 | add_library( rmr_shared SHARED "$<TARGET_OBJECTS:nano_objects>;$<TARGET_OBJECTS:common_objects>" ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 257 | |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 258 | set_target_properties( rmr_shared |
| 259 | PROPERTIES |
| 260 | OUTPUT_NAME "rmr" |
| 261 | SOVERSION ${major_version} |
E. Scott Daniels | 68c5cf1 | 2019-04-12 15:14:40 +0000 | [diff] [blame] | 262 | VERSION ${major_version}.${minor_version}.${patch_level} ) |
| 263 | |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 264 | 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] | 265 | set_target_properties( rmr_nng_shared |
| 266 | PROPERTIES |
| 267 | OUTPUT_NAME "rmr_nng" |
| 268 | SOVERSION ${major_version} |
| 269 | VERSION ${major_version}.${minor_version}.${patch_level} ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 270 | |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 271 | # we only build/export the static archive (.a) if generating a dev package |
| 272 | if( DEV_PKG ) |
| 273 | add_library( rmr_nng_static STATIC "$<TARGET_OBJECTS:nng_objects>;$<TARGET_OBJECTS:common_objects>" ) |
| 274 | set_target_properties( rmr_nng_static |
| 275 | PROPERTIES |
| 276 | OUTPUT_NAME "rmr_nng" |
| 277 | SOVERSION ${major_version} |
| 278 | VERSION ${major_version}.${minor_version}.${patch_level} ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 279 | |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 280 | add_library( rmr_static STATIC "$<TARGET_OBJECTS:nano_objects>;$<TARGET_OBJECTS:common_objects>" ) |
| 281 | |
| 282 | set_target_properties( rmr_static |
| 283 | PROPERTIES |
| 284 | OUTPUT_NAME "rmr" |
| 285 | SOVERSION ${major_version} |
| 286 | VERSION ${major_version}.${minor_version}.${patch_level} ) |
| 287 | endif() |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 288 | |
| 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 ) |
| 292 | add_dependencies( rmr_static;rmr_shared nanomsg ) |
| 293 | add_dependencies( rmr_nng_shared;rmr_nng_static ext_nng ) |
| 294 | else() |
| 295 | add_dependencies( rmr_shared nanomsg ) |
| 296 | add_dependencies( rmr_nng_shared ext_nng ) |
| 297 | endif() |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 298 | endif() |
| 299 | |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 300 | # |
| 301 | if( APPLE ) |
| 302 | message( "### apple hack: forcing hard coded library paths for nng/nano dynamic libraries" ) |
| 303 | target_link_libraries( rmr_shared ${CMAKE_CURRENT_BINARY_DIR}/lib/libnanomsg${nano_so_suffix} ) |
| 304 | target_link_libraries( rmr_nng_shared ${CMAKE_CURRENT_BINARY_DIR}/lib/libnng${nng_so_suffix} ) |
| 305 | endif() |
| 306 | |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 307 | # Define what should be installed, and where they should go. For dev package we install |
| 308 | # only the RMr headers, man pages and archive (.a) files. The run-time package gets just |
| 309 | # the library (.so) files and nothing more. |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 310 | # |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 311 | if( DEV_PKG ) |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 312 | set( target_list "rmr_nng_static;rmr_static" ) |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 313 | else() |
| 314 | set( target_list "rmr_nng_shared;rmr_shared" ) |
| 315 | endif() |
| 316 | |
| 317 | install( TARGETS ${target_list} EXPORT LibraryConfig |
| 318 | LIBRARY DESTINATION ${install_lib} |
| 319 | ARCHIVE DESTINATION ${install_lib} |
| 320 | PUBLIC_HEADER DESTINATION ${install_inc} |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 321 | ) |
| 322 | |
| 323 | |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 324 | unset( DEV_PKG CACHE ) # prevent from being a hiddent setting if user redoes things |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 325 | |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 326 | # install any nano/nng libraries in to the deb as well, but ONLY if asked for on the 'cmake ..' command |
| 327 | # (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] | 328 | # |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 329 | if( PACK_EXTERNALS ) |
E. Scott Daniels | 257323c | 2019-06-14 12:30:21 -0400 | [diff] [blame] | 330 | message( "+++ including nano and nng libraries in the deb" ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 331 | install( FILES |
E. Scott Daniels | a943533 | 2019-05-09 14:39:19 +0000 | [diff] [blame] | 332 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libnanomsg${nano_so_suffix} |
| 333 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libnanomsg${nano_so_suffix_m} |
| 334 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libnanomsg${nano_so_suffix_mm} |
| 335 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libnng${nng_so_suffix} |
| 336 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libnng${nng_so_suffix_m} |
| 337 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libnng${nng_so_suffix_mm} |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 338 | |
| 339 | DESTINATION ${install_lib} |
| 340 | ) |
| 341 | endif() |
| 342 | |
E. Scott Daniels | 257323c | 2019-06-14 12:30:21 -0400 | [diff] [blame] | 343 | unset( SKIP_EXTERNALS CACHE ) # prevent these from being applied next build unless specifically set on comd line |
| 344 | unset( PACK_EXTERNALS CACHE ) |
| 345 | |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 346 | IF( EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake" ) |
| 347 | include( InstallRequiredSystemLibraries ) |
| 348 | |
E. Scott Daniels | 78da4c9 | 2019-06-19 10:59:18 -0400 | [diff] [blame^] | 349 | set( CPACK_DEBIAN_PACKAGE_NAME ${deb_pkg_name} ) |
| 350 | set( CPACK_RPM_PACKAGE_NAME ${rpm_pkg_name} ) |
| 351 | |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 352 | set( CPACK_set_DESTDIR "on" ) |
| 353 | set( CPACK_PACKAGING_INSTALL_PREFIX "${install_root}" ) |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 354 | set( CPACK_GENERATOR "${pkg_list}" ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 355 | |
| 356 | set( CPACK_PACKAGE_DESCRIPTION "Thin library for RIC xAPP messaging routed based on message type." ) |
| 357 | set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "RIC message routing library" ) |
| 358 | set( CPACK_PACKAGE_VENDOR "None" ) |
| 359 | set( CPACK_PACKAGE_CONTACT "None" ) |
| 360 | set( CPACK_PACKAGE_VERSION_MAJOR "${major_version}" ) |
| 361 | set( CPACK_PACKAGE_VERSION_MINOR "${minor_version}" ) |
| 362 | set( CPACK_PACKAGE_VERSION_PATCH "${patch_level}" ) |
E. Scott Daniels | f6f4f12 | 2019-06-18 16:02:17 -0400 | [diff] [blame] | 363 | 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] | 364 | set( CPACK_DEBIAN_FILE_NAME "${deb_pkg_label}.deb" ) |
| 365 | set( CPACK_RPM_FILE_NAME "${rpm_pkg_label}.rpm" ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 366 | |
| 367 | # we build and ship the libraries, so there is NO dependency |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 368 | |
| 369 | set( CPACK_DEBIAN_PACKAGE_PRIORITY "optional" ) |
| 370 | set( CPACK_DEBIAN_PACKAGE_SECTION "ric" ) |
| 371 | set( CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR} ) |
E. Scott Daniels | 29d8716 | 2019-06-12 13:48:25 -0400 | [diff] [blame] | 372 | set( CPACK_RPM_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR} ) |
Ashwin Sridharan | fd9cc7a | 2019-04-03 16:47:02 -0400 | [diff] [blame] | 373 | |
| 374 | # this seems ingnored if included |
| 375 | #set( CPACK_COMPONENTS_ALL Libraries ApplicationData ) |
| 376 | |
| 377 | INCLUDE( CPack ) |
| 378 | ENDIF() |