|
21 | 21 | #include "html_generation.hpp" |
22 | 22 | #include <fstream> |
23 | 23 | #include <iostream> |
24 | | -#include <boost/asio/io_context.hpp> |
25 | | -#include <boost/process/v2/process.hpp> |
26 | | -#include <boost/process/v2/posix/fork_and_forget_launcher.hpp> |
| 24 | +#include <boost/version.hpp> |
| 25 | +#if BOOST_VERSION <= 108100 |
| 26 | + #include <boost/process.hpp> |
| 27 | +#else |
| 28 | + #include <boost/asio/io_context.hpp> |
| 29 | + #include <boost/process/v2/process.hpp> |
| 30 | + #include <boost/process/v2/posix/fork_and_forget_launcher.hpp> |
| 31 | +#endif |
27 | 32 | #include "browser_detection.hpp" |
28 | 33 | #include "Config.hpp" |
29 | 34 | #include "paths.hpp" |
@@ -69,12 +74,24 @@ void openFirstIndexFile(const FolderMap& fm, const std::string& html_dir) |
69 | 74 | } |
70 | 75 | // Open file via Boost Process. |
71 | 76 | std::cout << "Opening " << fullFileName << " in browser ...\n"; |
72 | | - boost::asio::io_context context; |
73 | 77 | std::vector<std::string> params = additional_parameters(browser.value().type); |
| 78 | + #if BOOST_VERSION <= 108100 |
| 79 | + std::string command = browser.value().path.string(); |
| 80 | + for (const auto& param: params) |
| 81 | + { |
| 82 | + command += " " + param; |
| 83 | + } |
| 84 | + command += " " + fullFileName; |
| 85 | + boost::process::child child(command); |
| 86 | + child.detach(); |
| 87 | + #else |
| 88 | + // After Boost 1.81.0 use process v2 API. |
| 89 | + boost::asio::io_context context; |
74 | 90 | params.push_back(fullFileName); |
75 | 91 | auto launcher = boost::process::v2::posix::fork_and_forget_launcher(); |
76 | 92 | boost::process::v2::process proc(context, browser.value().path.string(), params); |
77 | 93 | proc.detach(); |
| 94 | + #endif |
78 | 95 | } |
79 | 96 |
|
80 | 97 | int generateHtmlFiles(const MessageDatabase& mdb, const FolderMap& fm, const HTMLOptions htmlOptions) |
|
0 commit comments