diff --git a/cmake/FairMQDependencies.cmake b/cmake/FairMQDependencies.cmake index 0b5d6a0f..e965a307 100644 --- a/cmake/FairMQDependencies.cmake +++ b/cmake/FairMQDependencies.cmake @@ -23,6 +23,18 @@ if(BUILD_FAIRMQ OR BUILD_TIDY_TOOL) find_package2(PUBLIC Boost REQUIRED VERSION 1.66 COMPONENTS container program_options filesystem date_time regex ) + + # Check Boost.Process compatibility + # Boost 1.88 has broken Boost.Process v2 without v1 compatibility headers + # Boost 1.89+ provides for the old API + if(Boost_VERSION VERSION_EQUAL "1.88.0") + message(FATAL_ERROR "Boost version 1.88 is not supported due to Boost.Process API changes. " + "Please use Boost < 1.88 or >= 1.89") + endif() + + if(Boost_VERSION VERSION_GREATER_EQUAL "1.89") + set(FAIRMQ_BOOST_PROCESS_V1_HEADER ON CACHE INTERNAL "Use boost/process/v1.hpp for Boost >= 1.89") + endif() endif() if(BUILD_FAIRMQ) diff --git a/fairmq/CMakeLists.txt b/fairmq/CMakeLists.txt index df7d4d90..b993f652 100644 --- a/fairmq/CMakeLists.txt +++ b/fairmq/CMakeLists.txt @@ -176,6 +176,9 @@ if(BUILD_FAIRMQ) FAIRMQ_HAS_STD_FILESYSTEM=${FAIRMQ_HAS_STD_FILESYSTEM} FAIRMQ_HAS_STD_PMR=${FAIRMQ_HAS_STD_PMR} ) + if(FAIRMQ_BOOST_PROCESS_V1_HEADER) + target_compile_definitions(${target} PRIVATE FAIRMQ_BOOST_PROCESS_V1_HEADER) + endif() if(DEFINED FAIRMQ_CHANNEL_DEFAULT_AUTOBIND) # translate CMake boolean (TRUE, FALSE, 0, 1, OFF, ON) into C++ boolean literal (true, false) if(FAIRMQ_CHANNEL_DEFAULT_AUTOBIND) diff --git a/fairmq/shmem/Manager.cxx b/fairmq/shmem/Manager.cxx index 5d319f54..efdbf094 100644 --- a/fairmq/shmem/Manager.cxx +++ b/fairmq/shmem/Manager.cxx @@ -11,7 +11,13 @@ // Needed to compile-firewall the header because it // interferes with the header. So, let's factor // the whole dependency to Boost.Process out of the header. +#ifdef FAIRMQ_BOOST_PROCESS_V1_HEADER +#include +namespace bp = boost::process::v1; +#else #include +namespace bp = boost::process; +#endif #include namespace fair::mq::shmem { @@ -28,7 +34,7 @@ bool Manager::SpawnShmMonitor(const std::string& id) path.emplace(path.begin(), env.at(fairmq_path_key).to_string()); } - auto exe(boost::process::search_path(shmmonitor_exe_name, path)); + auto exe(bp::search_path(shmmonitor_exe_name, path)); if (exe.empty()) { LOG(warn) << "could not find " << shmmonitor_exe_name << " in \"$" << fairmq_path_key << ":$PATH\""; @@ -39,7 +45,7 @@ bool Manager::SpawnShmMonitor(const std::string& id) bool verbose(env.count(shmmonitor_verbose_key) && env.at(shmmonitor_verbose_key).to_string() == "true"); - boost::process::spawn( + bp::spawn( exe, "-x", "-m", "--shmid", id, "-d", "-t", "2000", (verbose ? "--verbose" : ""), env); return true; diff --git a/fairmq/tools/Process.cxx b/fairmq/tools/Process.cxx index b76adfbf..046d1dae 100644 --- a/fairmq/tools/Process.cxx +++ b/fairmq/tools/Process.cxx @@ -10,7 +10,11 @@ #include #include +#ifdef FAIRMQ_BOOST_PROCESS_V1_HEADER +#include +#else #include +#endif #include #include // kill, signals #include @@ -20,7 +24,11 @@ #include using namespace std; +#ifdef FAIRMQ_BOOST_PROCESS_V1_HEADER +namespace bp = boost::process::v1; +#else namespace bp = boost::process; +#endif namespace ba = boost::asio; namespace bs = boost::system; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a3dd6547..52721c3b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -16,6 +16,10 @@ if(FairLogger_VERSION VERSION_LESS 1.9.0 AND FairLogger_VERSION VERSION_GREATER_ LIST(APPEND definitions FAIR_MIN_SEVERITY=trace) endif() +if(FAIRMQ_BOOST_PROCESS_V1_HEADER) + LIST(APPEND definitions FAIRMQ_BOOST_PROCESS_V1_HEADER) +endif() + if(definitions) set(definitions DEFINITIONS ${definitions}) endif() @@ -134,6 +138,7 @@ add_testsuite(Device ${CMAKE_CURRENT_SOURCE_DIR}/device ${CMAKE_CURRENT_BINARY_DIR} TIMEOUT 20 + ${definitions} ${environment} ) diff --git a/test/device/_error_state.cxx b/test/device/_error_state.cxx index 046ac61f..0984289b 100644 --- a/test/device/_error_state.cxx +++ b/test/device/_error_state.cxx @@ -9,7 +9,11 @@ #include "runner.h" #include +#ifdef FAIRMQ_BOOST_PROCESS_V1_HEADER +#include +#else #include +#endif #include #include #include diff --git a/test/device/_exceptions.cxx b/test/device/_exceptions.cxx index a430f015..29b51a5d 100644 --- a/test/device/_exceptions.cxx +++ b/test/device/_exceptions.cxx @@ -9,7 +9,11 @@ #include "runner.h" #include +#ifdef FAIRMQ_BOOST_PROCESS_V1_HEADER +#include +#else #include +#endif #include #include diff --git a/test/device/_signals.cxx b/test/device/_signals.cxx index 5799b8ab..3fafe679 100644 --- a/test/device/_signals.cxx +++ b/test/device/_signals.cxx @@ -9,7 +9,11 @@ #include "runner.h" #include +#ifdef FAIRMQ_BOOST_PROCESS_V1_HEADER +#include +#else #include +#endif #include #include