mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-02-04 03:19:21 +00:00
fix(boost): add compatibility for Boost.Process v1 API in Boost 1.89+
Boost 1.88 replaced Boost.Process with v2, breaking the v1 API. Boost 1.89 restores v1 compatibility via <boost/process/v1.hpp>. - Fail configuration if Boost 1.88 is detected - Define FAIRMQ_BOOST_PROCESS_V1_HEADER for Boost >= 1.89 - Use conditional includes to select v1.hpp or process.hpp - Add namespace aliases (bp, bp_this) for portable API access
This commit is contained in:
committed by
Dennis Klein
parent
25abd605f3
commit
fa64faf3f7
@@ -23,6 +23,18 @@ if(BUILD_FAIRMQ OR BUILD_TIDY_TOOL)
|
|||||||
find_package2(PUBLIC Boost REQUIRED VERSION 1.66
|
find_package2(PUBLIC Boost REQUIRED VERSION 1.66
|
||||||
COMPONENTS container program_options filesystem date_time regex
|
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 <boost/process/v1.hpp> 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()
|
endif()
|
||||||
|
|
||||||
if(BUILD_FAIRMQ)
|
if(BUILD_FAIRMQ)
|
||||||
|
|||||||
@@ -176,6 +176,9 @@ if(BUILD_FAIRMQ)
|
|||||||
FAIRMQ_HAS_STD_FILESYSTEM=${FAIRMQ_HAS_STD_FILESYSTEM}
|
FAIRMQ_HAS_STD_FILESYSTEM=${FAIRMQ_HAS_STD_FILESYSTEM}
|
||||||
FAIRMQ_HAS_STD_PMR=${FAIRMQ_HAS_STD_PMR}
|
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)
|
if(DEFINED FAIRMQ_CHANNEL_DEFAULT_AUTOBIND)
|
||||||
# translate CMake boolean (TRUE, FALSE, 0, 1, OFF, ON) into C++ boolean literal (true, false)
|
# translate CMake boolean (TRUE, FALSE, 0, 1, OFF, ON) into C++ boolean literal (true, false)
|
||||||
if(FAIRMQ_CHANNEL_DEFAULT_AUTOBIND)
|
if(FAIRMQ_CHANNEL_DEFAULT_AUTOBIND)
|
||||||
|
|||||||
@@ -11,7 +11,13 @@
|
|||||||
// Needed to compile-firewall the <boost/process/async.hpp> header because it
|
// Needed to compile-firewall the <boost/process/async.hpp> header because it
|
||||||
// interferes with the <asio/buffer.hpp> header. So, let's factor
|
// interferes with the <asio/buffer.hpp> header. So, let's factor
|
||||||
// the whole dependency to Boost.Process out of the header.
|
// the whole dependency to Boost.Process out of the header.
|
||||||
|
#ifdef FAIRMQ_BOOST_PROCESS_V1_HEADER
|
||||||
|
#include <boost/process/v1.hpp>
|
||||||
|
namespace bp = boost::process::v1;
|
||||||
|
#else
|
||||||
#include <boost/process.hpp>
|
#include <boost/process.hpp>
|
||||||
|
namespace bp = boost::process;
|
||||||
|
#endif
|
||||||
#include <fairlogger/Logger.h>
|
#include <fairlogger/Logger.h>
|
||||||
|
|
||||||
namespace fair::mq::shmem {
|
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());
|
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()) {
|
if (exe.empty()) {
|
||||||
LOG(warn) << "could not find " << shmmonitor_exe_name << " in \"$" << fairmq_path_key
|
LOG(warn) << "could not find " << shmmonitor_exe_name << " in \"$" << fairmq_path_key
|
||||||
<< ":$PATH\"";
|
<< ":$PATH\"";
|
||||||
@@ -39,7 +45,7 @@ bool Manager::SpawnShmMonitor(const std::string& id)
|
|||||||
bool verbose(env.count(shmmonitor_verbose_key)
|
bool verbose(env.count(shmmonitor_verbose_key)
|
||||||
&& env.at(shmmonitor_verbose_key).to_string() == "true");
|
&& env.at(shmmonitor_verbose_key).to_string() == "true");
|
||||||
|
|
||||||
boost::process::spawn(
|
bp::spawn(
|
||||||
exe, "-x", "-m", "--shmid", id, "-d", "-t", "2000", (verbose ? "--verbose" : ""), env);
|
exe, "-x", "-m", "--shmid", id, "-d", "-t", "2000", (verbose ? "--verbose" : ""), env);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -10,7 +10,11 @@
|
|||||||
#include <fairmq/tools/Strings.h>
|
#include <fairmq/tools/Strings.h>
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
|
#ifdef FAIRMQ_BOOST_PROCESS_V1_HEADER
|
||||||
|
#include <boost/process/v1.hpp>
|
||||||
|
#else
|
||||||
#include <boost/process.hpp>
|
#include <boost/process.hpp>
|
||||||
|
#endif
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <csignal> // kill, signals
|
#include <csignal> // kill, signals
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -20,7 +24,11 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
#ifdef FAIRMQ_BOOST_PROCESS_V1_HEADER
|
||||||
|
namespace bp = boost::process::v1;
|
||||||
|
#else
|
||||||
namespace bp = boost::process;
|
namespace bp = boost::process;
|
||||||
|
#endif
|
||||||
namespace ba = boost::asio;
|
namespace ba = boost::asio;
|
||||||
namespace bs = boost::system;
|
namespace bs = boost::system;
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ if(FairLogger_VERSION VERSION_LESS 1.9.0 AND FairLogger_VERSION VERSION_GREATER_
|
|||||||
LIST(APPEND definitions FAIR_MIN_SEVERITY=trace)
|
LIST(APPEND definitions FAIR_MIN_SEVERITY=trace)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(FAIRMQ_BOOST_PROCESS_V1_HEADER)
|
||||||
|
LIST(APPEND definitions FAIRMQ_BOOST_PROCESS_V1_HEADER)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(definitions)
|
if(definitions)
|
||||||
set(definitions DEFINITIONS ${definitions})
|
set(definitions DEFINITIONS ${definitions})
|
||||||
endif()
|
endif()
|
||||||
@@ -134,6 +138,7 @@ add_testsuite(Device
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/device
|
${CMAKE_CURRENT_SOURCE_DIR}/device
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
TIMEOUT 20
|
TIMEOUT 20
|
||||||
|
${definitions}
|
||||||
${environment}
|
${environment}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,11 @@
|
|||||||
#include "runner.h"
|
#include "runner.h"
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
#ifdef FAIRMQ_BOOST_PROCESS_V1_HEADER
|
||||||
|
#include <boost/process/v1.hpp>
|
||||||
|
#else
|
||||||
#include <boost/process.hpp>
|
#include <boost/process.hpp>
|
||||||
|
#endif
|
||||||
#include <fairmq/tools/Process.h>
|
#include <fairmq/tools/Process.h>
|
||||||
#include <fairmq/tools/Unique.h>
|
#include <fairmq/tools/Unique.h>
|
||||||
#include <fairmq/Device.h>
|
#include <fairmq/Device.h>
|
||||||
|
|||||||
@@ -9,7 +9,11 @@
|
|||||||
#include "runner.h"
|
#include "runner.h"
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
#ifdef FAIRMQ_BOOST_PROCESS_V1_HEADER
|
||||||
|
#include <boost/process/v1.hpp>
|
||||||
|
#else
|
||||||
#include <boost/process.hpp>
|
#include <boost/process.hpp>
|
||||||
|
#endif
|
||||||
#include <fairmq/tools/Process.h>
|
#include <fairmq/tools/Process.h>
|
||||||
#include <fairmq/tools/Unique.h>
|
#include <fairmq/tools/Unique.h>
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,11 @@
|
|||||||
#include "runner.h"
|
#include "runner.h"
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
#ifdef FAIRMQ_BOOST_PROCESS_V1_HEADER
|
||||||
|
#include <boost/process/v1.hpp>
|
||||||
|
#else
|
||||||
#include <boost/process.hpp>
|
#include <boost/process.hpp>
|
||||||
|
#endif
|
||||||
#include <fairmq/tools/Unique.h>
|
#include <fairmq/tools/Unique.h>
|
||||||
#include <fairmq/tools/Process.h>
|
#include <fairmq/tools/Process.h>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user