Add BUILD_OFI_TRANSPORT build switch, default OFF

This commit is contained in:
Dennis Klein 2018-03-23 14:58:19 +01:00 committed by Mohammad Al-Turany
parent 727b76bb1d
commit 08581e49e1
3 changed files with 62 additions and 30 deletions

View File

@ -46,6 +46,9 @@ if(NANOMSG_FOUND)
add_definitions(-DMSGPACK_FOUND)
endif()
endif()
if(BUILD_OFI_TRANSPORT)
add_definitions(-DBUILD_OFI_TRANSPORT)
endif()
##################
@ -83,11 +86,6 @@ set(FAIRMQ_HEADER_FILES
devices/FairMQProxy.h
devices/FairMQSink.h
devices/FairMQSplitter.h
ofi/Context.h
ofi/Message.h
ofi/Poller.h
ofi/Socket.h
ofi/TransportFactory.h
options/FairMQParser.h
options/FairMQProgOptions.h
options/FairMQSuboptParser.h
@ -132,6 +130,16 @@ if(NANOMSG_FOUND)
)
endif()
if(BUILD_OFI_TRANSPORT)
set(FAIRMQ_HEADER_FILES ${FAIRMQ_HEADER_FILES}
ofi/Context.h
ofi/Message.h
ofi/Poller.h
ofi/Socket.h
ofi/TransportFactory.h
)
endif()
##########################
# libFairMQ source files #
##########################
@ -151,11 +159,6 @@ set(FAIRMQ_SOURCE_FILES
devices/FairMQProxy.cxx
# devices/FairMQSink.cxx
devices/FairMQSplitter.cxx
ofi/Context.cxx
ofi/Message.cxx
ofi/Poller.cxx
ofi/Socket.cxx
ofi/TransportFactory.cxx
options/FairMQParser.cxx
options/FairMQProgOptions.cxx
options/FairMQSuboptParser.cxx
@ -190,6 +193,17 @@ if(NANOMSG_FOUND)
)
endif()
if(BUILD_OFI_TRANSPORT)
set(FAIRMQ_SOURCE_FILES ${FAIRMQ_SOURCE_FILES}
ofi/Context.cxx
ofi/Message.cxx
ofi/Poller.cxx
ofi/Socket.cxx
ofi/TransportFactory.cxx
)
endif()
###################
# configure files #
###################
@ -202,6 +216,7 @@ configure_file(${CMAKE_SOURCE_DIR}/fairmq/options/startConfigExample.sh.in
########################
# compile protobuffers #
########################
if(BUILD_OFI_TRANSPORT)
add_custom_target(mkofibuilddir COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/ofi)
add_custom_command(
OUTPUT
@ -213,18 +228,25 @@ add_custom_command(
)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/ofi/Control.pb.h PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/ofi/Control.pb.cc PROPERTIES GENERATED TRUE)
endif()
#################################
# define libFairMQ build target #
#################################
if(BUILD_OFI_TRANSPORT)
add_library(FairMQ SHARED
${CMAKE_CURRENT_BINARY_DIR}/ofi/Control.pb.h
${CMAKE_CURRENT_BINARY_DIR}/ofi/Control.pb.cc
${FAIRMQ_SOURCE_FILES}
${FAIRMQ_HEADER_FILES} # for IDE integration
)
else()
add_library(FairMQ SHARED
${FAIRMQ_SOURCE_FILES}
${FAIRMQ_HEADER_FILES} # for IDE integration
)
endif()
#######################
# include directories #
@ -242,6 +264,9 @@ target_include_directories(FairMQ
##################
# link libraries #
##################
if(BUILD_OFI_TRANSPORT)
set(OFI_DEPS OFI::libfabric protobuf::libprotobuf)
endif()
target_link_libraries(FairMQ
INTERFACE # only consumers link against interface dependencies
@ -261,10 +286,9 @@ target_link_libraries(FairMQ
PRIVATE # only libFairMQ links against private dependencies
ZeroMQ
OFI::libfabric
protobuf::libprotobuf
Msgpack
$<$<BOOL:${NANOMSG_FOUND}>:nanomsg>
${OFI_DEPS}
)

View File

@ -12,7 +12,9 @@
#ifdef NANOMSG_FOUND
#include <nanomsg/FairMQTransportFactoryNN.h>
#endif /* NANOMSG_FOUND */
#ifdef BUILD_OFI_TRANSPORT
#include <fairmq/ofi/TransportFactory.h>
#endif
#include <FairMQLogger.h>
#include <fairmq/Tools.h>
@ -51,10 +53,12 @@ auto FairMQTransportFactory::CreateTransportFactory(const std::string& type, con
return make_shared<FairMQTransportFactoryNN>(finalId, config);
}
#endif /* NANOMSG_FOUND */
#ifdef BUILD_OFI_TRANSPORT
else if (type == "ofi")
{
return make_shared<fair::mq::ofi::TransportFactory>(finalId, config);
}
#endif /* BUILD_OFI_TRANSPORT */
else
{
LOG(error) << "Unavailable transport requested: " << "\"" << type << "\"" << ". Available are: "
@ -63,7 +67,9 @@ auto FairMQTransportFactory::CreateTransportFactory(const std::string& type, con
#ifdef NANOMSG_FOUND
<< ", \"nanomsg\""
#endif /* NANOMSG_FOUND */
#ifdef BUILD_OFI_TRANSPORT
<< ", and \"ofi\""
#endif /* BUILD_OFI_TRANSPORT */
<< ". Exiting.";
exit(EXIT_FAILURE);
}

View File

@ -63,9 +63,11 @@ TEST(Pair, MP_Nanomsg_tcp____SingleMsg)
}
#endif /* NANOMSG_FOUND */
#ifdef BUILD_OFI_TRANSPORT
TEST(Pair, MP_Ofi_____tcp____SingleMsg)
{
EXPECT_EXIT(RunPair("ofi"), ::testing::ExitedWithCode(0), "PAIR test successfull");
}
#endif /* BUILD_OFI_TRANSPORT */
} // namespace