mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-12 16:21:13 +00:00
cmake cleanups and fixes
* fix overlinking of libFairMQ * import dependencies in find modules * provide FairMQinstall target * add gtest helper module * add cotire helper module * add many comments * cleanup fairmq cmake file * add FindPStreams module * link logger into libFairMQ * drop root dictionary generation * bump min required cmake version to 3.7.2
This commit is contained in:
parent
7e34f7042f
commit
35b3212f7e
|
@ -24,7 +24,7 @@ DerivePointerBinding: false
|
|||
ExperimentalAutoDetectBinPacking: false
|
||||
IndentCaseLabels: true
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: All
|
||||
NamespaceIndentation: None
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: false
|
||||
PenaltyBreakBeforeFirstCallParameter: 1
|
||||
|
|
|
@ -1,185 +1,314 @@
|
|||
################################################################################
|
||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence version 3 (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
################################################################################
|
||||
# Copyright (C) 2012-2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
#
|
||||
# This is the top-level cmake file for the FairMQ submodule.
|
||||
#
|
||||
# Testing:
|
||||
# Enable the building of tests by enabling the cmake option BUILD_TESTING.
|
||||
#
|
||||
# Linking:
|
||||
# Depend on FairMQ target, if you want to link against libFairMQ.
|
||||
#
|
||||
# Convenience targets defined:
|
||||
# * FairMQFull - build everything in the submodule except tests
|
||||
# * FairMQAll - build everything including tests, if enabled
|
||||
# * FairMQInstall - install everything from the FairMQ submodule
|
||||
# * FairMQTests - build all tests in the submodule
|
||||
#
|
||||
#
|
||||
|
||||
############################
|
||||
# preprocessor definitions #
|
||||
############################
|
||||
if(NANOMSG_FOUND)
|
||||
add_definitions(-DNANOMSG_FOUND)
|
||||
if(MSGPACK_FOUND)
|
||||
add_definitions(-DMSGPACK_FOUND)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
##################
|
||||
# subdirectories #
|
||||
##################
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
if(DDS_FOUND)
|
||||
add_subdirectory(plugins/config)
|
||||
add_subdirectory(plugins/control)
|
||||
endif(DDS_FOUND)
|
||||
|
||||
|
||||
##########################
|
||||
# libFairMQ header files #
|
||||
##########################
|
||||
set(FAIRMQ_HEADER_FILES
|
||||
FairMQChannel.h
|
||||
FairMQConfigPlugin.h
|
||||
FairMQConfigurable.h
|
||||
FairMQControlPlugin.h
|
||||
FairMQDevice.h
|
||||
FairMQLogger.h
|
||||
FairMQMessage.h
|
||||
FairMQParts.h
|
||||
FairMQPoller.h
|
||||
FairMQSocket.h
|
||||
FairMQStateMachine.h
|
||||
FairMQTransportFactory.h
|
||||
FairMQTransports.h
|
||||
devices/FairMQBenchmarkSampler.h
|
||||
devices/FairMQMerger.h
|
||||
devices/FairMQMultiplier.h
|
||||
devices/FairMQProxy.h
|
||||
devices/FairMQSink.h
|
||||
devices/FairMQSplitter.h
|
||||
options/FairMQEventManager.h
|
||||
options/FairMQParser.h
|
||||
options/FairMQProgOptions.h
|
||||
options/FairMQSuboptParser.h
|
||||
options/FairProgOptions.h
|
||||
options/FairProgOptionsHelper.h
|
||||
runFairMQDevice.h
|
||||
shmem/FairMQContextSHM.h
|
||||
shmem/FairMQMessageSHM.h
|
||||
shmem/FairMQPollerSHM.h
|
||||
shmem/FairMQSocketSHM.h
|
||||
shmem/FairMQTransportFactorySHM.h
|
||||
tools/FairMQTools.h
|
||||
tools/runSimpleMQStateMachine.h
|
||||
zeromq/FairMQContextZMQ.h
|
||||
zeromq/FairMQMessageZMQ.h
|
||||
zeromq/FairMQPollerZMQ.h
|
||||
zeromq/FairMQSocketZMQ.h
|
||||
zeromq/FairMQTransportFactoryZMQ.h
|
||||
)
|
||||
|
||||
if(NANOMSG_FOUND)
|
||||
set(FAIRMQ_HEADER_FILES ${FAIRMQ_HEADER_FILES}
|
||||
nanomsg/FairMQMessageNN.h
|
||||
nanomsg/FairMQPollerNN.h
|
||||
nanomsg/FairMQSocketNN.h
|
||||
nanomsg/FairMQTransportFactoryNN.h
|
||||
)
|
||||
endif()
|
||||
|
||||
# TODO only for transition to namespaces
|
||||
set(FAIRMQ_HEADER_FILES_NAMESPACED
|
||||
logger/logger.h
|
||||
logger/logger_def.h
|
||||
)
|
||||
|
||||
if("${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}" VERSION_LESS "1.56")
|
||||
set(FAIRMQ_HEADER_FILES_NAMESPACED ${FAIRMQ_HEADER_FILES_NAMESPACED}
|
||||
logger/fairroot_null_deleter.h
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
set(FAIRMQ_SOURCE_FILES
|
||||
FairMQChannel.cxx
|
||||
FairMQConfigurable.cxx
|
||||
FairMQDevice.cxx
|
||||
FairMQLogger.cxx
|
||||
FairMQMessage.cxx
|
||||
FairMQPoller.cxx
|
||||
FairMQSocket.cxx
|
||||
FairMQStateMachine.cxx
|
||||
FairMQTransportFactory.cxx
|
||||
devices/FairMQBenchmarkSampler.cxx
|
||||
devices/FairMQMerger.cxx
|
||||
devices/FairMQMultiplier.cxx
|
||||
devices/FairMQProxy.cxx
|
||||
devices/FairMQSink.cxx
|
||||
devices/FairMQSplitter.cxx
|
||||
logger/logger.cxx
|
||||
options/FairMQParser.cxx
|
||||
options/FairMQProgOptions.cxx
|
||||
options/FairMQSuboptParser.cxx
|
||||
options/FairProgOptions.cxx
|
||||
shmem/FairMQContextSHM.cxx
|
||||
shmem/FairMQMessageSHM.cxx
|
||||
shmem/FairMQPollerSHM.cxx
|
||||
shmem/FairMQSocketSHM.cxx
|
||||
shmem/FairMQTransportFactorySHM.cxx
|
||||
zeromq/FairMQContextZMQ.cxx
|
||||
zeromq/FairMQMessageZMQ.cxx
|
||||
zeromq/FairMQPollerZMQ.cxx
|
||||
zeromq/FairMQSocketZMQ.cxx
|
||||
zeromq/FairMQTransportFactoryZMQ.cxx
|
||||
)
|
||||
|
||||
if(NANOMSG_FOUND)
|
||||
set(FAIRMQ_SOURCE_FILES ${FAIRMQ_SOURCE_FILES}
|
||||
nanomsg/FairMQMessageNN.cxx
|
||||
nanomsg/FairMQPollerNN.cxx
|
||||
nanomsg/FairMQSocketNN.cxx
|
||||
nanomsg/FairMQTransportFactoryNN.cxx
|
||||
)
|
||||
endif()
|
||||
|
||||
###################
|
||||
# configure files #
|
||||
###################
|
||||
configure_file(${CMAKE_SOURCE_DIR}/fairmq/run/startMQBenchmark.sh.in ${CMAKE_BINARY_DIR}/bin/startMQBenchmark.sh)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/fairmq/run/benchmark.json ${CMAKE_BINARY_DIR}/bin/config/benchmark.json)
|
||||
|
||||
add_subdirectory(logger)
|
||||
add_subdirectory(test)
|
||||
|
||||
Set(INCLUDE_DIRECTORIES
|
||||
${CMAKE_SOURCE_DIR}/fairmq
|
||||
${CMAKE_SOURCE_DIR}/fairmq/devices
|
||||
${CMAKE_SOURCE_DIR}/fairmq/tools
|
||||
${CMAKE_SOURCE_DIR}/fairmq/options
|
||||
${CMAKE_SOURCE_DIR}/fairmq/logger
|
||||
${CMAKE_SOURCE_DIR}/fairmq/zeromq
|
||||
${CMAKE_SOURCE_DIR}/fairmq/shmem
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
Set(SYSTEM_INCLUDE_DIRECTORIES
|
||||
${Boost_INCLUDE_DIR}
|
||||
${ZeroMQ_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
If(DDS_FOUND)
|
||||
add_subdirectory(plugins/config)
|
||||
add_subdirectory(plugins/control)
|
||||
EndIf(DDS_FOUND)
|
||||
|
||||
If(NANOMSG_FOUND)
|
||||
add_definitions(-DNANOMSG_FOUND)
|
||||
Set(INCLUDE_DIRECTORIES
|
||||
${INCLUDE_DIRECTORIES}
|
||||
${CMAKE_SOURCE_DIR}/fairmq/nanomsg
|
||||
)
|
||||
Set(SYSTEM_INCLUDE_DIRECTORIES
|
||||
${SYSTEM_INCLUDE_DIRECTORIES}
|
||||
${NANOMSG_INCLUDE_DIR}
|
||||
)
|
||||
If(MSGPACK_FOUND)
|
||||
add_definitions(-DMSGPACK_FOUND)
|
||||
Set(SYSTEM_INCLUDE_DIRECTORIES
|
||||
${SYSTEM_INCLUDE_DIRECTORIES}
|
||||
${MSGPACK_INCLUDE_DIR}
|
||||
)
|
||||
EndIf(MSGPACK_FOUND)
|
||||
EndIf(NANOMSG_FOUND)
|
||||
|
||||
Include_Directories(${INCLUDE_DIRECTORIES})
|
||||
Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
|
||||
|
||||
Set(LINK_DIRECTORIES
|
||||
${Boost_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
Link_Directories(${LINK_DIRECTORIES})
|
||||
|
||||
Set(SRCS
|
||||
"zeromq/FairMQTransportFactoryZMQ.cxx"
|
||||
"zeromq/FairMQMessageZMQ.cxx"
|
||||
"zeromq/FairMQSocketZMQ.cxx"
|
||||
"zeromq/FairMQPollerZMQ.cxx"
|
||||
"zeromq/FairMQContextZMQ.cxx"
|
||||
|
||||
"shmem/FairMQTransportFactorySHM.cxx"
|
||||
"shmem/FairMQMessageSHM.cxx"
|
||||
"shmem/FairMQSocketSHM.cxx"
|
||||
"shmem/FairMQPollerSHM.cxx"
|
||||
"shmem/FairMQContextSHM.cxx"
|
||||
|
||||
"FairMQLogger.cxx"
|
||||
"FairMQConfigurable.cxx"
|
||||
"FairMQStateMachine.cxx"
|
||||
"FairMQTransportFactory.cxx"
|
||||
"FairMQMessage.cxx"
|
||||
"FairMQSocket.cxx"
|
||||
"FairMQChannel.cxx"
|
||||
"FairMQDevice.cxx"
|
||||
"FairMQPoller.cxx"
|
||||
|
||||
"devices/FairMQBenchmarkSampler.cxx"
|
||||
"devices/FairMQMerger.cxx"
|
||||
"devices/FairMQMultiplier.cxx"
|
||||
"devices/FairMQProxy.cxx"
|
||||
"devices/FairMQSink.cxx"
|
||||
"devices/FairMQSplitter.cxx"
|
||||
|
||||
"options/FairProgOptions.cxx"
|
||||
"options/FairMQProgOptions.cxx"
|
||||
"options/FairMQParser.cxx"
|
||||
"options/FairMQSuboptParser.cxx"
|
||||
)
|
||||
|
||||
If(NANOMSG_FOUND)
|
||||
Set(SRCS
|
||||
${SRCS}
|
||||
"nanomsg/FairMQTransportFactoryNN.cxx"
|
||||
"nanomsg/FairMQMessageNN.cxx"
|
||||
"nanomsg/FairMQSocketNN.cxx"
|
||||
"nanomsg/FairMQPollerNN.cxx"
|
||||
)
|
||||
EndIf(NANOMSG_FOUND)
|
||||
|
||||
|
||||
# to copy src that are header-only files (e.g. c++ template) for FairRoot external installation
|
||||
# manual install (globbing add not recommended)
|
||||
Set(FAIRMQHEADERS
|
||||
FairMQParts.h
|
||||
FairMQTransports.h
|
||||
FairMQConfigPlugin.h
|
||||
FairMQControlPlugin.h
|
||||
runFairMQDevice.h
|
||||
options/FairProgOptionsHelper.h
|
||||
options/FairMQEventManager.h
|
||||
tools/FairMQTools.h
|
||||
tools/runSimpleMQStateMachine.h
|
||||
)
|
||||
Install(FILES ${FAIRMQHEADERS} DESTINATION include)
|
||||
|
||||
Set(DEPENDENCIES
|
||||
${DEPENDENCIES}
|
||||
${ZeroMQ_LIBRARY_SHARED}
|
||||
${Boost_THREAD_LIBRARY}
|
||||
dl
|
||||
fairmq_logger
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
${Boost_FILESYSTEM_LIBRARY}
|
||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||
${Boost_REGEX_LIBRARY}
|
||||
${Boost_DATE_TIME_LIBRARY}
|
||||
${Boost_INTERPROCESS_LIBRARY}
|
||||
)
|
||||
|
||||
If(NANOMSG_FOUND)
|
||||
Set(DEPENDENCIES
|
||||
${DEPENDENCIES}
|
||||
${NANOMSG_LIBRARY_SHARED}
|
||||
# msgpackc # currently header only
|
||||
)
|
||||
EndIf(NANOMSG_FOUND)
|
||||
|
||||
Set(LIBRARY_NAME FairMQ)
|
||||
|
||||
GENERATE_LIBRARY()
|
||||
|
||||
Set(Exe_Names
|
||||
bsampler
|
||||
merger
|
||||
multiplier
|
||||
proxy
|
||||
sink
|
||||
splitter
|
||||
runConfigExample
|
||||
)
|
||||
|
||||
Set(Exe_Source
|
||||
run/runBenchmarkSampler.cxx
|
||||
run/runMerger.cxx
|
||||
run/runMultiplier.cxx
|
||||
run/runProxy.cxx
|
||||
run/runSink.cxx
|
||||
run/runSplitter.cxx
|
||||
options/runConfigEx.cxx
|
||||
)
|
||||
|
||||
list(LENGTH Exe_Names _length)
|
||||
math(EXPR _length ${_length}-1)
|
||||
|
||||
ForEach(_file RANGE 0 ${_length})
|
||||
list(GET Exe_Names ${_file} _name)
|
||||
list(GET Exe_Source ${_file} _src)
|
||||
Set(EXE_NAME ${_name})
|
||||
Set(SRCS ${_src})
|
||||
Set(DEPENDENCIES FairMQ)
|
||||
GENERATE_EXECUTABLE()
|
||||
EndForEach(_file RANGE 0 ${_length})
|
||||
|
||||
configure_file(${CMAKE_SOURCE_DIR}/fairmq/options/startConfigExample.sh.in
|
||||
${CMAKE_BINARY_DIR}/bin/startConfigExample.sh)
|
||||
|
||||
|
||||
#################################
|
||||
# define libFairMQ build target #
|
||||
#################################
|
||||
add_library(FairMQ SHARED
|
||||
${FAIRMQ_SOURCE_FILES}
|
||||
${FAIRMQ_HEADER_FILES} # for IDE integration
|
||||
${FAIRMQ_HEADER_FILES_NAMESPACED} # for IDE integration
|
||||
)
|
||||
|
||||
|
||||
#######################
|
||||
# include directories #
|
||||
#######################
|
||||
target_include_directories(FairMQ
|
||||
PUBLIC # consumers inherit public include directories
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<INSTALL_INTERFACE:include/fairmq>
|
||||
)
|
||||
|
||||
|
||||
##################
|
||||
# link libraries #
|
||||
##################
|
||||
target_link_libraries(FairMQ
|
||||
INTERFACE # only consumers link against interface dependencies
|
||||
dl
|
||||
|
||||
PUBLIC # libFairMQ AND consumers of libFairMQ link aginst public dependencies
|
||||
pthread
|
||||
Boost::boost
|
||||
Boost::log
|
||||
Boost::log_setup
|
||||
Boost::program_options
|
||||
Boost::thread
|
||||
Boost::system
|
||||
Boost::filesystem
|
||||
Boost::regex
|
||||
Boost::date_time
|
||||
|
||||
PRIVATE # only libFairMQ links against private dependencies
|
||||
ZeroMQ
|
||||
$<$<BOOL:${NANOMSG_FOUND}>:nanomsg>
|
||||
$<$<AND:$<BOOL:${NANOMSG_FOUND}>,$<BOOL:${MSGPACK_FOUND}>>:Msgpack>
|
||||
)
|
||||
|
||||
|
||||
###############
|
||||
# executables #
|
||||
###############
|
||||
add_executable(bsampler run/runBenchmarkSampler.cxx)
|
||||
target_link_libraries(bsampler FairMQ)
|
||||
|
||||
add_executable(merger run/runMerger.cxx)
|
||||
target_link_libraries(merger FairMQ)
|
||||
|
||||
add_executable(multiplier run/runMultiplier.cxx)
|
||||
target_link_libraries(multiplier FairMQ)
|
||||
|
||||
add_executable(proxy run/runProxy.cxx)
|
||||
target_link_libraries(proxy FairMQ)
|
||||
|
||||
add_executable(sink run/runSink.cxx)
|
||||
target_link_libraries(sink FairMQ)
|
||||
|
||||
add_executable(splitter run/runSplitter.cxx)
|
||||
target_link_libraries(splitter FairMQ)
|
||||
|
||||
add_executable(runConfigExample options/runConfigEx.cxx)
|
||||
target_link_libraries(runConfigExample FairMQ)
|
||||
|
||||
|
||||
####################
|
||||
# aggregate target #
|
||||
####################
|
||||
# all targets except tests
|
||||
set(FAIRMQ_FULL_TARGETS
|
||||
FairMQ
|
||||
bsampler
|
||||
merger
|
||||
multiplier
|
||||
proxy
|
||||
sink
|
||||
splitter
|
||||
)
|
||||
add_custom_target(FairMQFull DEPENDS ${FAIRMQ_FULL_TARGETS})
|
||||
# all targets including tests, if enabled
|
||||
if(BUILD_TESTING)
|
||||
set(FAIRMQ_TEST_TARGET FairMQTests)
|
||||
endif()
|
||||
add_custom_target(FairMQAll
|
||||
DEPENDS
|
||||
FairMQFull
|
||||
${FAIRMQ_TEST_TARGET}
|
||||
)
|
||||
|
||||
|
||||
###########################
|
||||
# generate cotire targets #
|
||||
###########################
|
||||
#cotire(${FAIRMQ_FULL_TARGETS})
|
||||
# disabled by default for now, because it messes up target properties
|
||||
# still useful for development
|
||||
|
||||
|
||||
###########
|
||||
# install #
|
||||
###########
|
||||
install(
|
||||
TARGETS # FairMQFull, tests are not installed
|
||||
${FAIRMQ_FULL_TARGETS}
|
||||
|
||||
LIBRARY
|
||||
DESTINATION lib
|
||||
COMPONENT fairmq
|
||||
|
||||
RUNTIME
|
||||
DESTINATION bin
|
||||
COMPONENT fairmq
|
||||
)
|
||||
|
||||
# TODO only during transition to namespaces
|
||||
install(FILES ${FAIRMQ_HEADER_FILES}
|
||||
DESTINATION include
|
||||
COMPONENT fairmq
|
||||
)
|
||||
|
||||
# preserve relative path and prepend fairmq
|
||||
foreach(HEADER ${FAIRMQ_HEADER_FILES_NAMESPACED})
|
||||
get_filename_component(_path ${HEADER} DIRECTORY)
|
||||
file(TO_CMAKE_PATH include/fairmq/${_path} _destination)
|
||||
if("${_path}" STREQUAL "logger")
|
||||
install(FILES ${HEADER}
|
||||
DESTINATION include/logger
|
||||
COMPONENT fairmq
|
||||
)
|
||||
else()
|
||||
install(FILES ${HEADER}
|
||||
DESTINATION ${_destination}
|
||||
COMPONENT fairmq
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# use the following target to only install the fairmq component
|
||||
add_custom_target(FairMQInstall
|
||||
DEPENDS FairMQFull
|
||||
COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_COMPONENT=fairmq -P ${CMAKE_BINARY_DIR}/cmake_install.cmake
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user