#==================================================================================
#
+# 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 "35" )
set( install_root "${CMAKE_INSTALL_PREFIX}" )
set( install_lib "lib" )
# ---------------- 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( pkg_name "rmr-dev" )
+ set( deb_pkg_name "rmr-dev" )
+ set( rpm_pkg_name "rmr-devel" )
else()
- set( pkg_name "rmr" )
+ set( deb_pkg_name "rmr" )
+ set( rpm_pkg_name "rmr" )
endif()
-set( rpm_pkg_label "${CMAKE_PROJECT_NAME}${dev_tag}${spoiled_str}-${major_version}.${minor_version}.${patch_level}-${CMAKE_SYSTEM_PROCESSOR}" )
-set( deb_pkg_label "${CMAKE_PROJECT_NAME}${dev_tag}${spoiled_str}_${major_version}.${minor_version}.${patch_level}_${CMAKE_SYSTEM_PROCESSOR}" )
-message( "+++ building ${deb_pkg_label}" )
-message( "+++ building ${rpm_pkg_label}" )
+
+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
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()
set( CPACK_PACKAGE_VERSION_MAJOR "${major_version}" )
set( CPACK_PACKAGE_VERSION_MINOR "${minor_version}" )
set( CPACK_PACKAGE_VERSION_PATCH "${patch_level}" )
+ 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" )
# stash a set of packages for a particular flavour ($1)
#
function stash_pkgs {
- echo " - $1:" >>$yaml_file # add package flavour (dev, runtime, etc)
-
for pkg in deb rpm
do
ls .build/*.$pkg 2>/dev/null | while read f
do
cp $f $target_dir/${f##*/}
- echo " $pkg: $target_dir/${f##*/}" >>$yaml_file
+ echo " - $target_dir/${f##*/}" >>$yaml_file
done
done
ksh run_all.ksh # application based tests if units pass
)
-# initialise the yaml file
-cat <<-endKat >$yaml_file
----
-# package types which might be listed below
-pkg_types:
- - deb
- - rpm
-
-packages:
-endKat
+printf "---\nfiles:\n" >$yaml_file # initialise the yaml file
stash_pkgs development # testing good, stash dev packages built above