Fix msg init bug when pulling msg from the poo2
[ric-plt/lib/rmr.git] / CMakeLists.txt
index e005e50..ae986c9 100644 (file)
@@ -19,6 +19,7 @@
 
 # This CMake definition supports several -D command line options:
 #
+#      -DDEBUG=n                       Enable debugging level n
 #      -DDEV_PKG=1                     Development package configuration
 #      -DBUILD_DOC=1           Man pages generated
 #      -DIGNORE_LIBDIR=1       Installation of rmr libries is into /usr/local/lib and ignores
 #      -DPACK_EXTERNALS=1      Include external libraries used to build in the run-time package
 #                                              (This makes some stand-alone unit testing of bindings possible, it
 #                                              is not meant to be used for production package generation.)
+#      -DGPROF=1                       Enable profiling compile time flags
 #      -DSKIP_EXTERNALS=1      Do not use NNG submodule when building; uee installed packages
 #      -DMAN_PREFIX=<path>     Supply a path where man pages are installed (default: /usr/share/man)
 
+#      See ci/build_all for an example of how to build and test
+
 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 "11" )
-set( patch_level "0" )
+set( major_version "3" )               # should be automatically populated from git tag later, but until CI process sets a tag we use this
+set( minor_version "6" )
+set( patch_level "2" )
 
 set( install_root "${CMAKE_INSTALL_PREFIX}" )
 set( install_inc "include/rmr" )
@@ -100,10 +104,11 @@ if( DEBUG )                                       # if set, we'll set debugging on in the compile
        message( "+++ debugging is being set to ${DEBUG}" )
 else()
        set( debugging 0 )
-        message( "+++ debugging is set to off" )
+       message( "+++ debugging is set to off" )
 endif()
 unset( DEBUG CACHE )                                   # we don't want this to persist
 
+
 # define constants used in the version string, debugging, etc.
 add_definitions(
        -DGIT_ID=${git_id}
@@ -225,11 +230,21 @@ include_directories( "${CMAKE_CURRENT_BINARY_DIR}/include" )
 # Compiler flags
 #
 set( CMAKE_POSITION_INDEPENDENT_CODE ON )
-set( CMAKE_CXX_FLAGS "-g -Wall " )
+#set( CMAKE_C_FLAGS "-g -Wall " )
+#set( CMAKE_C_FLAGS "-g " )
+if( GPROF )                                    # if set, we'll set profiling flag on compiles
+       message( "+++ profiling is on" )
+       set( CMAKE_C_FLAGS "-pg " )
+else()
+       message( "+++ profiling is off" )
+       set( CMAKE_C_FLAGS "-g " )
+endif()
+unset( GPROF CACHE )                                   # we don't want this to persist
 
 # Include modules
 add_subdirectory( src/rmr/common )
 add_subdirectory( src/rmr/nng )
+add_subdirectory( src/rmr/si )
 add_subdirectory( doc )                                # this will auto skip if {X}fm is not available
 
 
@@ -254,6 +269,23 @@ if( DEV_PKG )
                VERSION ${major_version}.${minor_version}.${patch_level} )
 endif()
 
+add_library( rmr_si_shared SHARED "$<TARGET_OBJECTS:rmr_si_objects>;$<TARGET_OBJECTS:common_objects>" )
+set_target_properties( rmr_si_shared
+       PROPERTIES
+       OUTPUT_NAME "rmr_si"
+       SOVERSION ${major_version}
+       VERSION ${major_version}.${minor_version}.${patch_level} )
+
+# even if not generating a development package we still need to generate the .a so that health check 
+# can link against it to avoid RPM install issues.
+#
+add_library( rmr_si_static STATIC "$<TARGET_OBJECTS:rmr_si_objects>;$<TARGET_OBJECTS:common_objects>" )
+set_target_properties( rmr_si_static
+       PROPERTIES
+       OUTPUT_NAME "rmr_si"
+       SOVERSION ${major_version}
+       VERSION ${major_version}.${minor_version}.${patch_level} )
+
 # if externals need to be built, then we must force them to be built first by depending on them
 if( need_ext )
        if( DEV_PKG )
@@ -263,6 +295,28 @@ if( need_ext )
        endif()
 endif()
 
+# ------------- testing -------------------------------------------------------
+enable_testing()
+add_test(
+               NAME drive_unit_tests
+               COMMAND bash ../test/unit_test.ksh -q 
+               WORKING_DIRECTORY ../test
+)
+
+# cmake seems unable to start test/app_test/run_all.ksh, so we have to lump
+# a dummy script in ./test that does the obvious thing.
+add_test(
+               NAME drive_app
+               COMMAND bash  ./run_app_tests LD_LIBRARY_PATH=${install_root}/lib C_INCLUDE_PATH=${install_root}/include
+               WORKING_DIRECTORY ../test
+)
+
+
+# --- support binaries that depend on the libs identified above ---------------
+add_subdirectory( src/support )
+
+# ------------- packaging -----------------------------------------------------
+
 #
 if( APPLE  )
        message( "### apple hack: forcing hard coded library paths for nng/nano dynamic libraries" )
@@ -274,9 +328,9 @@ endif()
 # the library (.so) files and nothing more.
 #
 if( DEV_PKG )
-       set( target_list "rmr_nng_static" )
+       set( target_list "rmr_nng_static;rmr_si_static" )
 else()
-       set( target_list "rmr_nng_shared" )
+       set( target_list "rmr_nng_shared;rmr_si_shared" )
 endif()
 
 install( TARGETS ${target_list} EXPORT LibraryConfig
@@ -311,6 +365,9 @@ IF( EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake" )
        set( CPACK_DEBIAN_PACKAGE_NAME ${deb_pkg_name} )
        set( CPACK_RPM_PACKAGE_NAME ${rpm_pkg_name} )
 
+       # auto dependency checking makes the RPM install fail, see NOTES
+       set( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION="/usr/local /usr/local/bin /usr/local/lib" )
+
        set( CPACK_set_DESTDIR "on" )
        set( CPACK_PACKAGING_INSTALL_PREFIX "${install_root}" )
        set( CPACK_GENERATOR "${pkg_list}" )