From fdb6e73fc3fa68a20cafb7297b4989cb13d93795 Mon Sep 17 00:00:00 2001 From: Oliver Hahn Date: Tue, 30 Nov 2021 22:47:40 +0100 Subject: [PATCH] updated RPC/XDR routines to compile against TIRPC library since RPC is missing from modern glibc --- CMakeLists.txt | 10 ++++++ FindTIRPC.cmake | 47 ++++++++++++++++++++++++++++ src/plugins/output_tipsy.cc | 5 +++ src/plugins/output_tipsy_resample.cc | 4 +++ 4 files changed, 66 insertions(+) create mode 100644 FindTIRPC.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e8a104..e83719d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,10 @@ if(POLICY CMP0074) endif() find_package(FFTW3 COMPONENTS SINGLE DOUBLE THREADS) +######################################################################################################################## +# TIRPC, needed only for Tipsy format +find_package(TIRPC) + ######################################################################################################################## # Add a custom command that produces version.cc, plus # a dummy output that's not actually produced, in order @@ -106,6 +110,12 @@ if(HDF5_FOUND) target_compile_options(${PRGNAME} PRIVATE "-DH5_USE_16_API") endif(HDF5_FOUND) +if(TIRPC_FOUND) + target_link_libraries(${PRGNAME} ${TIRPC_LIBRARIES}) + target_include_directories(${PRGNAME} PRIVATE ${TIRPC_INCLUDE_DIRS}) + target_compile_options(${PRGNAME} PRIVATE "-DHAVE_TIRPC") +endif(TIRPC_FOUND) + target_link_libraries(${PRGNAME} ${FFTW3_LIBRARIES}) target_include_directories(${PRGNAME} PRIVATE ${FFTW3_INCLUDE_DIRS}) diff --git a/FindTIRPC.cmake b/FindTIRPC.cmake new file mode 100644 index 0000000..0695c73 --- /dev/null +++ b/FindTIRPC.cmake @@ -0,0 +1,47 @@ +# FindTIRPC +# --------- +# +# OH: taken from https://github.com/snort3/snort3/blob/master/cmake/FindTIRPC.cmake +# +# Find the native TIRPC includes and library. +# +# Result Variables +# ^^^^^^^^^^^^^^^^ +# +# This module will set the following variables in your project: +# +# ``TIRPC_INCLUDE_DIRS`` +# where to find rpc.h, etc. +# ``TIRPC_LIBRARIES`` +# the libraries to link against to use TIRPC. +# ``TIRPC_VERSION`` +# the version of TIRPC found. +# ``TIRPC_FOUND`` +# true if the TIRPC headers and libraries were found. +# + +find_package(PkgConfig QUIET) +pkg_check_modules(PC_TIRPC libtirpc) + +find_path(TIRPC_INCLUDE_DIRS + NAMES netconfig.h + PATH_SUFFIXES tirpc + HINTS ${PC_TIRPC_INCLUDE_DIRS} +) + +find_library(TIRPC_LIBRARIES + NAMES tirpc + HINTS ${PC_TIRPC_LIBRARY_DIRS} +) + +set(TIRPC_VERSION ${PC_TIRPC_VERSION}) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(TIRPC + REQUIRED_VARS TIRPC_LIBRARIES TIRPC_INCLUDE_DIRS + VERSION_VAR TIRPC_VERSION +) + +mark_as_advanced(TIRPC_INCLUDE_DIRS TIRPC_LIBRARIES) + diff --git a/src/plugins/output_tipsy.cc b/src/plugins/output_tipsy.cc index 991209d..7cc5729 100644 --- a/src/plugins/output_tipsy.cc +++ b/src/plugins/output_tipsy.cc @@ -7,6 +7,8 @@ // Copyright 2011 KIPAC/SLAC. All rights reserved. // +#if defined(HAVE_TIRPC) // needed for RPC/XDR functions + #include #include #include @@ -1109,3 +1111,6 @@ namespace{ output_plugin_creator_concrete< tipsy_output_plugin > creator2("tipsy_double"); //#endif } + + +#endif //defined(HAVE_TIRPC) \ No newline at end of file diff --git a/src/plugins/output_tipsy_resample.cc b/src/plugins/output_tipsy_resample.cc index 36fe8a0..7d0e82a 100644 --- a/src/plugins/output_tipsy_resample.cc +++ b/src/plugins/output_tipsy_resample.cc @@ -8,6 +8,8 @@ // +#if defined(HAVE_TIRPC) // needed for RPC/XDR functions + #include #include #include @@ -1398,3 +1400,5 @@ namespace output_plugin_creator_concrete< tipsy_output_plugin_res >creator2 ("tipsy_double_resample"); #endif } + +#endif // defined(HAVE_TIRPC) \ No newline at end of file