X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=CMakeLists.txt;h=7e273584fb7e3cca19f05a98fabd6f612db53136;hb=a7610c690a3976e296ca768977e38ceb9aafa5ff;hp=c9ca0ed7a184288df80a17ad3dd24a133a7a2912;hpb=105ca74aa26c2f42c230af78f181c223786cefea;p=ric-plt%2Flib%2Frmr.git diff --git a/CMakeLists.txt b/CMakeLists.txt index c9ca0ed..7e27358 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,12 +17,21 @@ #================================================================================== # +# This CMake definition supports several -D command line options: +# +# -DDEV_PKG=1 Development package configuration +# -DBUILD_DOC=1 Man pages generated +# -DPRESERVE_PTYPE=1 Do not change the processor type when naming deb packages +# -DPACK_EXTERNALS=1 Include external libraries used to build in the run-time package +# -DSKIP_EXTERNALS=1 Do not use Nano/NNG submodules when building; uee installed packages +# -DMAN_PREFIX= Supply a path where man pages are installed (default: /usr/share/man) + project( rmr LANGUAGES C ) cmake_minimum_required( VERSION 3.5 ) set( major_version "1" ) # should be automatically populated from git tag later, but until CI process sets a tag we use this set( minor_version "0" ) -set( patch_level "34" ) +set( patch_level "37" ) set( install_root "${CMAKE_INSTALL_PREFIX}" ) set( install_lib "lib" ) @@ -79,17 +88,42 @@ add_definitions( -DGIT_ID=${git_id} -DMAJOR_VER=${major_version} -DMINOR_VER=${minor_version} - -DPATCH_VER=${patch_level}${spoiled_str} + -DPATCH_VER=${patch_level} ) # ---------------- suss out pkg gen tools so we don't fail generating packages that the system cannot support -------------- +# deb packages use underbars, and package manager(s) seem to flip the *_64 processor type +# to the old (non-standard) amd64 string, so we do it here for consistency. Set -DPRESERVE_PTYPE=1 +# to prevent the flip. RPM packages will always be given the system generated processor type string. +# +if( ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" ) + if( NOT PRESERVE_PTYPE ) + set( deb_sys_name "amd64" ) + else() + set( deb_sys_name ${CMAKE_SYSTEM_PROCESSOR} ) + endif() +else() + set( deb_sys_name ${CMAKE_SYSTEM_PROCESSOR} ) +endif() +unset( PRESERVE_PTYPE CACHE ) # we don't want this to persist + +set( rpm_sys_name ${CMAKE_SYSTEM_PROCESSOR} ) if( DEV_PKG ) - set( dev_tag "-dev" ) + set( deb_pkg_name "rmr-dev" ) + set( rpm_pkg_name "rmr-devel" ) +else() + set( deb_pkg_name "rmr" ) + set( rpm_pkg_name "rmr" ) endif() -set( pkg_label "${CMAKE_PROJECT_NAME}-${major_version}.${minor_version}.${patch_level}.${CMAKE_SYSTEM_PROCESSOR}${dev_tag}" ) -message( "+++ building ${pkg_label}${spoiled_str}" ) + +set( pkg_label "rmr${spoiled_str}-${major_version}.${minor_version}.${patch_level}-${sys_name}" ) +set( rpm_pkg_label "${rpm_pkg_name}${spoiled_str}-${major_version}.${minor_version}.${patch_level}-${rpm_sys_name}" ) +set( deb_pkg_label "${deb_pkg_name}${spoiled_str}_${major_version}.${minor_version}.${patch_level}_${deb_sys_name}" ) +message( "+++ pkg name: ${deb_pkg_label}.deb" ) +message( "+++ pkg name: ${rpm_pkg_label}.rpm" ) + set( out_yml /tmp/build_output.yml ) # we will record package names (we record only untainted names) find_program( rpm NAMES rpmbuild ) # rpm package gen requires this to be installed @@ -108,12 +142,12 @@ execute_process( ) execute_process( - COMMAND bash -c " echo deb: ${CMAKE_CURRENT_BINARY_DIR}/${pkg_label}.deb >>${out_yml}" + COMMAND bash -c " echo deb: ${CMAKE_CURRENT_BINARY_DIR}/${deb_pkg_label}.deb >>${out_yml}" ) if( gen_rpm ) execute_process( - COMMAND bash -c " echo rpm: ${CMAKE_CURRENT_BINARY_DIR}/${pkg_label}.rpm >>${out_yml}" + COMMAND bash -c " echo rpm: ${CMAKE_CURRENT_BINARY_DIR}/${rpm_pkg_label}.rpm >>${out_yml}" ) endif() @@ -270,14 +304,12 @@ if( APPLE ) target_link_libraries( rmr_nng_shared ${CMAKE_CURRENT_BINARY_DIR}/lib/libnng${nng_so_suffix} ) endif() -# Define directories where package should drop things when installed -# In CMake speak archive == *.a library == *.so, so both are needed -# Headers from the common directory are forced to install by the local CM file in common. At -# the moment, there are no header files specific to either nano or nng, so to the public -# header directive is moot, but needed if some day there is one. +# Define what should be installed, and where they should go. For dev package we install +# only the RMr headers, man pages and archive (.a) files. The run-time package gets just +# the library (.so) files and nothing more. # if( DEV_PKG ) - set( target_list "rmr_nng_shared;rmr_nng_static;rmr_shared;rmr_static" ) + set( target_list "rmr_nng_static;rmr_static" ) else() set( target_list "rmr_nng_shared;rmr_shared" ) endif() @@ -314,6 +346,9 @@ unset( PACK_EXTERNALS CACHE ) IF( EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake" ) include( InstallRequiredSystemLibraries ) + set( CPACK_DEBIAN_PACKAGE_NAME ${deb_pkg_name} ) + set( CPACK_RPM_PACKAGE_NAME ${rpm_pkg_name} ) + set( CPACK_set_DESTDIR "on" ) set( CPACK_PACKAGING_INSTALL_PREFIX "${install_root}" ) set( CPACK_GENERATOR "${pkg_list}" ) @@ -325,7 +360,9 @@ IF( EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake" ) set( CPACK_PACKAGE_VERSION_MAJOR "${major_version}" ) set( CPACK_PACKAGE_VERSION_MINOR "${minor_version}" ) set( CPACK_PACKAGE_VERSION_PATCH "${patch_level}" ) - set( CPACK_PACKAGE_FILE_NAME "${pkg_label}${spoiled_str}" ) + set( CPACK_PACKAGE "${pkg_label}" ) # generic name for old versions of cpack + set( CPACK_DEBIAN_FILE_NAME "${deb_pkg_label}.deb" ) + set( CPACK_RPM_FILE_NAME "${rpm_pkg_label}.rpm" ) # we build and ship the libraries, so there is NO dependency