X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=CMakeLists.txt;h=225c5f79aa6e1fadee62bdb62f9bcd2656394176;hb=f7d44570f8de6e15f768e8e2d9b6061cd0bff11f;hp=9371ce3b82161af967e5b77cd447e6af2fc8b5de;hpb=aa0b497f216ebd8bc72850bf4af5c9f35c288b65;p=ric-plt%2Flib%2Frmr.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 9371ce3..225c5f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,10 +21,9 @@ project( rmr LANGUAGES C ) cmake_minimum_required( VERSION 3.5 ) - -set( major_version "1" ) +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 "16" ) +set( patch_level "25" ) set( install_root "${CMAKE_INSTALL_PREFIX}" ) set( install_lib "lib" ) @@ -39,21 +38,50 @@ endif() # locations on all platforms. include( GNUInstallDirs ) -if( NOT BUILD_LIB ) - set( BUILD_LIB lib ) +# nano/nng install using LIBDIR as established by the gnu include; it varies from system +# to system, and we don't trust that it is always set, so we default to lib. +# +if( NOT CMAKE_INSTALL_LIBDIR ) + set( CMAKE_INSTALL_LIBDIR "lib" ) endif() -# ---------------- set version info (not perfect, but better than nothing) ---- +# ---------------- extract some things from git ------------------------------ + +# commit id for the version string execute_process( COMMAND bash -c "git rev-parse --short HEAD|awk '{printf\"%s\", $0}'" OUTPUT_VARIABLE git_id ) +# version information for library names and version string +execute_process( + 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' " + OUTPUT_VARIABLE mmp_version_str + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE +) + +# extra indicator to show that the build was based on modified file(s) and not the true commit +# (no hope of reproducing the exact library for debugging). Used only for the internal version +# string. +execute_process( + COMMAND bash -c "git diff --shortstat|awk -v fmt=%s -v r=-rotten '{ s=r } END { printf( fmt, s ) }'" + OUTPUT_VARIABLE spoiled_str +) + +# uncomment these lines once CI starts adding a tag on merge +#set( mmp_version ${mmp_version_str} ) +#list( GET mmp_version 0 major_version ) +#list( GET mmp_version 1 minor_version ) +#list( GET mmp_version 2 patch_level ) + +message( "+++ building ${major_version}.${minor_version}.${patch_level}${spoiled_str}" ) + +# define constants used in the version string add_definitions( -DGIT_ID=${git_id} -DMAJOR_VER=${major_version} -DMINOR_VER=${minor_version} - -DPATCH_VER=${patch_level} + -DPATCH_VER=${patch_level}${spoiled_str} ) @@ -153,13 +181,22 @@ add_subdirectory( doc ) # this will auto skip if {X}fm is not available add_library( rmr_shared SHARED "$;$" ) add_library( rmr_static STATIC "$;$" ) -# both libraries to be named with librmr prefix -set_target_properties( rmr_shared PROPERTIES OUTPUT_NAME "rmr" ) -set_target_properties( rmr_static PROPERTIES OUTPUT_NAME "rmr" ) +# both libraries to be named with librmr prefix and given version numbers with sym links +set_target_properties( rmr_shared + PROPERTIES + OUTPUT_NAME "rmr" + SOVERSION ${major_version} + VERSION ${major_version}.${minor_version}.${patch_level} ) + +set_target_properties( rmr_static + PROPERTIES + OUTPUT_NAME "rmr" + SOVERSION ${major_version} + VERSION ${major_version}.${minor_version}.${patch_level} ) # NNG based library (librmr_nng ) -# library is built by pulling objects from nng and common subdirs +# library is built by pulling objects from nng and common subdirs. # add_library( rmr_nng_shared SHARED "$;$" ) add_library( rmr_nng_static STATIC "$;$" ) @@ -173,10 +210,18 @@ if( need_ext ) endif() -# both libraries to be named with librmr_nng prefix -# -set_target_properties( rmr_nng_shared PROPERTIES OUTPUT_NAME "rmr_nng" ) -set_target_properties( rmr_nng_static PROPERTIES OUTPUT_NAME "rmr_nng" ) +# both libraries to be named with librmr_nng prefix and given version numbers with sym links +set_target_properties( rmr_nng_shared + PROPERTIES + OUTPUT_NAME "rmr_nng" + SOVERSION ${major_version} + VERSION ${major_version}.${minor_version}.${patch_level} ) + +set_target_properties( rmr_nng_static + PROPERTIES + OUTPUT_NAME "rmr_nng" + SOVERSION ${major_version} + VERSION ${major_version}.${minor_version}.${patch_level} ) # if( APPLE ) @@ -191,6 +236,7 @@ endif() # 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. # +#install( TARGETS rmr_nng_shared;rmr_nng_static;rmr_shared;rmr_static;rmr_nng_shared_mm EXPORT LibraryConfig install( TARGETS rmr_nng_shared;rmr_nng_static;rmr_shared;rmr_static EXPORT LibraryConfig ARCHIVE DESTINATION ${install_lib} LIBRARY DESTINATION ${install_lib} @@ -205,12 +251,12 @@ install( TARGETS rmr_nng_shared;rmr_nng_static;rmr_shared;rmr_static EXPORT Libr if( need_ext ) message( "including nano and nng libraries in the deb" ) install( FILES - ${CMAKE_CURRENT_BINARY_DIR}/${BUILD_LIB}/libnanomsg${nano_so_suffix} - ${CMAKE_CURRENT_BINARY_DIR}/${BUILD_LIB}/libnanomsg${nano_so_suffix_m} - ${CMAKE_CURRENT_BINARY_DIR}/${BUILD_LIB}/libnanomsg${nano_so_suffix_mm} - ${CMAKE_CURRENT_BINARY_DIR}/${BUILD_LIB}/libnng${nng_so_suffix} - ${CMAKE_CURRENT_BINARY_DIR}/${BUILD_LIB}/libnng${nng_so_suffix_m} - ${CMAKE_CURRENT_BINARY_DIR}/${BUILD_LIB}/libnng${nng_so_suffix_mm} + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libnanomsg${nano_so_suffix} + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libnanomsg${nano_so_suffix_m} + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libnanomsg${nano_so_suffix_mm} + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libnng${nng_so_suffix} + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libnng${nng_so_suffix_m} + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libnng${nng_so_suffix_mm} DESTINATION ${install_lib} ) @@ -231,7 +277,7 @@ 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 "${CMAKE_PROJECT_NAME}_${major_version}.${minor_version}.${CPACK_PACKAGE_VERSION_PATCH}" ) + set( CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${major_version}.${minor_version}.${CPACK_PACKAGE_VERSION_PATCH}${spoiled_str}" ) set( CPACK_SOURCE_PACKAGE_FILE_NAME "vric${CMAKE_PROJECT_NAME}_${major_version}.${minor_version}.${CPACK_PACKAGE_VERSION_PATCH}" ) # we build and ship the libraries, so there is NO dependency