#==================================================================================
#
+# 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=<path> 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 "39" )
set( install_root "${CMAKE_INSTALL_PREFIX}" )
set( install_lib "lib" )
-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
)
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()
set( need_ext 0 )
endif()
-unset( SKIP_EXTERNALS CACHE ) # prevent these from being applied next build unless specifically set on comd line
-unset( PACK_EXTERNALS CACHE )
# this gets us round a chicken/egg problem. include files don't exist until make is run
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()
# (sure would be nice if FILEs allowed for globbing; sadlyy it does not.)
#
if( PACK_EXTERNALS )
- message( "including nano and nng libraries in the deb" )
+ message( "+++ including nano and nng libraries in the deb" )
install( FILES
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libnanomsg${nano_so_suffix}
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libnanomsg${nano_so_suffix_m}
)
endif()
+unset( SKIP_EXTERNALS CACHE ) # prevent these from being applied next build unless specifically set on comd line
+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}" )
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